Return information about OpenMP support for this system. For individual models look at the $has_openmp() method.

dust_openmp_support(check_compile = FALSE)

Arguments

check_compile

Logical, indicating if we should check if we can compile an openmp program - this is slow the first time.

Value

A list with information about the openmp support on your system.

  • The first few elements come from the openmp library directly: num_proc, max_threads, thread_limit; these correspond to a call to the function omp_get_<name>() in C and openmp_version which is the value of the _OPENMP macro.

  • A logical has_openmp which is TRUE if it looks like runtime OpenMP support is available

  • The next elements tell you about different sources that might control the number of threads allowed to run: mc.cores (from the R option with the same name), OMP_THREAD_LIMIT, OMP_NUM_THREADS, MC_CORES (from environment variables), limit_r (limit computed against R-related control variables), limit_openmp (limit computed against OpenMP-related variables) and limit the smaller of limit_r and limit_openmp

See also

dust_openmp_threads() for setting a polite number of threads.

Examples

# System wide support
dust::dust_openmp_support()
#> $num_procs
#> [1] 2
#> 
#> $max_threads
#> [1] 2
#> 
#> $thread_limit
#> [1] 2147483647
#> 
#> $openmp_version
#> [1] 201511
#> 
#> $has_openmp
#> [1] TRUE
#> 
#> $mc.cores
#> [1] NA
#> 
#> $OMP_THREAD_LIMIT
#> [1] NA
#> 
#> $OMP_NUM_THREADS
#> [1] NA
#> 
#> $MC_CORES
#> [1] NA
#> 
#> $limit_r
#> [1] 1
#> 
#> $limit_openmp
#> [1] 2
#> 
#> $limit
#> [1] 1
#> 

# Support compiled into a generator
walk <- dust::dust_example("walk")
walk$public_methods$has_openmp()
#> [1] TRUE

# Support from an instance of that model
model <- walk$new(list(sd = 1), 0, 1)
model$has_openmp()
#> [1] TRUE