UCL-RITS / pi_examples

A lot of ways to run the same way of calculating pi. Some of them are dumb.
Creative Commons Zero v1.0 Universal
28 stars 8 forks source link

Use `mapreduce` for Julia functional example #11

Closed giordano closed 2 years ago

giordano commented 2 years ago

mapreduce combines reduce and map into a single function, avoiding allocating intermediate arrays. This improves performance by a factor of ~3.

Some benchmarks on Myriad. Before PR:

[cceamgi@login13 julia_func_pi_dir]$ ./run.sh 
Calculating PI using:
  50000000 slices
  1 worker(s)
Obtained value of PI: 3.1415926535897936
Time taken: 0.4528329372406006 seconds
[cceamgi@login13 julia_func_pi_dir]$ ./run.sh 1000000000
Calculating PI using:
  1000000000 slices
  1 worker(s)
Obtained value of PI: 3.141592653589793
Time taken: 12.335363149642944 seconds

After PR:

[cceamgi@login13 julia_func_pi_dir]$ ./run.sh 
  Warming up...done. [0.262s]

Calculating PI using:
  1000000000 slices
  1 worker(s)
Obtained value of PI: 3.141592653589793
Time taken: 4.437 seconds