Skip to content

Commit

Permalink
fix typo; ensure we set TBB_INTERFACE_NEW
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinushey committed Jan 15, 2025
1 parent fd8f510 commit f2f9dc1
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions R/tbb.R
Original file line number Diff line number Diff line change
Expand Up @@ -46,35 +46,37 @@ tbbLibraryPath <- function(name = NULL) {

tbbCxxFlags <- function() {

flags <- character()
if (!TBB_ENABLED)
return("-DRCPP_PARALLEL_USE_TBB=0")

# opt-in to TBB on Windows
if (is_windows()) {
enabled <- if (TBB_ENABLED) "1" else "0"
flags <- c(flags, sprintf("-DRCPP_PARALLEL_USE_TBB=%s", enabled))
flags <- c("-DRCPP_PARALLEL_USE_TBB=1")

# TBB does not have assembly code for Windows ARM64
# so we need to use compiler builtins
if (TBB_ENABLED && is_windows()) {
if (R.version$arch == "aarch64") {
# TBB does not have assembly code for Windows ARM64
# so we need to use compiler builtins
flags <- c(flags, "-DTBB_USE_GCC_BUILTINS")
}
}

# if TBB_INC is set, apply those library paths
tbbInc <- Sys.getenv("TBB_INC", unset = TBB_INC)
if (!file.exists(tbbInc)) {
tbbInc <- system.file("include", package = "Rcpp")
tbbInc <- system.file("include", package = "RcppParallel")
}

if (nzchar(tbbInc)) {

# add include path
flags <- c(flags, paste0("-I", asBuildPath(tbbInc)))
# add include path
if (nzchar(tbbInc) && file.exists(tbbInc)) {

# prefer new interface if version.h exists
# prefer new interface if version.h exists -- we keep this
# for compatibility with packages like StanHeaders, rstan
versionPath <- file.path(tbbInc, "tbb/version.h")
if (file.exists(versionPath))
flags <- c(flags, "-DTBB_INTERFACE_NEW")

# now add the include path
flags <- c(flags, paste0("-I", asBuildPath(tbbInc)))

}

# return flags as string
Expand Down

0 comments on commit f2f9dc1

Please sign in to comment.