Skip to content
This repository was archived by the owner on Oct 4, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 33 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ threadpool = "1.7"
lazy_static = "1.1"
rand = "0.5.5"
itertools = "0.7.8"
hashbrown = "0.1"

[dependencies.nix]
version = "0.9"
Expand Down
1 change: 1 addition & 0 deletions LICENSE-THIRD-PARTY.txt
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ Library.
** lazy_static
** rand
** itertools
** hashbrown
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ git clone https://github.com/awslabs/fast-pseudoprimes.git
cd fast-pseudoprimes
cargo +nightly run --features numa,unstable --release
```
The code takes about 24 seconds to run from start to finish.
The code takes about 21.9 seconds to run from start to finish.

## Status of this code
This code is released as-is, and we have no plans to maintain it. We are happy to accept pull requests.
Expand Down
5 changes: 4 additions & 1 deletion src/bloomfilter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use numa_threadpool::ThreadPool;

use std::sync::{Mutex, Arc, mpsc::channel};
use std::sync::atomic::{Ordering, AtomicUsize};
use std::collections::HashMap;
use hashbrown::HashMap;
use std::time::Instant;

mod conc_bloom;
Expand Down Expand Up @@ -230,6 +230,7 @@ pub fn final_sieve(
t1: &[u64],
t2: &[u64]
) -> Vec<Pseudoprime> {
let total = Instant::now();
let t2map = Arc::new(t2map);
let pool = ThreadPool::new(|_| ());
let t1_product_set = Arc::new(ProductSet::new(t1_forward, MODULUS));
Expand Down Expand Up @@ -264,6 +265,8 @@ pub fn final_sieve(

let t3_misses = t3_misses.load(Ordering::SeqCst);

println!("[final_sieve] Completed in {}ms", total.elapsed().as_millis());

println!("Found {} pseudoprimes, with {} T3 misses, {} T2 false positives",
results.len(), t3_misses, t2map.len() - t3_misses - results.len());

Expand Down
3 changes: 3 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// SPDX-License-Identifier: Apache-2.0

#![allow(dead_code)]
#![cfg_attr(feature = "unstable", feature(duration_as_u128))]
#![cfg_attr(feature = "unstable", feature(asm))]
#![cfg_attr(feature = "unstable", feature(core_intrinsics))]
#![cfg_attr(feature = "unstable", feature(avx512_target_feature))]
Expand All @@ -11,6 +12,8 @@ extern crate lazy_static;
extern crate modinverse;
extern crate rug;
extern crate threadpool;
extern crate hashbrown;

#[cfg(feature="unstable")]
extern crate libc;
extern crate itertools;
Expand Down
3 changes: 3 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// SPDX-License-Identifier: Apache-2.0

#![cfg_attr(feature = "unstable", feature(asm))]
#![cfg_attr(feature = "unstable", feature(duration_as_u128))]

extern crate pseudoprimes;
extern crate rug;
Expand All @@ -21,6 +22,7 @@ fn main() {

// fp p<=0.001, 32GiB, k=2
let filter = bloom_t1(&T1_INVERSE);
println!("[timing]: bloom_t1 {} milliseconds", total.elapsed().as_millis());
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will break entirely if we don't have the unstable feature enabled.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated it to use seconds/milliseconds correctly:

cargo +nightly run --features numa --release | grep Completed
[bloom_t1] Completed 4294967296 in 120 sec
[t2_map] Completed 4294967296 in 12 sec
[final_sieve] Completed in 1 sec
Completed in: 134 sec, primes found: 55

cargo +nightly run --features numa,unstable --release | grep Completed
[bloom_t1] Completed 4294967296 in 13813 ms
[t2_map] Completed 4294967296 in 6179 ms
[final_sieve] Completed in 1923 ms
Completed in: 21945 ms, primes found: 55


let t2_map = build_t2(filter, &T2);

Expand All @@ -32,5 +34,6 @@ fn main() {
println!("Found passing prime {}, vector {:?}", result.pseudoprime, result.factors);
}

println!("[total]: Completed in {}ms", total.elapsed().as_millis());
println!("Total time: {} seconds, primes found: {}", total.elapsed().as_secs(), results.len());
}
4 changes: 2 additions & 2 deletions src/progress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ impl<'a> Drop for ProgressHandle<'a> {

impl<'a> Drop for ProgressReporter {
fn drop(&mut self) {
println!("[{}] Completed {} in {}s", self.desc, self.counter.load(Ordering::SeqCst),
self.start_time.elapsed().as_secs());
println!("[{}] Completed {} in {}ms", self.desc, self.counter.load(Ordering::SeqCst),
self.start_time.elapsed().as_millis());
}
}

Expand Down