openmp | R Documentation |
Control number of OpenMP threads used by a TMB model.
openmp(n = NULL, max = FALSE, autopar = NULL, DLL = getUserDLL())
n |
Requested number of threads, or |
max |
Logical; Set n to OpenMP runtime value 'omp_get_max_threads()'? |
autopar |
Logical; use automatic parallelization - see details. |
DLL |
DLL of a TMB model. |
This function controls the number of parallel threads used by a TMB model compiled with OpenMP.
The number of threads is part of the configuration list config()
of the DLL.
The value only affects parallelization of the DLL. It does not affect BLAS/LAPACK specific parallelization which has to be specified elsewhere.
When a DLL is loaded, the number of threads is set to 1 by default.
To activate parallelization you have to explicitly call openmp(nthreads)
after loading the DLL. Calling openmp(max=TRUE)
should normally pick up the environment variable OMP_NUM_THREADS
, but this may be platform dependent.
An experimental option autopar=TRUE
can be set to parallelize models automatically. This requires the model to be compiled with framework="TMBad"
and openmp=TRUE
without further requirements on the C++ code. If the C++ code already has explicit parallel constructs these will be ignored if automatic parallelization is enabled.
Number of threads.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.