File tree 1 file changed +19
-6
lines changed
Filter options
1 file changed +19
-6
lines changed
Original file line number Diff line number Diff line change 1
1
2
+ isUsingTbb <- function () {
3
+ backend <- Sys.getenv(" RCPP_PARALLEL_BACKEND" , " tbb" )
4
+ identical(backend , " tbb" )
5
+ }
2
6
3
7
setThreadOptions <- function (numThreads = " auto" , stackSize = " auto" ) {
4
8
@@ -19,18 +23,27 @@ setThreadOptions <- function(numThreads = "auto", stackSize = "auto") {
19
23
stackSize <- as.integer(stackSize )
20
24
21
25
# 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 )
26
28
27
29
if (numThreads == - 1L )
28
30
Sys.unsetenv(" RCPP_PARALLEL_NUM_THREADS" )
29
31
else
30
32
Sys.setenv(RCPP_PARALLEL_NUM_THREADS = numThreads )
31
33
}
32
34
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
+ )
35
42
}
36
43
44
+ defaultNumThreads <- function () {
45
+ .Call(
46
+ " defaultNumThreads" ,
47
+ PACKAGE = " RcppParallel"
48
+ )
49
+ }
You can’t perform that action at this time.
0 commit comments