dust_openmp_threads | R Documentation |
Politely select a number of threads to use. See Details for the algorithm
dust_openmp_threads(n = NULL, action = "error")
n |
Either |
action |
An action to perform if |
There are two limits and we will take the smaller of the two.
The first limit comes from piggy-backing off of R's normal
parallel configuration; we will use the MC_CORES
environment
variable and mc.cores
option as a guide to how many cores you
are happy to use. We take mc.cores
first, then MC_CORES
, which
is the same behaviour as parallel::mclapply
and friends.
The second limit comes from openmp. If you do not have OpenMP
support, then we use one thread (higher numbers have no effect at
all in this case). If you do have OpenMP support, we take the
smallest of the number of "processors" (reported by
omp_get_num_procs()
) the "max threads" (reported by
omp_get_max_threads()
and "thread_limit" (reported by
omp_get_thread_limit()
.
See dust_openmp_support()
for the values of all the values
that go into this calculation.
An integer, indicating the number of threads that you can use
# Default number of threads; tries to pick something friendly,
# erring on the conservative side.
dust::dust_openmp_threads(NULL)
# Try to pick something silly and it will be reduced for you
dust::dust_openmp_threads(1000, action = "fix")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.