imager (version 0.45.8)

cimg.openmp: Control CImg's parallelisation

Description

On supported architectures CImg can parallelise many operations using OpenMP (e.g. imager.combine). Use this function to turn parallelisation on or off.

Usage

cimg.use.openmp(mode = "adaptive", nthreads = 1, verbose = FALSE)

cimg.limit.openmp()

Value

NULL (function is used for side effects)

Arguments

mode

Either "adaptive","always" or "none". The default is adaptive (parallelisation for large images only).

nthreads

The number of OpenMP threads that imager should use. The default is 1. Set to 0 to get no more than 2, based on OpenMP environment variables.

verbose

Whether to output information about the threads being set.

Functions

  • cimg.limit.openmp(): Limit OpenMP thread count to no more than 2, based on OpenMP environment variables.

Author

Simon Barthelme

Details

You need to be careful that nthreads is not higher than the value in the system environment variable OMP_THREAD_LIMIT (this can be checked with Sys.getenv('OMP_THREAD_LIMIT')). The OMP_THREAD_LIMIT thread limit usually needs to be correctly set before launching R, so using Sys.setenv once a session has started is not certain to work.

Examples

Run this code
cimg.limit.openmp()
cimg.use.openmp("never") #turn off parallelisation

Run the code above in your browser using DataLab