Skip to content

Commit cf86415

Browse files
committed
add tbbLibPath; update NEWS
1 parent b9068f2 commit cf86415

File tree

10 files changed

+222
-166
lines changed

10 files changed

+222
-166
lines changed

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ export(RcppParallel.package.skeleton)
66
export(RcppParallelLibs)
77
export(defaultNumThreads)
88
export(setThreadOptions)
9+
export(tbbLibPath)

inst/NEWS renamed to NEWS.md

Lines changed: 61 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,114 +1,135 @@
1-
RcppParallel 5.1.1
2-
------------------------------------------------------------------------
1+
## RcppParallel 5.1.2 (UNRELEASED)
32

4-
* Updated bundled version of TBB (Intel TBB 2019 Update 8)
5-
* Added support for external TBB library using TBB_INC and TBB_LIB environment variables.
3+
* `RcppParallel` gains the `tbbLibPath()` function, to be used when attempting
4+
to query the location of the TBB libraries that `RcppParallel` has been
5+
configured to use. This may be useful for R packages which wish to explicitly
6+
use, or link to, these libraries.
7+
8+
## RcppParallel 5.1.1
9+
10+
* Updated bundled version of TBB (Intel TBB 2019 Update 8).
11+
12+
* RcppParallel can now be configured to use an external copy of TBB, via the
13+
`TBB_LIB` and `TBB_INC` environment variables. These should be set to the
14+
directories containing the TBB libraries and headers, respectively.
15+
616
* Added support for the latest versions of Intel oneAPI TBB / oneTBB.
17+
718
* Updated TBB functionality for the new interface.
19+
820
* Falling back to building TBB from local source code.
21+
922
* Backward TBB compatibility based on `__TBB_tbb_stddef_H`.
23+
1024
* Resolved conflicts between system and local TBB headers.
25+
1126
* Fixed URLs, used HTTPS, and minor cleanups.
27+
1228
* Updated package DESCRIPTION and bumped version.
13-
* setThreadOptions(...) can again be called multiple times per session.
14-
The requested number of threads will be used for invocations to parallelFor()
15-
and parallelReduce() that don't explicitly request a specific number of threads.
16-
* The parallelFor() and parallelReduce() functions gain the 'numThreads'
29+
30+
* `setThreadOptions(...)` can again be called multiple times per session.
31+
The requested number of threads will be used for invocations to `parallelFor()`
32+
and `parallelReduce()` that don't explicitly request a specific number of threads.
33+
34+
* The `parallelFor()` and `parallelReduce()` functions gain the `numThreads`
1735
argument, allowing one to limit the number of threads used for a
1836
particular computation.
1937

20-
RcppParallel 5.0.3
21-
------------------------------------------------------------------------
38+
## RcppParallel 5.0.3
39+
2240
* Fixed compilation on macOS M1 machines.
2341

24-
RcppParallel 5.0.2
25-
------------------------------------------------------------------------
42+
## RcppParallel 5.0.2
2643

27-
* setThreadOptions(...) can now only be called once per session, to avoid
44+
* `setThreadOptions(...)` can now only be called once per session, to avoid
2845
segfaults when compiling RcppParallel / TBB with gcc 10.1. Subsequent
29-
calls to setThreadOptions(...) are ignored.
46+
calls to `setThreadOptions(...)` are ignored.
3047

31-
RcppParallel 5.0.1
32-
------------------------------------------------------------------------
48+
## RcppParallel 5.0.1
3349

3450
* Fixed compilation issue on OpenSUSE Tumbleweed with -flto=auto
51+
3552
* Fixed compilation when CPPFLAGS = -I/usr/local/include and a version
3653
of libtbb is installed there
3754

38-
RcppParallel 5.0.0
39-
------------------------------------------------------------------------
55+
## RcppParallel 5.0.0
4056

4157
* RcppParallel backend can now be customized with RCPP_PARALLEL_BACKEND
4258
environment variable (supported values are 'tbb' and 'tinythread')
59+
4360
* Fixed issue when compiling RcppParallel on macOS Catalina
61+
4462
* Fixed issue when compiling RcppParallel with Rtools40
4563

46-
RcppParallel 4.4.4
47-
------------------------------------------------------------------------
64+
## RcppParallel 4.4.4
4865

4966
* Fixed an issue when compiling RcppParallel with clang-9 on Fedora
5067

51-
RcppParallel 4.4.3
52-
------------------------------------------------------------------------
68+
## RcppParallel 4.4.3
5369

