Skip to content

Commit aa94ceb

Browse files
authored
Merge branch 'master' into release/5.1.10
2 parents 8ce382b + 0b136ce commit aa94ceb

File tree

808 files changed

+57923
-168586
lines changed

Some content is hidden

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

808 files changed

+57923
-168586
lines changed

.Rbuildignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@
44
^\.Rprofile$
55
^\.Rproj\.user$
66
^appveyor\.yml$
7+
^check$
78
^doc$
89
^gen$
910
^libs$
1011
^inst/lib$
1112
^inst/libs$
1213
^revdep$
1314
^src/.*\.o$
14-
^src/tbb/build/lib_.*$
15+
^src/tbb/build$
1516
^tags$
1617
^tests/testthat/pkg/RcppParallelTest/src/.*\.dll$
1718
^tests/testthat/pkg/RcppParallelTest/src/.*\.s?o$

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
.Rhistory
44
.RData
55
.DS_Store
6+
check
67
inst/doc
78
inst/lib
89
inst/libs
@@ -12,6 +13,8 @@ src-i386
1213
src-x64
1314
tbb.log
1415

16+
src/tbb/build
17+
src/tbb/build-tbb
18+
1519
R/tbb-autodetected.R
16-
src/install.libs.R
1720

DESCRIPTION

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,36 +3,37 @@ Type: Package
33
Title: Parallel Programming Tools for 'Rcpp'
44
Version: 5.1.10
55
Authors@R: c(
6+
person("Kevin", "Ushey", role = c("aut", "cre"), email = "[email protected]",
7+
comment = c(ORCID = "0000-0003-2880-7407")),
68
person("JJ", "Allaire", role = c("aut"), email = "[email protected]"),
79
person("Romain", "Francois", role = c("aut", "cph")),
8-
person("Kevin", "Ushey", role = c("aut", "cre"), email = "[email protected]"),
910
person("Gregory", "Vandenbrouck", role = "aut"),
1011
person("Marcus", "Geelnard", role = c("aut", "cph"),
1112
comment = "TinyThread library, https://tinythreadpp.bitsnbites.eu/"),
12-
person("Hamada S.", "Badr",
13-
email = "[email protected]",
14-
role = c("ctb"),
13+
person("Hamada S.", "Badr", email = "[email protected]", role = c("ctb"),
1514
comment = c(ORCID = "0000-0002-9808-2344")),
16-
person(family = "Posit, PBC", role = "cph"),
17-
person(family = "Intel", role = c("aut", "cph"),
18-
comment = "Intel TBB library, https://www.threadingbuildingblocks.org/"),
19-
person(family = "Microsoft", role = "cph")
15+
person("Dirk", "Eddelbuettel", role = c("aut"), email = "[email protected]",
16+
comment = c(ORCID = "0000-0001-6419-907X")),
17+
person(family = "Intel", role = c("aut", "cph"), comment = "oneTBB library"),
18+
person(family = "UXL Foundation", role = c("aut", "cph"), comment = "oneTBB library"),
19+
person(family = "Microsoft", role = "cph"),
20+
person(family = "Posit, PBC", role = "cph")
2021
)
2122
Description: High level functions for parallel programming with 'Rcpp'.
2223
For example, the 'parallelFor()' function can be used to convert the work of
2324
a standard serial "for" loop into a parallel one and the 'parallelReduce()'
2425
function can be used for accumulating aggregate or other values.
25-
Depends: R (>= 3.0.2)
26+
Depends: R (>= 3.6.0)
2627
Suggests:
2728
Rcpp,
2829
RUnit,
2930
knitr,
3031
rmarkdown
3132
Roxygen: list(markdown = TRUE)
32-
SystemRequirements: GNU make, Intel TBB, Windows: cmd.exe and cscript.exe, Solaris: g++ is required
33+
SystemRequirements: CMake (>= 3.5)
3334
License: GPL (>= 3)
3435
URL: https://rcppcore.github.io/RcppParallel/, https://github.com/RcppCore/RcppParallel
3536
BugReports: https://github.com/RcppCore/RcppParallel/issues
3637
Biarch: TRUE
37-
RoxygenNote: 7.1.1
38+
RoxygenNote: 7.3.2
3839
Encoding: UTF-8

NEWS.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
11

2+
## RcppParallel 6.0.0 (UNRELEASED)
3+
4+
* RcppParallel now bundles oneTBB 2022.0.0. Note that the TBB ABI has changed;
5+
packages which depend on RcppParallel may need to be rebuilt.
6+
7+
* On Windows, RcppParallel now uses the copy of TBB provided by Rtools.
8+
If TBB is not available, RcppParallel will use only the fallback 'tinythread'
9+
implementation. In practice, this implies that RcppParallel will now only
10+
provide a TBB backend with R (>= 4.2.0).
11+
212
## RcppParallel 5.1.10
313

414
* Fixed an issue where packages linking to RcppParallel could inadverently

R/aaa.R

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11

22
# stubs that get overridden via configure script
3-
TBB_LIB <- ""
4-
TBB_INC <- ""
3+
TBB_ENABLED <- TRUE
4+
TBB_LIB <- ""
5+
TBB_INC <- ""
6+
7+
TBB_NAME <- "tbb"
8+
TBB_MALLOC_NAME <- "tbbmalloc"

R/tbb-autodetected.R.in

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11

2-
TBB_LIB <- "@TBB_LIB@"
3-
TBB_INC <- "@TBB_INC@"
2+
TBB_ENABLED <- @TBB_ENABLED@
3+
TBB_LIB <- "@TBB_LIB@"
4+
TBB_INC <- "@TBB_INC@"
5+
6+
TBB_NAME <- "@TBB_NAME@"
7+
TBB_MALLOC_NAME <- "@TBB_MALLOC_NAME@"

R/tbb.R

Lines changed: 48 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -37,39 +37,54 @@ tbbLibraryPath <- function(name = NULL) {
3737
# find the request library (if any)
3838
libNames <- tbbLibNames[[sysname]]
3939
for (libName in libNames) {
40+
4041
tbbName <- file.path(tbbRoot, libName)
4142
if (file.exists(tbbName))
4243
return(tbbName)
44+
45+
arch <- if (nzchar(.Platform$r_arch)) .Platform$r_arch
46+
suffix <- paste(c("lib", arch, libName), collapse = "/")
47+
tbbName <- system.file(suffix, package = "RcppParallel")
48+
if (file.exists(tbbName))
49+
return(tbbName)
50+
4351
}
4452

4553
}
4654

4755
tbbCxxFlags <- function() {
4856

49-
flags <- character()
50-
51-
# opt-in to TBB on Windows
52-
if (is_windows()) {
53-
flags <- c(flags, "-DRCPP_PARALLEL_USE_TBB=1")
57+
if (!TBB_ENABLED)
58+
return("-DRCPP_PARALLEL_USE_TBB=0")
59+
60+
flags <- c("-DRCPP_PARALLEL_USE_TBB=1")
61+
62+
# TBB does not have assembly code for Windows ARM64
63+
# so we need to use compiler builtins
64+
if (TBB_ENABLED && is_windows()) {
5465
if (R.version$arch == "aarch64") {
55-
# TBB does not have assembly code for Windows ARM64
56-
# so we need to use compiler builtins
5766
flags <- c(flags, "-DTBB_USE_GCC_BUILTINS")
5867
}
5968
}
6069

6170
# if TBB_INC is set, apply those library paths
6271
tbbInc <- Sys.getenv("TBB_INC", unset = TBB_INC)
63-
if (nzchar(tbbInc)) {
64-
65-
# add include path
66-
flags <- c(flags, paste0("-I", asBuildPath(tbbInc)))
67-
68-
# prefer new interface if version.h exists
72+
if (!file.exists(tbbInc)) {
73+
tbbInc <- system.file("include", package = "RcppParallel")
74+
}
75+
76+
# add include path
77+
if (nzchar(tbbInc) && file.exists(tbbInc)) {
78+
79+
# prefer new interface if version.h exists -- we keep this
80+
# for compatibility with packages like StanHeaders, rstan
6981
versionPath <- file.path(tbbInc, "tbb/version.h")
7082
if (file.exists(versionPath))
7183
flags <- c(flags, "-DTBB_INTERFACE_NEW")
72-
84+
85+
# now add the include path
86+
flags <- c(flags, paste0("-I", asBuildPath(tbbInc)))
87+
7388
}
7489

7590
# return flags as string
@@ -79,41 +94,31 @@ tbbCxxFlags <- function() {
7994

8095
# Return the linker flags required for TBB on this platform
8196
tbbLdFlags <- function() {
82-
83-
tbbFlags <- tbbLdFlagsImpl()
84-
97+
98+
# on Windows, we statically link to oneTBB
8599
if (is_windows()) {
86-
libDir <- system.file("libs", .Platform$r_arch, package = "RcppParallel")
87-
libName <- paste0("RcppParallel", .Platform$dynlib.ext)
88-
newFlags <- sprintf("-L%s -lRcppParallel", shQuote(libDir))
89-
tbbFlags <- paste(newFlags, tbbFlags)
100+
101+
libPath <- system.file("libs", package = "RcppParallel")
102+
if (nzchar(.Platform$r_arch))
103+
libPath <- file.path(libPath, .Platform$r_arch)
104+
105+
ldFlags <- sprintf("-L%s -lRcppParallel", asBuildPath(libPath))
106+
return(ldFlags)
107+
90108
}
91-
92-
tbbFlags
93-
94-
}
95-
96-
tbbLdFlagsImpl <- function() {
97-
109+
98110
# shortcut if TBB_LIB defined
99111
tbbLib <- Sys.getenv("TBB_LINK_LIB", Sys.getenv("TBB_LIB", unset = TBB_LIB))
100112
if (nzchar(tbbLib)) {
101-
102-
fmt <- if (is_windows()) {
103-
"-L%1$s -ltbb -ltbbmalloc"
104-
} else {
105-
"-L%1$s -Wl,-rpath,%1$s -ltbb -ltbbmalloc"
106-
}
107-
108-
return(sprintf(fmt, asBuildPath(tbbLib)))
113+
fmt <- "-L%1$s -Wl,-rpath,%1$s -l%2$s -l%3$s"
114+
return(sprintf(fmt, asBuildPath(tbbLib), TBB_NAME, TBB_MALLOC_NAME))
109115
}
110-
111-
# on Mac, Windows and Solaris, we need to explicitly link (#206)
112-
needsExplicitFlags <- is_mac() || is_windows() || (is_solaris() && !is_sparc())
113-
if (needsExplicitFlags) {
114-
libPath <- asBuildPath(tbbLibraryPath())
115-
libFlag <- paste0("-L", libPath)
116-
return(paste(libFlag, "-ltbb", "-ltbbmalloc"))
116+
117+
# explicitly link on macOS
118+
# https://github.com/RcppCore/RcppParallel/issues/206
119+
if (is_mac()) {
120+
fmt <- "-L%s -l%s -l%s"
121+
return(sprintf(fmt, asBuildPath(tbbLibraryPath()), TBB_NAME, TBB_MALLOC_NAME))
117122
}
118123

119124
# nothing required on other platforms

R/zzz.R

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ loadTbbLibrary <- function(name) {
2727

2828
.onLoad <- function(libname, pkgname) {
2929

30+
# on Windows, load RcppParallel first
31+
if (.Platform$OS.type == "windows") {
32+
.dllInfo <<- library.dynam("RcppParallel", pkgname, libname)
33+
}
34+
3035
# load tbb, tbbmalloc
3136
.tbbDllInfo <<- loadTbbLibrary("tbb")
3237
.tbbMallocDllInfo <<- loadTbbLibrary("tbbmalloc")
@@ -37,7 +42,9 @@ loadTbbLibrary <- function(name) {
3742
.tbbMallocProxyDllInfo <<- loadTbbLibrary("tbbmalloc_proxy")
3843

3944
# load RcppParallel library if available
40-
.dllInfo <<- library.dynam("RcppParallel", pkgname, libname, local = FALSE)
45+
if (.Platform$OS.type != "windows") {
46+
.dllInfo <<- library.dynam("RcppParallel", pkgname, libname, local = FALSE)
47+
}
4148

4249
}
4350

RcppParallel.Rproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Version: 1.0
2-
ProjectId: f1ae2e5b-eb1d-4d93-9ae1-29e364a5eaa6
2+
ProjectId: 8e3d73b0-404c-42f5-b2ef-46f759f65dd4
33

44
RestoreWorkspace: No
55
SaveWorkspace: No

inst/include/RcppParallel.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,13 @@
1818
#endif
1919

2020
#if RCPP_PARALLEL_USE_TBB
21-
#if defined(WINNT) && defined(__aarch64__) && !defined(TBB_USE_GCC_BUILTINS)
22-
#define TBB_USE_GCC_BUILTINS 1
23-
#endif
21+
# if defined(WINNT) && defined(__aarch64__) && !defined(TBB_USE_GCC_BUILTINS)
22+
# define TBB_USE_GCC_BUILTINS 1
23+
# endif
2424
# include "RcppParallel/TBB.h"
2525
#endif
2626

2727
#include "RcppParallel/Backend.h"
28-
2928
#include "RcppParallel/RVector.h"
3029
#include "RcppParallel/RMatrix.h"
3130

inst/include/RcppParallel/Common.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@ inline int resolveValue(const char* envvar,
1313
U defaultValue)
1414
{
1515
// if the requested value is non-zero and not the default, we can use it
16-
if (requestedValue != static_cast<T>(defaultValue) && requestedValue > 0)
16+
bool useRequestedValue =
17+
requestedValue != static_cast<T>(defaultValue) &&
18+
requestedValue > 0;
19+
20+
if (useRequestedValue)
1721
return requestedValue;
1822

1923
// otherwise, try reading the default from associated envvar

inst/include/RcppParallel/TBB.h

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,37 @@
1010
#include <tbb/tbb.h>
1111
#include <tbb/global_control.h>
1212
#include <tbb/scalable_allocator.h>
13+
#include <tbb/task_arena.h>
14+
15+
// For compatibility with older R packages.
16+
namespace tbb {
17+
18+
#ifndef __TBB_task_scheduler_init_H
19+
#define __TBB_task_scheduler_init_H
20+
21+
class task_scheduler_init {
22+
23+
public:
24+
task_scheduler_init(
25+
int number_of_threads = -1,
26+
std::size_t stack_size = 0)
27+
{
28+
}
29+
30+
static int default_num_threads()
31+
{
32+
return tbb::this_task_arena::max_concurrency();
33+
}
34+
35+
static const int automatic = -1;
36+
static const int deferred = -2;
37+
38+
};
39+
40+
#endif
41+
42+
} // end namespace tbb
43+
1344

1445
namespace RcppParallel {
1546

0 commit comments

Comments
 (0)