Skip to content

Commit 8e3b5d5

Browse files
committed
CRAN release 5.1.11
1 parent 0b3c250 commit 8e3b5d5

File tree

16 files changed

+531
-344
lines changed

16 files changed

+531
-344
lines changed

DESCRIPTION

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: RcppParallel
22
Type: Package
33
Title: Parallel Programming Tools for 'Rcpp'
4-
Version: 5.1.9
4+
Version: 5.1.11-1
55
Authors@R: c(
66
person("JJ", "Allaire", role = c("aut"), email = "jj@rstudio.com"),
77
person("Romain", "Francois", role = c("aut", "cph")),
@@ -23,16 +23,29 @@ Description: High level functions for parallel programming with 'Rcpp'.
2323
a standard serial "for" loop into a parallel one and the 'parallelReduce()'
2424
function can be used for accumulating aggregate or other values.
2525
Depends: R (>= 3.0.2)
26-
Suggests:
27-
Rcpp,
28-
RUnit,
29-
knitr,
30-
rmarkdown
31-
Roxygen: list(markdown = TRUE)
32-
SystemRequirements: GNU make, Intel TBB, Windows: cmd.exe and cscript.exe, Solaris: g++ is required
26+
Suggests: Rcpp, RUnit, knitr, rmarkdown
27+
SystemRequirements: GNU make, Intel TBB, Windows: cmd.exe and
28+
cscript.exe, Solaris: g++ is required
3329
License: GPL (>= 3)
34-
URL: https://rcppcore.github.io/RcppParallel/, https://github.com/RcppCore/RcppParallel
30+
URL: https://rcppcore.github.io/RcppParallel/,
31+
https://github.com/RcppCore/RcppParallel
3532
BugReports: https://github.com/RcppCore/RcppParallel/issues
3633
Biarch: TRUE
3734
RoxygenNote: 7.1.1
3835
Encoding: UTF-8
36+
NeedsCompilation: yes
37+
Packaged: 2025-01-23 23:26:25 UTC; kevin
38+
Author: JJ Allaire [aut],
39+
Romain Francois [aut, cph],
40+
Kevin Ushey [aut, cre],
41+
Gregory Vandenbrouck [aut],
42+
Marcus Geelnard [aut, cph] (TinyThread library,
43+
https://tinythreadpp.bitsnbites.eu/),
44+
Hamada S. Badr [ctb] (<https://orcid.org/0000-0002-9808-2344>),
45+
Posit, PBC [cph],
46+
Intel [aut, cph] (Intel TBB library,
47+
https://www.threadingbuildingblocks.org/),
48+
Microsoft [cph]
49+
Maintainer: Kevin Ushey <kevin@rstudio.com>
50+
Repository: CRAN
51+
Date/Publication: 2025-01-24 02:00:02 UTC

NEWS.md

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

2+
## RcppParallel 5.1.11
3+
4+
* Compatibility with LLVM 21.
5+
6+
## RcppParallel 5.1.10
7+
8+
* Fixed an issue where packages linking to RcppParallel could inadverently
9+
depend on internals of the TBB library available during compilation, even
10+
if the package did not explicitly use TBB itself.
11+
212
## RcppParallel 5.1.9
313

414
* RcppParallel no longer passes `-rpath` when building / linking on Windows.

R/flags.R

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
11

22
#' Compilation flags for RcppParallel
3-
#'
3+
#'
44
#' Output the compiler or linker flags required to build against RcppParallel.
5-
#'
5+
#'
66
#' These functions are typically called from `Makevars` as follows:
7-
#'
7+
#'
88
#' ```
99
#' PKG_LIBS += $(shell "${R_HOME}/bin/Rscript" -e "RcppParallel::LdFlags()")
1010
#' ```
11-
#'
11+
#'
1212
#' On Windows, the flags ensure that the package links with the built-in TBB
1313
#' library. On Linux and macOS, the output is empty, because TBB is loaded
1414
#' dynamically on load by `RcppParallel`.
15-
#'
15+
#'
1616
#' \R packages using RcppParallel should also add the following to their
1717
#' `NAMESPACE` file:
18-
#'
18+
#'
1919
#' ```
2020
#' importFrom(RcppParallel, RcppParallelLibs)
2121
#' ```
22-
#'
22+
#'
2323
#' This is necessary to ensure that \pkg{RcppParallel} (and so, TBB) is loaded
2424
#' and available.
25-
#'
25+
#'
2626
#' @name flags
2727
#' @rdname flags
2828
#' @aliases RcppParallelLibs LdFlags CxxFlags
29-
#'
29+
#'
3030
#' @return Returns \code{NULL}, invisibly. These functions are called for
3131
#' their side effects (writing the associated flags to stdout).
3232
#'

R/tbb.R

Lines changed: 46 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,53 @@
11

22
#' Get the Path to a TBB Library
3-
#'
3+
#'
44
#' Retrieve the path to a TBB library. This can be useful for \R packages
55
#' using RcppParallel that wish to use, or re-use, the version of TBB that
66
#' RcppParallel has been configured to use.
7-
#'
7+
#'
88
#' @param name
99
#' The name of the TBB library to be resolved. Normally, this is one of
1010
#' `tbb`, `tbbmalloc`, or `tbbmalloc_proxy`. When `NULL`, the library
1111
#' path containing the TBB libraries is returned instead.
12-
#'
12+
#'
1313
#' @export
1414
tbbLibraryPath <- function(name = NULL) {
15-
15+
1616
# library paths for different OSes
1717
sysname <- Sys.info()[["sysname"]]
18-
18+
1919
# find root for TBB install
2020
tbbRoot <- Sys.getenv("TBB_LIB", unset = tbbRoot())
2121
if (is.null(name))
2222
return(tbbRoot)
23-
23+
2424
# form library names
2525
tbbLibNames <- list(
2626
"Darwin" = paste0("lib", name, ".dylib"),
2727
"Windows" = paste0( name, ".dll"),
2828
"SunOS" = paste0("lib", name, ".so"),
2929
"Linux" = paste0("lib", name, c(".so.2", ".so"))
3030
)
31-
31+
3232
# skip systems that we know not to be compatible
3333
isCompatible <- !is_sparc() && !is.null(tbbLibNames[[sysname]])
3434
if (!isCompatible)
3535
return(NULL)
36-
36+
3737
# find the request library (if any)
3838
libNames <- tbbLibNames[[sysname]]
3939
for (libName in libNames) {
4040
tbbName <- file.path(tbbRoot, libName)
4141
if (file.exists(tbbName))
4242
return(tbbName)
4343
}
44-
44+
4545
}
4646

4747
tbbCxxFlags <- function() {
48-
48+
4949
flags <- character()
50-
50+
5151
# opt-in to TBB on Windows
5252
if (is_windows()) {
5353
flags <- c(flags, "-DRCPP_PARALLEL_USE_TBB=1")
@@ -57,58 +57,78 @@ tbbCxxFlags <- function() {
5757
flags <- c(flags, "-DTBB_USE_GCC_BUILTINS")
5858
}
5959
}
60-
60+
6161
# if TBB_INC is set, apply those library paths
6262
tbbInc <- Sys.getenv("TBB_INC", unset = TBB_INC)
6363
if (nzchar(tbbInc)) {
64-
64+
6565
# add include path
6666
flags <- c(flags, paste0("-I", asBuildPath(tbbInc)))
67-
67+
6868
# prefer new interface if version.h exists
6969
versionPath <- file.path(tbbInc, "tbb/version.h")
7070
if (file.exists(versionPath))
7171
flags <- c(flags, "-DTBB_INTERFACE_NEW")
72-
72+
7373
}
74-
74+
7575
# return flags as string
7676
paste(flags, collapse = " ")
77-
77+
7878
}
7979

8080
# Return the linker flags required for TBB on this platform
8181
tbbLdFlags <- function() {
82-
82+
83+
tbbFlags <- tbbLdFlagsImpl()
84+
85+
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)
90+
}
91+
92+
tbbFlags
93+
94+
}
95+
96+
tbbLdFlagsImpl <- function() {
97+
8398
# shortcut if TBB_LIB defined
8499
tbbLib <- Sys.getenv("TBB_LINK_LIB", Sys.getenv("TBB_LIB", unset = TBB_LIB))
85100
if (nzchar(tbbLib)) {
86-
fmt <- if (is_windows()) "-L%1$s -ltbb -ltbbmalloc"
87-
else "-L%1$s -Wl,-rpath,%1$s -ltbb -ltbbmalloc"
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+
88108
return(sprintf(fmt, asBuildPath(tbbLib)))
89109
}
90-
110+
91111
# on Mac, Windows and Solaris, we need to explicitly link (#206)
92112
needsExplicitFlags <- is_mac() || is_windows() || (is_solaris() && !is_sparc())
93113
if (needsExplicitFlags) {
94114
libPath <- asBuildPath(tbbLibraryPath())
95115
libFlag <- paste0("-L", libPath)
96116
return(paste(libFlag, "-ltbb", "-ltbbmalloc"))
97117
}
98-
118+
99119
# nothing required on other platforms
100120
""
101-
121+
102122
}
103123

104124
tbbRoot <- function() {
105-
125+
106126
if (nzchar(TBB_LIB))
107127
return(TBB_LIB)
108-
128+
109129
rArch <- .Platform$r_arch
110130
parts <- c("lib", if (nzchar(rArch)) rArch)
111131
libDir <- paste(parts, collapse = "/")
112132
system.file(libDir, package = "RcppParallel")
113-
133+
114134
}

R/zzz.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ loadTbbLibrary <- function(name) {
3737
.tbbMallocProxyDllInfo <<- loadTbbLibrary("tbbmalloc_proxy")
3838

3939
# load RcppParallel library if available
40-
.dllInfo <<- library.dynam("RcppParallel", pkgname, libname)
40+
.dllInfo <<- library.dynam("RcppParallel", pkgname, libname, local = FALSE)
4141

4242
}
4343

inst/include/RcppParallel.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include "RcppParallel/TinyThread.h"
77

88
// Use TBB only where it's known to compile and work correctly
9-
// (NOTE: Windows TBB is temporarily opt-in for packages for
9+
// (NOTE: Windows TBB is temporarily opt-in for packages for
1010
// compatibility with CRAN packages not previously configured
1111
// to link to TBB in Makevars.win)
1212
#ifndef RCPP_PARALLEL_USE_TBB
@@ -32,14 +32,14 @@
3232
namespace RcppParallel {
3333

3434
inline void parallelFor(std::size_t begin,
35-
std::size_t end,
35+
std::size_t end,
3636
Worker& worker,
3737
std::size_t grainSize = 1,
3838
int numThreads = -1)
3939
{
40-
grainSize = resolveValue("RCPP_PARALLEL_GRAIN_SIZE", grainSize, 1u);
40+
grainSize = resolveValue("RCPP_PARALLEL_GRAIN_SIZE", grainSize, std::size_t(1));
4141
numThreads = resolveValue("RCPP_PARALLEL_NUM_THREADS", numThreads, -1);
42-
42+
4343
#if RCPP_PARALLEL_USE_TBB
4444
if (internal::backend() == internal::BACKEND_TBB)
4545
tbbParallelFor(begin, end, worker, grainSize, numThreads);
@@ -52,14 +52,14 @@ inline void parallelFor(std::size_t begin,
5252

5353
template <typename Reducer>
5454
inline void parallelReduce(std::size_t begin,
55-
std::size_t end,
55+
std::size_t end,
5656
Reducer& reducer,
5757
std::size_t grainSize = 1,
5858
int numThreads = -1)
5959
{
60-
grainSize = resolveValue("RCPP_PARALLEL_GRAIN_SIZE", grainSize, 1);
60+
grainSize = resolveValue("RCPP_PARALLEL_GRAIN_SIZE", grainSize, std::size_t(1));
6161
numThreads = resolveValue("RCPP_PARALLEL_NUM_THREADS", numThreads, -1);
62-
62+
6363
#if RCPP_PARALLEL_USE_TBB
6464
if (internal::backend() == internal::BACKEND_TBB)
6565
tbbParallelReduce(begin, end, reducer, grainSize, numThreads);

0 commit comments

Comments
 (0)