Skip to content

Commit 158b953

Browse files
kevinusheycran-robot
authored andcommitted
version 5.0.0
1 parent d4d0b01 commit 158b953

File tree

15 files changed

+177
-94
lines changed

15 files changed

+177
-94
lines changed

DESCRIPTION

Lines changed: 3 additions & 3 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: 4.4.4
4+
Version: 5.0.0
55
Authors@R: c(
66
person("JJ", "Allaire", role = c("aut"), email = "jj@rstudio.com"),
77
person("Romain", "Francois", role = c("aut", "cph")),
@@ -28,7 +28,7 @@ URL: http://rcppcore.github.io/RcppParallel,
2828
Biarch: TRUE
2929
Collate: 'build.R' 'hooks.R' 'options.R' 'skeleton.R'
3030
NeedsCompilation: yes
31-
Packaged: 2019-09-25 16:06:48 UTC; kevinushey
31+
Packaged: 2020-03-10 19:14:58 UTC; kevinushey
3232
Author: JJ Allaire [aut],
3333
Romain Francois [aut, cph],
3434
Kevin Ushey [aut, cre],
@@ -41,4 +41,4 @@ Author: JJ Allaire [aut],
4141
Microsoft [cph]
4242
Maintainer: Kevin Ushey <kevin@rstudio.com>
4343
Repository: CRAN
44-
Date/Publication: 2019-09-27 08:50:10 UTC
44+
Date/Publication: 2020-03-11 23:10:22 UTC

MD5

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
1-
4785c7aa919dd342f638704419dca769 *DESCRIPTION
1+
26e59102bf659e5991dc7837854ac4ec *DESCRIPTION
22
50d75b4d42421eb8dc927070d5b190d4 *NAMESPACE
33
5a1495bf7a04c7ba544b8d4c4c002d79 *R/build.R
4-
1c89f724d1263d253689bb19202fc187 *R/hooks.R
5-
0cb36faf871ae59f97c4d2408469651b *R/options.R
4+
e40b3b2f751d79e1eeccbd56d333f4dd *R/hooks.R
5+
9af62c399b678118175782c155c8ec68 *R/options.R
66
c738dae81e6eb1863eca51006694f2fb *R/skeleton.R
77
390aa2da7fa4a9d9cafe36ea98b1605b *cleanup
88
b655b8ee83719d6f623567248466e2d4 *cleanup.win
99
cde1332e18de6608b528526313571267 *configure
1010
b481df59119f55840bf861e8e1c1a9f9 *configure.win
11-
f9d8bed7ec9c56f52984b19a1004144b *inst/NEWS
12-
5ff513fb33023d45231d644c6cd9e7ba *inst/include/RcppParallel.h
11+
e1995fada10f36a24aff1b4af444016b *inst/NEWS
12+
a621d9e091b717f24ce5033323c85ba2 *inst/include/RcppParallel.h
13+
a6c056a4c7e284fb4a0258a525669340 *inst/include/RcppParallel/Backend.h
1314
d4ab7ad2384f150a32637a284e831bc0 *inst/include/RcppParallel/Common.h
1415
3749562d299d4065cc99f275e7f2585a *inst/include/RcppParallel/RMatrix.h
1516
7b0de08055d8aa0b21de7a1260083041 *inst/include/RcppParallel/RVector.h
1617
70ea4c28bcd015bcf2eef88bb1d45ced *inst/include/RcppParallel/TBB.h
1718
804a6a70a3eefef66c5700bd0fbbfe9b *inst/include/RcppParallel/Timer.h
18-
640b20f47726aabcc8cf501ab43375e1 *inst/include/RcppParallel/TinyThread.h
19+
cba41cd9cc316a5edd076c4bc6abaa4c *inst/include/RcppParallel/TinyThread.h
1920
719fca47bf2eb469426db8b3dd0d1b9b *inst/include/index.html
2021
cbc1275e9a34dd943d4d1d31863b15bf *inst/include/serial/tbb/parallel_for.h
2122
cb129f0cecff46bdea633d23db82a17f *inst/include/serial/tbb/tbb_annotate.h
@@ -139,19 +140,17 @@ b218740313281a0ee2832de9777e71e3 *inst/skeleton/vector-sum.Rd
139140
2b9284692fea3fa494038f0a684f53d0 *inst/skeleton/vector-sum.cpp
140141
c7e35f89b0b1ffb309920b6596b13d62 *inst/tests/cpp/distance.cpp
141142
b9e5bbe1cadd17714288718fa225e49c *inst/tests/cpp/innerproduct.cpp
142-
7e29328ca6927d0297b4ff2d2f498305 *inst/tests/cpp/malloc.cpp
143143
8ca3bc3f887c91b7dfd38ab0192b4bcc *inst/tests/cpp/sum.cpp
144144
8ec8d03260257d2fffb8e39442ebe66b *inst/tests/cpp/transform.cpp
145145
61a8898bd23f20c9487bebe52c92fb6a *inst/tests/runit.distance.R
146146
d201cb80099dba62315a39eaadc0eb67 *inst/tests/runit.innerproduct.R
147-
0f0fa4e7ed653cd99d6cd3a26a6a3e6c *inst/tests/runit.malloc.R
148147
3b28677a7432e04b31b7cb91ca17855f *inst/tests/runit.sum.R
149148
bcb7cccabfbd3e3f24834d40d1f014a0 *inst/tests/runit.transform.R
150149
cee8e00decc99c13c084f3af8256c9df *man/RcppParallel-package.Rd
151150
cf21b0e90c8e12da67f81db0f9e3edad *man/RcppParallel.package.skeleton.Rd
152151
5b33e213c19d4da27cf4f401a2020518 *man/RcppParallelFlags.Rd
153-
f3b91a97f7f2c4cbe658b0858d74017e *man/setThreadOptions.Rd
154-
7ba831317b47182ed1693e2bb196cbd7 *src/Makevars.in
152+
d5aa6a871c5b1ef15377dca51706277c *man/setThreadOptions.Rd
153+
eec626907c1276435e752210c4b5e79c *src/Makevars.in
155154
577ff72d88540ba48b61c11fe1d0cb3c *src/init.cpp
156155
32ee0b5805df0877ee7e81d97619ec96 *src/options.cpp
157156
ab34a7f2db75a1b1ad2eeddeefd330ce *src/tbb/CHANGES
@@ -221,7 +220,7 @@ e9637b87056560f0280e2c2509fc9971 *src/tbb/build/vs2013/makefile.sln
221220
b59924ca71fcbd1043f40334227b93b9 *src/tbb/build/windows.cl.inc
222221
a233345a54f6f6396a97b2968d5d42b2 *src/tbb/build/windows.gcc.inc
223222
7ee8d7b31d57eb476bb5179079fe6086 *src/tbb/build/windows.icl.inc
224-
dda1ef69f72e1950f857e2fc85a53666 *src/tbb/build/windows.inc
223+
c37d52688295e2fd1b05c3e3ededabb7 *src/tbb/build/windows.inc
225224
719fca47bf2eb469426db8b3dd0d1b9b *src/tbb/include/index.html
226225
7fedae3af7bb81b25e0f2978f758395e *src/tbb/include/serial/tbb/parallel_for.h
227226
9155bd2dece2303d826feb03ecebf951 *src/tbb/include/serial/tbb/tbb_annotate.h
@@ -516,7 +515,7 @@ b765d41fdcdfb8d68d72103a524b3f90 *src/tbb/src/tbbmalloc/tbbmalloc_internal_api.h
516515
da1bd66f7c1bc19cd4542daac9ddfa5e *src/tbb/src/tbbmalloc/win64-tbbmalloc-export.def
517516
14f025a300e77c2f4c50f075a7315208 *src/tbb/src/tbbproxy/tbbproxy-windows.asm
518517
7eab0aae6dc1101e7220bbdde0408ec9 *src/tbb/src/tbbproxy/tbbproxy.cpp
519-
9c42494a8a946f4e7d9a1dd823c3fca9 *tests/doRUnit.R
518+
f583b9e335d83e862b59f19b35f38f58 *tests/doRUnit.R
520519
af8e7488d578542b16949cb62833f616 *tools/config.R
521520
b564bb610841dd8709edc843eeca49a0 *tools/config/cleanup.R
522-
51aada6d029f16bc6e80bc8195c410e2 *tools/config/configure.R
521+
1f65577b20dd2a9696d235baf850e5fd *tools/config/configure.R

R/hooks.R

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,6 @@ mallocDllInfo <- NULL
2525
# load the package library
2626
library.dynam("RcppParallel", pkgname, libname)
2727

28-
# set default thread options
29-
numThreads <- "auto"
30-
numThreadsEnv <- Sys.getenv("RCPP_PARALLEL_NUM_THREADS", unset = NA)
31-
if (!is.na(numThreadsEnv))
32-
setThreadOptions(numThreads = as.integer(numThreadsEnv))
33-
else
34-
setThreadOptions(numThreads = "auto")
3528
}
3629

