7 #include "imstkThreadManager.h" 8 #include "imstkLogger.h" 12 namespace ParallelUtils
14 std::unique_ptr<tbb::global_control> ThreadManager::s_tbbGlobalControl;
19 LOG_IF(FATAL, (nThreads == 0)) <<
"Invalid number of threads";
20 LOG(INFO) <<
"Set number of worker threads to " << nThreads;
22 if (s_tbbGlobalControl)
24 s_tbbGlobalControl.reset();
27 s_tbbGlobalControl = std::unique_ptr<tbb::global_control>(
28 new tbb::global_control(tbb::global_control::max_allowed_parallelism,
41 return s_tbbGlobalControl->active_value(tbb::global_control::max_allowed_parallelism);
static void setThreadPoolSize(const size_t nThreads)
Set system-wide thread pool size for parallel computation.
static size_t getThreadPoolSize()
Returns the size of the thread pool.
static void setOptimalParallelism()
Set system-wide thread pool size to the optimal value (use all logical cores)