From f2f9dc12d6b22746441a2a695e7dffb46ad5edf2 Mon Sep 17 00:00:00 2001 From: Kevin Ushey Date: Tue, 14 Jan 2025 20:39:38 -0800 Subject: [PATCH] fix typo; ensure we set TBB_INTERFACE_NEW --- R/tbb.R | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/R/tbb.R b/R/tbb.R index d56f8d46..7b28ea1b 100644 --- a/R/tbb.R +++ b/R/tbb.R @@ -46,15 +46,15 @@ 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") } } @@ -62,19 +62,21 @@ tbbCxxFlags <- function() { # 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