5470
* Suppress gcc-9 warnings related -Wclass-memaccess
71+
5572
* Added TBB headers for serial TBB operations (#90, @mikejiang)
73+
5674
* Fixed row iterator constructor (#87, @wtianyi)
75+
5776
* Fixed compilation on FreeBSD
5877

59-
RcppParallel 4.4.2
60-
------------------------------------------------------------------------
78+
## RcppParallel 4.4.2
6179

6280
* Suppress gcc-8 warnings related to -Wclass-memaccess
81+
6382
* Use PKG_CXXFLAGS rather than PKG_CPPFLAGS
83+
6484
* Remove unused dependency on the BH package
6585

66-
RcppParallel 4.4.1
67-
------------------------------------------------------------------------
86+
## RcppParallel 4.4.1
6887

6988
* Ensure user-specified R configuration passed to TBB
89+
7090
* Work around warnings emitted by gcc 8
7191

72-
RcppParallel 4.4.0
73-
------------------------------------------------------------------------
92+
## RcppParallel 4.4.0
7493

7594
* Respect user-defined compiler settings (e.g. from ~/.R/Makevars).
95+
7696
* Remove TBB's attempts to suppress compiler diagnostics.
97+
7798
* Allow setting the number of threads to use via RCPP_PARALLEL_NUM_THREADS
7899
environment variable.
100+
79101
* Update to TBB 2018 Update 1.
102+
80103
* Add native registration of compiled functions.
81104

82-
RcppParallel 4.3.20
83-
------------------------------------------------------------------------
105+
## RcppParallel 4.3.20
84106

85107
* Add support for Rtools 3.3 w/ GCC 4.9
86108

87-
RcppParallel 4.3.14
88-
------------------------------------------------------------------------
109+
## RcppParallel 4.3.14
89110

90111
* Add support for TBB on Solaris
112+
91113
* Fix failure to compile on OS X Snow Leopard R toolchain
114+
92115
* Add const and non-const operator[] for RMatrix class
93116

94-
RcppParallel 4.3.8
95-
------------------------------------------------------------------------
117+
## RcppParallel 4.3.8
96118

97119
* Add tbbmalloc library
120+
98121
* Correctly pass clang to TBB configure when R is using clang
99122

100-
RcppParallel 4.3.6
101-
------------------------------------------------------------------------
123+
## RcppParallel 4.3.6
102124

103125
* Support for TBB on Windows
104126

105-
RcppParallel 4.3.3
106-
------------------------------------------------------------------------
127+
## RcppParallel 4.3.3
107128

108129
* Update to TBB 4.3 (fixes clang compilation error in platform.h)
130+
109131
* Forward CXX to TBB Makefile
110132

111-
RcppParallel 4.2.5
112-
------------------------------------------------------------------------
133+
## RcppParallel 4.2.5
113134

114135
* Initial release

R/RcppParallel-package.R

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11

2-
32
#' Parallel programming tools for Rcpp
43
#'
54
#' High level functions for doing parallel programming with Rcpp. For example,
@@ -10,7 +9,7 @@
109
#' The high level interface enables safe and robust parallel programming
1110
#' without direct manipulation of operating system threads. On Windows, macOS,
1211
#' and Linux systems the underlying implementation is based on Intel TBB
13-
#' (Threading Building Blocks). On other platforms a less-performant fallback
12+
#' (Threading Building Blocks). On other platforms, a less-performant fallback
1413
#' implementation based on the TinyThread library is used.
1514
#'
1615
#' For additional documentation, see the package website at:

R/flags.R

Lines changed: 11 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,25 @@
33
#'
44
#' Output the compiler or linker flags required to build against RcppParallel.
55
#'
6-
#' These functions are typically called from \code{Makevars} as follows:
6+
#' These functions are typically called from `Makevars` as follows:
77
#'
88
#' ```
99
#' PKG_LIBS += $(shell "${R_HOME}/bin/Rscript" -e "RcppParallel::LdFlags()")
1010
#' ```
1111
#'
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
14-
#' dynamically.
14+
#' dynamically on load by `RcppParallel`.
1515
#'
16-
#' To ensure portability, load \pkg{RcppParallel} before loading
17-
#' your package, e.g. by including \code{importFrom(RcppParallel,
18-
#' RcppParallelLibs)} in your \code{NAMESPACE} file. See
19-
#' \url{https://github.com/RcppCore/RcppParallel/issues/129} for details.
16+
#' \R packages using RcppParallel should also add the following to their
17+
#' `NAMESPACE` file:
18+
#'
19+
#' ```
20+
#' importFrom(RcppParallel, RcppParallelLibs)
21+
#' ```
22+
#'
23+
#' This is necessary to ensure that \pkg{RcppParallel} (and so, TBB) is loaded
24+
#' and available.
2025
#'
2126
#' @name flags
2227
#' @rdname flags
@@ -46,113 +51,3 @@ RcppParallelLibs <- function() {
4651
LdFlags()
4752
}
4853

49-
50-
51-
tbbCxxFlags <- function() {
52-
53-
flags <- character()
54-
55-
# opt-in to TBB on Windows
56-
if (is_windows())
57-
flags <- c(flags, "-DRCPP_PARALLEL_USE_TBB=1")
58-
59-
# if TBB_INC is set, apply those library paths
60-
tbbInc <- Sys.getenv("TBB_INC", unset = NA)
61-
if (!is.na(tbbInc)) {
62-
63-
# add include path
64-
flags <- c(flags, paste0("-I", shQuote(asBuildPath(tbbInc))))
65-
66-
# prefer new interface if version.h exists
67-
versionPath <- file.path(tbbInc, "tbb/version.h")
68-
if (file.exists(versionPath))
69-
flags <- c(flags, "-DTBB_INTERFACE_NEW")
70-
71-
}
72-
73-
# return flags as string
74-
paste(flags, collapse = " ")
75-
76-
}
77-
78-
# Return the linker flags required for TBB on this platform
79-
tbbLdFlags <- function() {
80-
81-
# shortcut if TBB_LIB defined
82-
tbbLib <- Sys.getenv("TBB_LIB", unset = NA)
83-
if (!is.na(tbbLib)) {
84-
fmt <- "-L%1$s -Wl,-rpath,%1$s -ltbb -ltbbmalloc"
85-
return(sprintf(fmt, shQuote(asBuildPath(tbbLib))))
86-
}
87-
88-
# on Windows and Solaris, we need to explicitly link
89-
needsExplicitFlags <- is_windows() || (is_solaris() && !is_sparc())
90-
if (needsExplicitFlags) {
91-
libPath <- asBuildPath(dirname(tbbLibPath()))
92-
libFlag <- paste0("-L", shQuote(libPath))
93-
return(paste(libFlag, "-ltbb", "-ltbbmalloc"))
94-
}
95-
96-
# nothing required on other platforms
97-
""
98-
99-
}
100-
101-
tbbRoot <- function() {
102-
rArch <- .Platform$r_arch
103-
parts <- c("libs", if (nzchar(rArch)) rArch, "tbb")
104-
libDir <- paste(parts, collapse = "/")
105-
system.file(libDir, package = "RcppParallel")
106-
}
107-
108-
# Determine the platform-specific path to the TBB library
109-
tbbLibPath <- function(suffix = "") {
110-
111-
# library paths for different OSes
112-
sysname <- Sys.info()[["sysname"]]
113-
114-
tbbLibNames <- list(
115-
"Darwin" = paste0("libtbb", suffix, ".dylib"),
116-
"Windows" = paste0("tbb", suffix, ".dll"),
117-
"SunOS" = paste0("libtbb", suffix, ".so"),
118-
"Linux" = paste0("libtbb", suffix, c(".so.2", ".so"))
119-
)
120-
121-
# skip systems that we know not to be compatible
122-
isCompatible <-
123-
!is_sparc() &&
124-
!is.null(tbbLibNames[[sysname]])
125-
126-
if (!isCompatible)
127-
return(NULL)
128-
129-
# find root for TBB install
130-
tbbRoot <- Sys.getenv("TBB_LIB", unset = tbbRoot())
131-
libNames <- tbbLibNames[[sysname]]
132-
for (libName in libNames) {
133-
tbbName <- file.path(tbbRoot, libName)
134-
if (file.exists(tbbName))
135-
return(tbbName)
136-
}
137-
138-
}
139-
140-
# Helper function to ape the behavior of the R build system
141-
# when providing paths to libraries
142-
asBuildPath <- function(path) {
143-
144-
# nothing to do for non-Windows
145-
if (!is_windows())
146-
return(path)
147-
148-
# normalize paths using forward slashes
149-
path <- normalizePath(path, winslash = "/", mustWork = FALSE)
150-
151-
# prefer short path names if the path has spaces
152-
if (grepl(" ", path, fixed = TRUE))
153-
path <- utils::shortPathName(path)
154-
155-
# return path
156-
return(path)
157-
158-
}

R/hooks.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ mallocDllInfo <- NULL
1414
}
1515
}
1616

17-
tbbMalloc <- tbbLibPath("malloc")
17+
tbbMalloc <- tbbLibPath("tbbmalloc")
1818
if (!is.null(tbbMalloc)) {
1919
if (!file.exists(tbbMalloc)) {
2020
warning(paste("TBB malloc library", tbbMalloc, "not found."))

0 commit comments

Comments
 (0)