3730
.onUnload <- function(libpath) {

R/options.R

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

2+
isUsingTbb <- function() {
3+
backend <- Sys.getenv("RCPP_PARALLEL_BACKEND", "tbb")
4+
identical(backend, "tbb")
5+
}
26

37
setThreadOptions <- function(numThreads = "auto", stackSize = "auto") {
48

@@ -19,18 +23,27 @@ setThreadOptions <- function(numThreads = "auto", stackSize = "auto") {
1923
stackSize <- as.integer(stackSize)
2024

2125
# Call setThreadOptions if using tbb
22-
if (!is.null(dllInfo)) {
23-
invisible(.Call("setThreadOptions", numThreads, stackSize,
24-
PACKAGE = "RcppParallel"))
25-
}
26+
if (!is.null(dllInfo) && isUsingTbb())
27+
setTbbThreadOptions(numThreads, stackSize)
2628

2729
if (numThreads == -1L)
2830
Sys.unsetenv("RCPP_PARALLEL_NUM_THREADS")
2931
else
3032
Sys.setenv(RCPP_PARALLEL_NUM_THREADS = numThreads)
3133
}
3234

33-
defaultNumThreads <- function() {
34-
.Call("defaultNumThreads", PACKAGE = "RcppParallel")
35+
setTbbThreadOptions <- function(numThreads, stackSize) {
36+
.Call(
37+
"setThreadOptions",
38+
as.integer(numThreads),
39+
as.integer(stackSize),
40+
PACKAGE = "RcppParallel"
41+
)
3542
}
3643

44+
defaultNumThreads <- function() {
45+
.Call(
46+
"defaultNumThreads",
47+
PACKAGE = "RcppParallel"
48+
)
49+
}

inst/NEWS

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
RcppParallel 5.0.0
2+
------------------------------------------------------------------------
3+
* RcppParallel backend can now be customized with RCPP_PARALLEL_BACKEND
4+
environment variable (supported values are 'tbb' and 'tinythread')
5+
* Fixed issue when compiling RcppParallel on macOS Catalina
6+
* Fixed issue when compiling RcppParallel with Rtools40
7+
18
RcppParallel 4.4.4
29
------------------------------------------------------------------------
310
* Fixed an issue when compiling RcppParallel with clang-9 on Fedora

inst/include/RcppParallel.h

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,44 +10,53 @@
1010
// compatibility with CRAN packages not previously configured
1111
// to link to TBB in Makevars.win)
1212
#ifndef RCPP_PARALLEL_USE_TBB
13-
#if defined(__APPLE__) || defined(__gnu_linux__) || ((defined(__sun) && defined(__SVR4) && !defined(__sparc)))
14-
#define RCPP_PARALLEL_USE_TBB 1
15-
#include "RcppParallel/TBB.h"
16-
#else
17-
#define RCPP_PARALLEL_USE_TBB 0
18-
#endif
13+
# if defined(__APPLE__) || defined(__gnu_linux__) || (defined(__sun) && defined(__SVR4) && !defined(__sparc))
14+
# define RCPP_PARALLEL_USE_TBB 1
15+
# else
16+
# define RCPP_PARALLEL_USE_TBB 0
17+
# endif
1918
#endif
2019

2120
#if RCPP_PARALLEL_USE_TBB
22-
#include "RcppParallel/TBB.h"
21+
# include "RcppParallel/TBB.h"
2322
#endif
2423

24+
#include "RcppParallel/Backend.h"
25+
2526
#include "RcppParallel/RVector.h"
2627
#include "RcppParallel/RMatrix.h"
2728

2829
namespace RcppParallel {
2930

30-
inline void parallelFor(std::size_t begin, std::size_t end,
31-
Worker& worker, std::size_t grainSize = 1) {
32-
31+
inline void parallelFor(std::size_t begin,
32+
std::size_t end,
33+
Worker& worker,
34+
std::size_t grainSize = 1)
35+
{
3336
#if RCPP_PARALLEL_USE_TBB
34-
tbbParallelFor(begin, end, worker, grainSize);
37+
if (internal::backend() == internal::BACKEND_TBB)
38+
tbbParallelFor(begin, end, worker, grainSize);
39+
else
40+
ttParallelFor(begin, end, worker, grainSize);
3541
#else
3642
ttParallelFor(begin, end, worker, grainSize);
3743
#endif
38-
3944
}
4045

4146
template <typename Reducer>
42-
inline void parallelReduce(std::size_t begin, std::size_t end,
43-
Reducer& reducer, std::size_t grainSize = 1) {
44-
47+
inline void parallelReduce(std::size_t begin,
48+
std::size_t end,
49+
Reducer& reducer,
50+
std::size_t grainSize = 1)
51+
{
4552
#if RCPP_PARALLEL_USE_TBB
46-
tbbParallelReduce(begin, end, reducer, grainSize);
53+
if (internal::backend() == internal::BACKEND_TBB)
54+
tbbParallelReduce(begin, end, reducer, grainSize);
55+
else
56+
ttParallelReduce(begin, end, reducer, grainSize);
4757
#else
4858
ttParallelReduce(begin, end, reducer, grainSize);
4959
#endif
50-
5160
}
5261

5362
} // namespace RcppParallel
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
2+
#ifndef __RCPP_PARALLEL_BACKEND__
3+
#define __RCPP_PARALLEL_BACKEND__
4+
5+
#include <cstdlib>
6+
#include <cstring>
7+
8+
extern "C" {
9+
void REprintf(const char*, ...);
10+
}
11+
12+
namespace RcppParallel {
13+
namespace internal {
14+
15+
enum backend_type {
16+
BACKEND_TBB,
17+
BACKEND_TINYTHREAD
18+
};
19+
20+
#if RCPP_PARALLEL_USE_TBB
21+
22+
inline backend_type defaultBackend()
23+
{
24+
return BACKEND_TBB;
25+
}
26+
27+
#else
28+
29+
inline backend_type defaultBackend()
30+
{
31+
return BACKEND_TINYTHREAD;
32+
}
33+
34+
#endif
35+
36+
inline const char* backendToString(backend_type backend)
37+
{
38+
switch (backend)
39+
{
40+
case BACKEND_TBB:
41+
return "tbb";
42+
case BACKEND_TINYTHREAD:
43+
return "tinythread";
44+
}
45+
46+
// shouldn't be reached but need to silence compiler warnings
47+
return "tbb";
48+
}
49+
50+
inline backend_type backend()
51+
{
52+
const char* requestedBackend = std::getenv("RCPP_PARALLEL_BACKEND");
53+
if (requestedBackend == NULL)
54+
{
55+
return defaultBackend();
56+
}
57+
else if (std::strcmp(requestedBackend, "tbb") == 0)
58+
{
59+
#if RCPP_PARALLEL_USE_TBB
60+
return BACKEND_TBB;
61+
#else
62+
const char* msg =
63+
"tbb backend is not available; using tinythread instead";
64+
65+
REprintf("%s\n", msg);
66+
return BACKEND_TINYTHREAD;
67+
#endif
68+
}
69+
else if (strcmp(requestedBackend, "tinythread") == 0)
70+
{
71+
return BACKEND_TINYTHREAD;
72+
}
73+
else
74+
{
75+
const char* fmt = "unknown parallel backend '%s'; using '%s' instead\n";
76+
REprintf(fmt, requestedBackend, backendToString(defaultBackend()));
77+
return defaultBackend();
78+
}
79+
}
80+
81+
} // namespace internal
82+
} // namespace RcppParallel
83+
84+
#endif /* __RCPP_PARALLEL_BACKEND__ */

inst/include/RcppParallel/TinyThread.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
#define __RCPP_PARALLEL_TINYTHREAD__
33

44
#include <cstdlib>
5+
#include <cstdio>
56

67
#include "Common.h"
78

89
#include <tthread/tinythread.h>
910

10-
#include <stdio.h>
1111

1212
#include <vector>
1313

inst/tests/cpp/malloc.cpp

Lines changed: 0 additions & 26 deletions
This file was deleted.

inst/tests/runit.malloc.R

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)