Set the number of threads to be used in SimInf code that is
parallelized with OpenMP (if available). The number of threads is
initialized when SimInf is first loaded in the R session using
optional envioronment variables (see ‘Details’). It is also
possible to specify the number of threads by calling
set_num_threads
. If the environment variables that affect
the number of threads change, then set_num_threads
must be
called again for it to take effect.
Details
The omp_get_num_procs()
function is used to determine the
number of processors that are available to the device at the time
the routine is called. The number of threads is then limited by
omp_get_thread_limit()
and the current values of the
environmental variables (if set)
Sys.getenv("OMP_THREAD_LIMIT")
Sys.getenv("OMP_NUM_THREADS")
Sys.getenv("SIMINF_NUM_THREADS")
Additionally, the maximum number of threads can be controlled by
the threads
argument, given that its value is not above any
of the limits described above.