Skip to content

Commit 3bf1b0d

Browse files
authored
Merge pull request #39 from RcppCore/feature/num-threads-environment-var
enable specifying number of threads via environment variable
2 parents 57d5a6f + 17481c6 commit 3bf1b0d

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

R/hooks.R

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,12 @@ mallocDllInfo <- NULL
2626
library.dynam("RcppParallel", pkgname, libname)
2727

2828
# set default thread options
29-
setThreadOptions()
29+
numThreads <- "auto"
30+
numThreadsEnv <- Sys.getenv("RCPP_PARALLEL_NUM_THREADS", unset = NA)
31+
if (!is.na(numThreadsEnv))
32+
setThreadOptions(numThreads = as.integer(numThreadsEnv))
33+
else
34+
setThreadOptions(numThreads = "auto")
3035
}
3136

3237
.onUnload <- function(libpath) {

0 commit comments

Comments
 (0)