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.
1730inlineCxxPlugin <- 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
0 commit comments