Skip to content

Commit 17481c6

Browse files
committed
enable specifying number of threads via environment variable
1 parent 57d5a6f commit 17481c6

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)