Skip to content
Snippets Groups Projects
Commit f452f3f4 authored by Neil Gershenfeld's avatar Neil Gershenfeld
Browse files

wip

parent b120900e
Branches
No related tags found
No related merge requests found
Pipeline #47070 passed
......@@ -15,7 +15,8 @@
|1,090|[numbapig.py](Python/numbapig.py)|Python, Numba, CUDA, 5120 cores|NVIDIA V100|March, 2020|
|1,062|[taichipi.py](Python/taichipi.py)|Python, Taichi, 5120 cores|NVIDIA V100|March, 2023|
|811|prior|Cray XT4|C, MPI, 2048 processes|prior|
|484|[threadpi.rs](Rust/threadpi.rs)|Rust, 96 threads and cores<br>cargo run --release -- 96|Graviton4|December, 2024|
|501|[rayonpi.rs](Rust/rayonpi.rs)|Rust Rayon, 96 cores<br>cargo run --release -- 96|Graviton4|December, 2024|
|484|[threadpi.rs](Rust/threadpi.rs)|Rust threads, 96 cores<br>cargo run --release -- 96|Graviton4|December, 2024|
|315|[numbapip.py](Python/numbapip.py)|Python, Numba, parallel, fastmath<br>96 cores|Intel 2x Xeon Platinum 8175M|February, 2020|
|272|[threadpi.c](C/threadpi.c)|C, 96 threads<br>gcc threadpi.c -o threadpi -O3 -ffast-math -pthread|Intel 2x Xeon Platinum 8175M|June, 2019|
|267|[threadpi.cpp](C++/threadpi.cpp)|C++, 96 threads<br>g++ threadpi.cpp -o threadpi -O3 -ffast-math -pthread|Intel 2x Xeon Platinum 8175M|March, 2020|
......@@ -31,6 +32,7 @@
|16.1|[pi.html](https://pub.pages.cba.mit.edu/pi/JavaScript/pi.html)|JavaScript, 6 workers|Intel i7-8700T|November, 2018|
|15.7|[clusterpi.js](Node/clusterpi.js)|Node, 6 workers|Intel i7-8700T|December, 2018|
|9.37|[pi.c](C/pi.c)|C<br>gcc pi.c -o pi -lm -O3 -ffast-math|Intel i7-8700T|November, 2018|
|5.55|[rayonpi.rs](Rust/rayonpi.rs)|Rust Rayon, 1 core<br>cargo run --release -- 96|Graviton4|December, 2024|
|4.87|[numbapi.py](Python/numbapi.py)|Python, Numba|Intel i7-8700T|February, 2020|
|4.63|[pi.c](C/pi.c)|C<br>gcc pi.c -o pi -lm -O3|Intel i7-8700T|December, 2024|
|3.73|[pi.html](https://pub.pages.cba.mit.edu/pi/JavaScript/pi.html)|JavaScript, 1 worker|Intel i7-8700T|November, 2018|
......
/*
* rayonpi.rs
* Neil Gershenfeld 12/24/24
* Rust Rayon parallel pi calculation benchmark
* pi = 3.14159265358979323846
*/
use std::time::SystemTime;
use std::thread::available_parallelism;
use rayon::prelude::*;
const NPTS:u64 = 1e9 as u64;
fn main() {
let a:f64 = 0.5;
let b:f64 = 0.75;
let c:f64 = 0.25;
//
let start = SystemTime::now().duration_since(SystemTime::UNIX_EPOCH).unwrap().as_micros();
let pi:f64 = (1..=NPTS).into_iter()
.map(|i| a/(((i as f64)-b)*((i as f64)-c)))
.sum();
let end = SystemTime::now().duration_since(SystemTime::UNIX_EPOCH).unwrap().as_micros();
let dt = ((end-start) as f64)/1e6;
let mflops = (NPTS as f64)*5.0/((dt as f64)*1e6);
println!("NPTS = {NPTS}, cores = 1, pi = {pi}");
println!("time = {dt:.3}, estimated MFlops = {mflops:.0}");
//
let num_cores:u64 = available_parallelism().unwrap().get() as u64;
let start = SystemTime::now().duration_since(SystemTime::UNIX_EPOCH).unwrap().as_micros();
let npts:u64 = NPTS*num_cores;
let pi:f64 = (1..=npts).into_par_iter()
.map(|i| a/(((i as f64)-b)*((i as f64)-c)))
.sum();
let end = SystemTime::now().duration_since(SystemTime::UNIX_EPOCH).unwrap().as_micros();
let dt = ((end-start) as f64)/1e6;
let mflops = (npts as f64)*5.0/((dt as f64)*1e6);
println!("NPTS = {npts}, cores = {num_cores}, pi = {pi}");
println!("time = {dt:.3}, estimated MFlops = {mflops:.0}");
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment