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

update to oneTBB 2022.0 #232

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
finishing up
  • Loading branch information
kevinushey committed Jan 14, 2025
commit 686f90ed194ed3eddc204f9f9e698ebe154e9219
1 change: 0 additions & 1 deletion 1 .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,4 @@ src-x64
tbb.log

R/tbb-autodetected.R
src/install.libs.R

2 changes: 1 addition & 1 deletion 2 R/tbb-autodetected.R.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

TBB_LIB <- "@TBB_LIB@"
TBB_INC <- "@TBB_INC@"
TBB_NAME <- "@TBB_NAME@"
TBB_NAME <- "@TBB_NAME@"
5 changes: 2 additions & 3 deletions 5 src/Makevars.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ PKG_CPPFLAGS = @PKG_CPPFLAGS@
PKG_CXXFLAGS = @CXX11STD@ -DRCPP_PARALLEL_USE_TBB=1
PKG_CXXFLAGS += -DTBB_SUPPRESS_DEPRECATED_MESSAGES=1

PKG_LIBS = -Wl,-L"$(TBB_LIB)" @TBB_RPATH@ -l$(TBB_NAME) -ltbbmalloc
PKG_LIBS += @PKG_LIBS_EXTRA@
PKG_LIBS = @PKG_LIBS@ @PKG_LIBS_EXTRA@

.PHONY: all tbb tbb-clean

Expand All @@ -23,7 +22,7 @@ $(OBJECTS): tbb
# NOTE: TBB libraries are installed via install.libs.R.
# However, we need to copy headers here so that they are visible during compilation.
tbb: tbb-clean
TBB_LIB="$(TBB_LIB)" TBB_INC="$(TBB_INC)" TBB_NAME="$(TBB_NAME)" @R@ -s -f install.libs.R --args build
@TBB_LIB="$(TBB_LIB)" TBB_INC="$(TBB_INC)" TBB_NAME="$(TBB_NAME)" @R@ -s -f install.libs.R --args build

# NOTE: we do not want to clean ../inst/lib or ../inst/libs here,
# as we may be writing to those locations in multiarch builds
Expand Down
110 changes: 110 additions & 0 deletions 110 src/install.libs.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@

# !diagnostics suppress=R_PACKAGE_DIR,SHLIB_EXT,R_ARCH
.install.libs <- function(tbbLib) {

# copy default library
files <- Sys.glob(paste0("*", SHLIB_EXT))
dest <- file.path(R_PACKAGE_DIR, paste0("libs", R_ARCH))
dir.create(dest, recursive = TRUE, showWarnings = FALSE)
file.copy(files, dest, overwrite = TRUE)

# copy symbols if available
if (file.exists("symbols.rds"))
file.copy("symbols.rds", dest, overwrite = TRUE)

# also copy to package 'libs' folder, for devtools
libsDest <- paste0("../libs", R_ARCH)
dir.create(libsDest, recursive = TRUE, showWarnings = FALSE)
file.copy(files, libsDest, overwrite = TRUE)

# copy tbb (NOTE: do not use inst/ folder as R will resolve symlinks,
# behavior which we do _not_ want here!)
tbbDest <- file.path(R_PACKAGE_DIR, paste0("lib", R_ARCH))
dir.create(tbbDest, recursive = TRUE, showWarnings = FALSE)

# note: on Linux, TBB gets compiled with extensions like
# '.so.2', so be ready to handle those
shlibPattern <- switch(
Sys.info()[["sysname"]],
Windows = "^tbb.*\\.dll$",
Darwin = "^libtbb.*\\.dylib$",
"^libtbb.*\\.so.*$"
)

if (!nzchar(tbbLib)) {

# using bundled TBB
tbbLibs <- list.files(
path = "tbb/build/lib_release",
pattern = shlibPattern,
full.names = TRUE
)

for (tbbLib in tbbLibs) {
system2("cp", c("-P", shQuote(tbbLib), shQuote(tbbDest)))
}

} else {

# using system tbb
tbbLibs <- list.files(
path = tbbLib,
pattern = shlibPattern,
full.names = TRUE
)

# don't copy symlinks
tbbLibs <- tbbLibs[!nzchar(Sys.readlink(tbbLibs))]

# copy / link the libraries
useSymlinks <- Sys.getenv("TBB_USE_SYMLINKS", unset = "TRUE")
if (useSymlinks) {
file.symlink(tbbLibs, tbbDest)
} else {
for (tbbLib in tbbLibs) {
system2("cp", c("-P", shQuote(tbbLib), shQuote(tbbDest)))
}
}

}

}

useTbbPreamble <- function(tbbInc) {
dir.create("../inst/include", recursive = TRUE, showWarnings = FALSE)
for (suffix in c("oneapi", "serial", "tbb")) {
tbbPath <- file.path(tbbInc, suffix)
if (file.exists(tbbPath)) {
file.copy(tbbPath, "../inst/include", recursive = TRUE)
}
}
}

useSystemTbb <- function(tbbLib, tbbInc) {
useTbbPreamble(tbbInc)
}

useBundledTbb <- function() {
useTbbPreamble("tbb/include")
dir.create("tbb/build", showWarnings = FALSE)
system("cd tbb/build; cmake -DTBB_TEST=0 -DTBB_EXAMPLES=0 .. && cmake --build .")
system("cd tbb/build; mv *_relwithdebinfo lib_release")
}


# Main ----

tbbLib <- Sys.getenv("TBB_LIB")
tbbInc <- Sys.getenv("TBB_INC")

args <- commandArgs(trailingOnly = TRUE)
if (identical(args, "build")) {
if (nzchar(tbbLib) && nzchar(tbbInc)) {
useSystemTbb(tbbLib, tbbInc)
} else {
useBundledTbb()
}
} else {
source("../R/tbb-autodetected.R")
.install.libs(tbbLib)
}
3 changes: 3 additions & 0 deletions 3 tools/config/configure.R
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,10 @@ define(

# set TBB_RPATH
if (!is.na(tbbLib)) {
define(PKG_LIBS = "-Wl,-L\"$(TBB_LIB)\" @TBB_RPATH@ -l$(TBB_NAME) -ltbbmalloc")
define(TBB_RPATH = sprintf("-Wl,-rpath,%s", shQuote(tbbLib)))
} else {
define(PKG_LIBS = "@TBB_RPATH@ -l$(TBB_NAME) -ltbbmalloc")
define(TBB_RPATH = "")
}

Expand All @@ -225,6 +227,7 @@ if (!is.na(tbbLib)) {
define(PKG_CPPFLAGS = "-I../inst/include")
}


# macOS needs some extra flags set
if (Sys.info()[["sysname"]] == "Darwin") {
define(PKG_LIBS_EXTRA = "-Ltbb/build/lib_release -ltbb -Wl,-rpath,\"@loader_path/../lib\"")
Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.