26#ifndef _GEMA_OPENMP_H_
27#define _GEMA_OPENMP_H_
40 assert(maxThreads > 0);
42 omp_set_num_threads(maxThreads);
56 int mt = omp_get_max_threads();
58 return (nt > 0 && nt <= mt) ? nt : mt;
71 return omp_get_thread_num();
84 _oldNumThreads = omp_get_max_threads(); omp_set_num_threads(nthreads);
89 omp_set_num_threads(_oldNumThreads);
98#define GM_OMP_ASSERT_NO_DYNAMIC assert(omp_get_dynamic() == 0)
100#define GM_OMP_ASSERT_NO_DYNAMIC ((void)0)
A RAII class used to temporarily adjust the number of OMP threads in effect.
Definition gmOmp.h:80
void GmOmpInit(int maxThreads)
Initializes OpenMP to use the given maximum number of threads. It also disables dynamic scheduling.
Definition gmOmp.h:38
int GmOmpAdjustNumThreads(int nt)
Adjusts the given number of threads. If nt <= 0 or if nt > maximum number of omp threads,...
Definition gmOmp.h:53
int GmOmpThreadNum()
Returns the current Open Mp thread number (omp_get_thread_num()).
Definition gmOmp.h:68