Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 6d52c6d

Browse filesBrowse files
committed
don't set tbb thread options when disabled
1 parent 3e11a1f commit 6d52c6d
Copy full SHA for 6d52c6d

File tree

1 file changed

+19
-6
lines changed
Filter options

1 file changed

+19
-6
lines changed

‎R/options.R

Copy file name to clipboardExpand all lines: R/options.R
+19-6Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11

2+
isUsingTbb <- function() {
3+
backend <- Sys.getenv("RCPP_PARALLEL_BACKEND", "tbb")
4+
identical(backend, "tbb")
5+
}
26

37
setThreadOptions <- 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

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.