Skip to content

Commit 88abf03

Browse files
committed
Merge pull request #21 from RcppCore/feature/boost-simd-refinements
Various refinements to Boost.SIMD implementation
2 parents b21daa8 + 3e06621 commit 88abf03

17 files changed

+209
-66
lines changed

.Rbuildignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
^.*\.Rproj$
22
^\.Rproj\.user$
3+
^\.Rprofile$
34
^src/tbb/build/lib_.*$
45
^tests/testthat/pkg/RcppParallelTest/src/.*\.s?o$
56
^tests/testthat/pkg/RcppParallelTest/src/.*\.dll$
@@ -8,4 +9,4 @@
89
^README.md
910
^doc$
1011
^src/.*\.o$
11-
^examples/
12+
^examples/

DESCRIPTION

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,16 @@ Authors@R: c(
1212
person(family = "RStudio", role = "cph"),
1313
person(family = "Intel", role = c("aut", "cph"),
1414
comment = "Intel TBB library, https://www.threadingbuildingblocks.org/"),
15-
person(family = "Microsoft", role = "cph")
15+
person(family = "Microsoft", role = "cph"),
16+
person("Joel", "Falcou", role = "aut"),
17+
person(family = "UMR 8623 CNRS/Univ Paris Sud XI", role = "cph",
18+
comment = "Boost.SIMD library, https://www.lri.fr/~falcou/pub/pact-2012.pdf")
1619
)
1720
Description: High level functions for doing parallel programming with 'Rcpp'.
1821
For example, the parallelFor() function can be used to convert the work of
1922
a standard serial "for" loop into a parallel one and the parallelReduce()
2023
function can be used for accumulating aggregate or other values.
24+
Depends: R (>= 3.0.2)
2125
Suggests:
2226
Rcpp,
2327
RUnit,

NAMESPACE

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
export(setThreadOptions)
22
export(defaultNumThreads)
33
export(RcppParallelLibs)
4+
export(CxxFlags)
5+
export(LdFlags)
6+
47

R/build.R

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,36 @@
11

22

3+
# Output the CXX flags. These flags are propagated to sourceCpp via the
4+
# inlineCxxPlugin (defined below) and to packages via a line in Makevars[.win]
5+
# like this:
6+
#
7+
# PKG_CXXFLAGS += $(shell "${R_HOME}/bin${R_ARCH_BIN}/Rscript.exe" -e "RcppParallel::CxxFlags()")
8+
#
9+
CxxFlags <- function(simd = TRUE) {
10+
cat(tbbCxxFlags(simd = simd))
11+
}
12+
13+
314
# Output the LD flags for building against TBB. These flags are propagated
415
# to sourceCpp via the inlineCxxPlugin (defined below) and to packages
5-
# via a line in Makevars.win like this:
16+
# via a line in Makevars[.win] like this:
617
#
718
# PKG_LIBS += $(shell "${R_HOME}/bin${R_ARCH_BIN}/Rscript.exe" -e "RcppParallel::LdFlags()")
819
#
9-
# Note that this is only required for Windows builds (on Linux and OS X no
10-
# explicit link to TBB is required).
11-
RcppParallelLibs <- function() {
20+
LdFlags <- function() {
1221
cat(tbbLdFlags())
1322
}
1423

24+
# alias for backward compatibility
25+
RcppParallelLibs <- function() {
26+
LdFlags()
27+
}
1528

16-
# Inline plugin used by sourceCpp to link to the TBB library
29+
# Inline plugin used by sourceCpp.
1730
inlineCxxPlugin <- function() {
1831
list(
1932
env = list(
20-
PKG_CXXFLAGS = paste(tbbCxxFlags(), mtuneFlags()),
33+
PKG_CXXFLAGS = paste("$(CXX1XSTD)", tbbCxxFlags()),
2134
PKG_LIBS = tbbLdFlags()
2235
),
2336
includes = "#include <RcppParallel.h>",
@@ -27,19 +40,18 @@ inlineCxxPlugin <- function() {
2740
)
2841
}
2942

30-
mtuneFlags <- function() {
31-
switch(Sys.info()[["sysname"]],
32-
"Linux" = "-mtune=native",
33-
"Darwin" = "-mtune=core2",
34-
"Windows" = "-mtune=core2",
35-
""
36-
)
37-
}
38-
39-
tbbCxxFlags <- function() {
40-
flags <- "$(CXX1XSTD)"
43+
tbbCxxFlags <- function(simd = TRUE) {
44+
45+
flags <- c()
46+
47+
# opt-in to TBB on Windows
4148
if (Sys.info()['sysname'] == "Windows")
4249
flags <- paste(flags, "-DRCPP_PARALLEL_USE_TBB=1")
50+
51+
# reflect requested use of boost::simd
52+
if (!simd)
53+
flags <- paste(flags, "-DRCPP_PARALLEL_USE_SIMD=0")
54+
4355
flags
4456
}
4557

examples/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.html

examples/boost-simd-abssum.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// [[Rcpp::depends(RcppParallel)]]
2-
#include <RcppParallelSIMD.h>
2+
#include <RcppParallel.h>
33
#include <Rcpp.h>
44
using namespace Rcpp;
55

examples/boost-simd-accumulate.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// [[Rcpp::depends(RcppParallel)]]
2-
#include <RcppParallelSIMD.h>
2+
#include <RcppParallel.h>
33
#include <Rcpp.h>
44
using namespace Rcpp;
55

examples/boost-simd-capabilities.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// [[Rcpp::depends(RcppParallel)]]
2-
#include <RcppParallelSIMD.h>
2+
#include <RcppParallel.h>
33
#include <Rcpp.h>
44
using namespace Rcpp;
55

examples/boost-simd-dot.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// [[Rcpp::depends(RcppParallel)]]
2-
#include <RcppParallelSIMD.h>
2+
#include <RcppParallel.h>
33
#include <Rcpp.h>
44
using namespace Rcpp;
55

examples/boost-simd-hello-world.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// [[Rcpp::depends(RcppParallel)]]
2-
#include <RcppParallelSIMD.h>
2+
#include <RcppParallel.h>
33
#include <Rcpp.h>
44
using namespace Rcpp;
55

0 commit comments

Comments
 (0)