Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

setThreadOptions

Thread options for RcppParallel


Description

Set thread options (number of threads to use for task scheduling and stack size per-thread) for RcppParallel.

Usage

setThreadOptions(numThreads = "auto", stackSize = "auto")

defaultNumThreads()

Arguments

numThreads

Number of threads to use for task scheduling. Call defaultNumThreads() to determine the the default value used for "auto".

stackSize

Stack size (in bytes) to use for worker threads. The default used for "auto" is 2MB on 32-bit systems and 4MB on 64-bit systems (note that this parameter has no effect on Windows).

Details

RcppParallel is automatically initialized with the default number of threads and thread stack size when it loads. You can call setThreadOptions() at any time to change the defaults.

The parallelFor() and parallelReduce() also accept numThreads as an argument, if you'd like to control the number of threads specifically to be made available for a particular parallel function call. Note that this value is advisory, and TBB may choose a smaller number of threads if the number of requested threads cannot be honored on the system.

Value

defaultNumThreads() returns the default number of threads used by RcppParallel, if another value isn't specified either via setThreadOptions() or explicitly in calls to parallelFor() and parallelReduce().

Examples

## Not run: 
library(RcppParallel)
setThreadOptions(numThreads = 4)
defaultNumThreads()

## End(Not run)

RcppParallel

Parallel Programming Tools for 'Rcpp'

v5.1.4
GPL (>= 2)
Authors
JJ Allaire [aut], Romain Francois [aut, cph], Kevin Ushey [aut, cre], Gregory Vandenbrouck [aut], Marcus Geelnard [aut, cph] (TinyThread library, https://tinythreadpp.bitsnbites.eu/), Hamada S. Badr [ctb] (<https://orcid.org/0000-0002-9808-2344>), RStudio [cph], Intel [aut, cph] (Intel TBB library, https://www.threadingbuildingblocks.org/), Microsoft [cph]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.