-
Notifications
You must be signed in to change notification settings - Fork 6
Closed
Description
I am using OCaml 5.1.1 and I see different results for the Parallel Initialization of float array with Random Numbers.
"Although we expected to see speedup executing in multiple cores, the code actually slows down as the number of cores increase."
The test results is showing that code is faster with more cores.
hyperfine 'dune exec ./float_init_par_unsafe.exe 1 100_000_000' 'dune exec ./float_init_par_unsafe.exe 2 100_000_000' 'dune exec ./float_init_par_unsafe.exe 4 100_000_000' 'dune exec ./float_init_par_unsafe.exe 8 100_000_000' 'dune exec ./float_init_par_unsafe.exe 12 100_000_000'
Benchmark 1: dune exec ./float_init_par_unsafe.exe 1 100_000_000
Time (mean ± σ): 1.643 s ± 0.064 s [User: 1.384 s, System: 0.258 s]
Range (min … max): 1.596 s … 1.808 s 10 runs
Benchmark 2: dune exec ./float_init_par_unsafe.exe 2 100_000_000
Time (mean ± σ): 909.2 ms ± 19.7 ms [User: 1448.2 ms, System: 292.0 ms]
Range (min … max): 885.9 ms … 956.9 ms 10 runs
Benchmark 3: dune exec ./float_init_par_unsafe.exe 4 100_000_000
Time (mean ± σ): 584.7 ms ± 12.4 ms [User: 1684.7 ms, System: 306.1 ms]
Range (min … max): 560.7 ms … 606.5 ms 10 runs
Benchmark 4: dune exec ./float_init_par_unsafe.exe 8 100_000_000
Time (mean ± σ): 488.0 ms ± 27.3 ms [User: 2558.5 ms, System: 368.4 ms]
Range (min … max): 443.2 ms … 544.6 ms 10 runs
Benchmark 5: dune exec ./float_init_par_unsafe.exe 12 100_000_000
Time (mean ± σ): 500.2 ms ± 18.8 ms [User: 3453.3 ms, System: 449.3 ms]
Range (min … max): 470.1 ms … 526.7 ms 10 runs
Summary
'dune exec ./float_init_par_unsafe.exe 8 100_000_000' ran
1.02 ± 0.07 times faster than 'dune exec ./float_init_par_unsafe.exe 12 100_000_000'
1.20 ± 0.07 times faster than 'dune exec ./float_init_par_unsafe.exe 4 100_000_000'
1.86 ± 0.11 times faster than 'dune exec ./float_init_par_unsafe.exe 2 100_000_000'
3.37 ± 0.23 times faster than 'dune exec ./float_init_par_unsafe.exe 1 100_000_000'
The version with states array for Random is slower than the first version.
hyperfine 'dune exec ./float_init_par2.exe 1 100_000_000' 'dune exec ./float_init_par2.exe 2 100_000_000' 'dune exec ./float_init_par2.exe 4 100_000_000' 'dune exec ./float_init_par2.exe 8 100_000_000' 'dune exec ./float_init_par2.exe 12 100_000_000'
Benchmark 1: dune exec ./float_init_par2.exe 1 100_000_000
Time (mean ± σ): 2.193 s ± 0.014 s [User: 1.938 s, System: 0.256 s]
Range (min … max): 2.179 s … 2.219 s 10 runs
Benchmark 2: dune exec ./float_init_par2.exe 2 100_000_000
Time (mean ± σ): 2.173 s ± 0.125 s [User: 4.002 s, System: 0.271 s]
Range (min … max): 2.051 s … 2.379 s 10 runs
Benchmark 3: dune exec ./float_init_par2.exe 4 100_000_000
Time (mean ± σ): 1.404 s ± 0.044 s [User: 4.934 s, System: 0.332 s]
Range (min … max): 1.355 s … 1.518 s 10 runs
Benchmark 4: dune exec ./float_init_par2.exe 8 100_000_000
Time (mean ± σ): 966.9 ms ± 49.9 ms [User: 6622.6 ms, System: 378.7 ms]
Range (min … max): 892.9 ms … 1050.9 ms 10 runs
Benchmark 5: dune exec ./float_init_par2.exe 12 100_000_000
Time (mean ± σ): 856.5 ms ± 28.1 ms [User: 8483.6 ms, System: 476.1 ms]
Range (min … max): 806.7 ms … 892.0 ms 10 runs
Summary
'dune exec ./float_init_par2.exe 12 100_000_000' ran
1.13 ± 0.07 times faster than 'dune exec ./float_init_par2.exe 8 100_000_000'
1.64 ± 0.07 times faster than 'dune exec ./float_init_par2.exe 4 100_000_000'
2.54 ± 0.17 times faster than 'dune exec ./float_init_par2.exe 2 100_000_000'
2.56 ± 0.09 times faster than 'dune exec ./float_init_par2.exe 1 100_000_000'
Version 3 is the fastest (matches with the Readme).
hyperfine 'dune exec ./float_init_par3.exe 1 100_000_000' 'dune exec ./float_init_par3.exe 2 100_000_000' 'dune exec ./float_init_par3.exe 4 100_000_000' 'dune exec ./float_init_par3.exe 8 100_000_000' 'dune exec ./float_init_par3.exe 12 100_000_000'
Benchmark 1: dune exec ./float_init_par3.exe 1 100_000_000
Time (mean ± σ): 849.3 ms ± 9.9 ms [User: 576.3 ms, System: 273.1 ms]
Range (min … max): 842.2 ms … 870.1 ms 10 runs
Warning: Statistical outliers were detected. Consider re-running this benchmark on a quiet system without any interferences from other programs. It might help to use the '--warmup' or '--prepare' options.
Benchmark 2: dune exec ./float_init_par3.exe 2 100_000_000
Time (mean ± σ): 474.4 ms ± 6.7 ms [User: 612.1 ms, System: 266.1 ms]
Range (min … max): 469.2 ms … 490.9 ms 10 runs
Warning: Statistical outliers were detected. Consider re-running this benchmark on a quiet system without any interferences from other programs. It might help to use the '--warmup' or '--prepare' options.
Benchmark 3: dune exec ./float_init_par3.exe 4 100_000_000
Time (mean ± σ): 293.1 ms ± 5.2 ms [User: 652.9 ms, System: 307.1 ms]
Range (min … max): 286.0 ms … 302.6 ms 10 runs
Benchmark 4: dune exec ./float_init_par3.exe 8 100_000_000
Time (mean ± σ): 275.1 ms ± 9.1 ms [User: 1048.4 ms, System: 369.8 ms]
Range (min … max): 263.8 ms … 296.8 ms 10 runs
Benchmark 5: dune exec ./float_init_par3.exe 12 100_000_000
Time (mean ± σ): 236.1 ms ± 5.5 ms [User: 1528.3 ms, System: 466.9 ms]
Range (min … max): 227.4 ms … 245.2 ms 13 runs
Summary
'dune exec ./float_init_par3.exe 12 100_000_000' ran
1.17 ± 0.05 times faster than 'dune exec ./float_init_par3.exe 8 100_000_000'
1.24 ± 0.04 times faster than 'dune exec ./float_init_par3.exe 4 100_000_000'
2.01 ± 0.05 times faster than 'dune exec ./float_init_par3.exe 2 100_000_000'
3.60 ± 0.09 times faster than 'dune exec ./float_init_par3.exe 1 100_000_000'
Metadata
Metadata
Assignees
Labels
No labels