Learn R Programming

SLmetrics (version 0.3-4)

OpenMP: Control OpenMP

Description

Enable or disable OpenMP parallelization for computations.

Disclaimer

This toggle is a brute-force implementation and does not guard against data races or nested parallel regions. Nested OpenMP regions can introduce subtle race conditions if multiple layers of parallelism access shared data concurrently. If you combine this package’s OpenMP switch with other parallel machine-learning routines, you may encounter undefined behavior.

Usage

## enable OpenMP
openmp.on()

## disable OpenMP openmp.off()

## set number of threads openmp.threads(threads)

Value

If OpenMP is unavailable, the function returns NULL.

Arguments

threads

A positive <integer>-value (Default: None). If threads is missing, the openmp.threads() returns the number of available threads. If NULL all available threads will be used.

Examples

Run this code
if (FALSE) {
## enable OpenMP
SLmetrics::openmp.on()

## disable OpenMP
SLmetrics::openmp.off()

## available threads
SLmetrics::openmp.threads()

## set number of threads
SLmetrics::openmp.threads(2)
}


Run the code above in your browser using DataLab