11
2+ isUsingTbb <- function () {
3+ backend <- Sys.getenv(" RCPP_PARALLEL_BACKEND" , " tbb" )
4+ identical(backend , " tbb" )
5+ }
26
37setThreadOptions <- function (numThreads = " auto" , stackSize = " auto" ) {
48
@@ -19,18 +23,27 @@ setThreadOptions <- function(numThreads = "auto", stackSize = "auto") {
1923 stackSize <- as.integer(stackSize )
2024
2125 # Call setThreadOptions if using tbb
22- if (! is.null(dllInfo )) {
23- invisible (.Call(" setThreadOptions" , numThreads , stackSize ,
24- PACKAGE = " RcppParallel" ))
25- }
26+ if (! is.null(dllInfo ) && isUsingTbb())
27+ setTbbThreadOptions(numThreads , stackSize )
2628
2729 if (numThreads == - 1L )
2830 Sys.unsetenv(" RCPP_PARALLEL_NUM_THREADS" )
2931 else
3032 Sys.setenv(RCPP_PARALLEL_NUM_THREADS = numThreads )
3133}
3234
33- defaultNumThreads <- function () {
34- .Call(" defaultNumThreads" , PACKAGE = " RcppParallel" )
35+ setTbbThreadOptions <- function (numThreads , stackSize ) {
36+ .Call(
37+ " setThreadOptions" ,
38+ as.integer(numThreads ),
39+ as.integer(stackSize ),
40+ PACKAGE = " RcppParallel"
41+ )
3542}
3643
44+ defaultNumThreads <- function () {
45+ .Call(
46+ " defaultNumThreads" ,
47+ PACKAGE = " RcppParallel"
48+ )
49+ }
0 commit comments