Skip to content

Commit 39303ec

Browse files
authored
Merge pull request #141 from hsbadr/develop
Update TBB interface and allow using external lib
2 parents c9af2a2 + 06c99a9 commit 39303ec

File tree

117 files changed

+90
-21
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

117 files changed

+90
-21
lines changed

DESCRIPTION

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
Package: RcppParallel
22
Type: Package
33
Title: Parallel Programming Tools for 'Rcpp'
4-
Version: 5.0.2-9000
4+
Version: 5.1.0-9000
55
Authors@R: c(
66
person("JJ", "Allaire", role = c("aut"), email = "jj@rstudio.com"),
77
person("Romain", "Francois", role = c("aut", "cph")),
88
person("Kevin", "Ushey", role = c("aut", "cre"), email = "kevin@rstudio.com"),
99
person("Gregory", "Vandenbrouck", role = "aut"),
1010
person("Marcus", "Geelnard", role = c("aut", "cph"),
11-
comment = "TinyThread library, http://tinythreadpp.bitsnbites.eu/"),
11+
comment = "TinyThread library, https://tinythreadpp.bitsnbites.eu/"),
12+
person("Hamada S.", "Badr",
13+
email = "badr@jhu.edu",
14+
role = c("ctb"),
15+
comment = c(ORCID = "0000-0002-9808-2344")),
1216
person(family = "RStudio", role = "cph"),
1317
person(family = "Intel", role = c("aut", "cph"),
1418
comment = "Intel TBB library, https://www.threadingbuildingblocks.org/"),
@@ -24,12 +28,12 @@ Suggests:
2428
RUnit,
2529
knitr,
2630
rmarkdown
27-
SystemRequirements: GNU make, Windows: cmd.exe and cscript.exe, Solaris: g++ is required
31+
SystemRequirements: GNU make, Intel TBB, Windows: cmd.exe and cscript.exe, Solaris: g++ is required
2832
License: GPL (>= 2)
29-
URL: http://rcppcore.github.io/RcppParallel, https://github.com/RcppCore/RcppParallel
33+
URL: https://rcppcore.github.io/RcppParallel/, https://github.com/RcppCore/RcppParallel
3034
BugReports: https://github.com/RcppCore/RcppParallel/issues
3135
Biarch: TRUE
32-
Collate:
36+
Collate:
3337
'build.R'
3438
'hooks.R'
3539
'options.R'

R/build.R

Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,23 @@ inlineCxxPlugin <- function() {
4141
}
4242

4343
tbbCxxFlags <- function() {
44-
44+
4545
flags <- c()
46-
46+
4747
# opt-in to TBB on Windows
4848
if (Sys.info()['sysname'] == "Windows")
4949
flags <- paste(flags, "-DRCPP_PARALLEL_USE_TBB=1")
50-
50+
51+
if (dir.exists(Sys.getenv("TBB_INC"))) {
52+
TBB_INC <- asBuildPath(Sys.getenv("TBB_INC"))
53+
54+
if (file.exists(file.path(TBB_INC, "tbb", "version.h"))) {
55+
flags <- paste0("-I", shQuote(TBB_INC), " -DTBB_INTERFACE_NEW")
56+
} else {
57+
flags <- paste0("-I", shQuote(TBB_INC))
58+
}
59+
}
60+
5161
flags
5262
}
5363

@@ -57,6 +67,9 @@ tbbLdFlags <- function() {
5767
if ((Sys.info()['sysname'] %in% c("Windows", "SunOS")) && !isSparc()) {
5868
tbb <- tbbLibPath()
5969
paste("-L", asBuildPath(dirname(tbb)), " -ltbb -ltbbmalloc", sep = "")
70+
} else if (dir.exists(Sys.getenv("TBB_LIB"))) {
71+
TBB_LIB <- asBuildPath(Sys.getenv("TBB_LIB"))
72+
paste0("-L", shQuote(TBB_LIB), " -Wl,-rpath,", TBB_LIB, " -ltbb -ltbbmalloc")
6073
} else {
6174
""
6275
}
@@ -66,19 +79,32 @@ tbbLdFlags <- function() {
6679
tbbLibPath <- function(suffix = "") {
6780
sysname <- Sys.info()['sysname']
6881
tbbSupported <- list(
69-
"Darwin" = paste("libtbb", suffix, ".dylib", sep = ""),
70-
"Linux" = paste("libtbb", suffix, ".so.2", sep = ""),
82+
"Darwin" = paste("libtbb", suffix, ".dylib", sep = ""),
83+
"Linux" = paste("libtbb", suffix, ".so.2", sep = ""),
7184
"Windows" = paste("tbb", suffix, ".dll", sep = ""),
7285
"SunOS" = paste("libtbb", suffix, ".so", sep = "")
7386
)
74-
if ((sysname %in% names(tbbSupported)) && !isSparc()) {
75-
libDir <- "lib/"
76-
if (sysname == "Windows")
77-
libDir <- paste(libDir, .Platform$r_arch, "/", sep="")
78-
system.file(paste(libDir, tbbSupported[[sysname]], sep = ""),
79-
package = "RcppParallel")
87+
88+
if (dir.exists(Sys.getenv("TBB_LIB"))) {
89+
TBB_LIB <- asBuildPath(Sys.getenv("TBB_LIB"))
90+
asBuildPath(file.path(TBB_LIB, paste("libtbb", suffix, ".so", sep = "")))
8091
} else {
81-
NULL
92+
if ((sysname %in% names(tbbSupported)) && !isSparc()) {
93+
libDir <- "lib/"
94+
if (sysname == "Windows")
95+
libDir <- paste(libDir, .Platform$r_arch, "/", sep="")
96+
97+
tbb_path <- system.file(paste(libDir, tbbSupported[[sysname]], sep = ""),
98+
package = "RcppParallel")
99+
if (sysname == "Linux" && !file.exists(tbb_path)) {
100+
system.file(paste(libDir, "libtbb", suffix, ".so", sep =""),
101+
package = "RcppParallel")
102+
} else {
103+
tbb_path
104+
}
105+
} else {
106+
NULL
107+
}
82108
}
83109
}
84110

inst/NEWS

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
1-
RcppParallel 5.0.3 (UNRELEASED)
1+
RcppParallel 5.1.0 (UNRELEASED)
22
------------------------------------------------------------------------
33

4+
* Added support for external TBB library via TBB_INC and/or TBB_LIB environment variables.
5+
* Updated TBB functionality for the new interface.
6+
* Falling back to building TBB from local source code.
7+
* Backward TBB compatibility based on `__TBB_tbb_stddef_H`.
8+
* Resolved conflicts between system and local TBB headers.
9+
* Fixed URLs, used HTTPS, and minor cleanups.
10+
* Updated package DESCRIPTION and bumped version.
411
* setThreadOptions(...) can again be called multiple times per session.
512
The requested number of threads will be used for invocations to parallelFor()
613
and parallelReduce() that don't explicitly request a specific number of threads.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)