CMA-ES / libcmaes

libcmaes is a multithreaded C++11 library with Python bindings for high performance blackbox stochastic optimization using the CMA-ES algorithm for Covariance Matrix Adaptation Evolution Strategy
Other
321 stars 78 forks source link

Limit maximum number of threads. #147

Closed abhinavagarwal07 closed 6 years ago

abhinavagarwal07 commented 8 years ago

How to limit maximum number of threads running concurrently?

beniz commented 8 years ago

See https://eigen.tuxfamily.org/dox/TopicMultiThreading.html If you are calling from C++, it might work to use the setNbThreads from Eigen. Let me know if it doesn't. Default is using all threads.

fergu commented 7 years ago

Bit late to the party here, but in C++ you can use

omp_set_num_threads(int nThreads)

omp_set_dynamic(false)

The former will set the maximum number of threads that OMP will use. The latter says that OMP will always use the maximum number of threads. OMP will try to 'smartly' distribute the load without this set, meaning it may only use 3 or 4 threads out of a maximum of 8 (for example). I've found it to be a bit unpredictable with expensive objective functions, so I set it to false.