-
Notifications
You must be signed in to change notification settings - Fork 7
v2.63.0 OpenMP Multithreading
Alternative Multithreading using openmp/libgomp. (Previous is boost::threads/pthreads) Built in a separate executable with "openmp" in it.
As this is hardware and OS dependent better check how the different Multithreading libs perform on your system. (also test different modes: sim/climb/...) Builds with 'time' in the name will print the sim time and how much CPU got used at the end. (separate build because some scripts might depend on the last line being the result)
In my tests OpenMP performed better than Boost Threads when the CPU has many cores and tuo runs with many threads. The difference is neglegtable on about 1-10 cores/threads, it becomes noticable at 10-20 threads, but with 71 threads on 72 cores OpenMP is the way to go.
To compile it yourself you might need to modify the Makefile for your OS to include '-fopenmp' in CPPFLAGS and '-lgomp' in LDFLAGS. You can remove '-lboost_thread'.
Boost:
- All Boost Threads runs a sim iteration parallel and after the parallel section they sum their results sequentially(!) up (meaning only one threads writes at a time, the others wait)
OpenMP:
- Each Thread stores his results individually and only at the end of all parallel simulation the results get summed up.
There are several environment variables to change/configure OpenMP:
Windows: "set OMP_XXX=bla" Linux: "export OMP_XXX=bla"
For example "OMP_SCHEDULE" sets the ordering of threads. Possible values are:
- static
- dynamic
- guided
- auto
- runtime
$ export OMP_SCHEDULE=guided
More info on scheduling: http://jakascorner.com/blog/2016/06/omp-for-scheduling.html
Also "OMP_CANCELLATION" is not set per default, but might improve the performance in some cases.
$ export OMP_CANCELLATION=true
http://jakascorner.com/blog/2016/08/omp-cancel.html
- seeding is different in both modes, so same seed won't produce the same result