You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: examples/simd-operations.Rmd
+18-15Lines changed: 18 additions & 15 deletions
Original file line number
Diff line number
Diff line change
@@ -15,11 +15,10 @@ Modern CPU processors are built with new, extended instruction sets that optimiz
15
15
16
16
`Boost.SIMD` is a C++ header-only library that makes it possible to explicitly request the use of SIMD instructions when possible, while falling back to regular scalar operations if not. `RcppParallel` wraps and exposes this library for use with R vectors.
17
17
18
-
Here's a quick example of how we might compute the sum of elements in a vector, using `Boost.SIMD`. Note that we've added `#define RCPP_PARALLEL_USE_SIMD 1` before including `RcppParallel.h` since SIMD features are not included by default.
18
+
Here's a quick example of how we might compute the sum of elements in a vector, using `Boost.SIMD`.
19
19
20
20
```{r, engine='Rcpp'}
21
21
// [[Rcpp::depends(RcppParallel)]]
22
-
#define RCPP_PARALLEL_USE_SIMD 1
23
22
#include <RcppParallel.h>
24
23
#include <Rcpp.h>
25
24
@@ -65,7 +64,6 @@ These functions operate like their `std::` counterparts, but expect a functor wi
Note that Boost.SIMD requires a C++11 conformant compiler. This means that packages making use of SIMD features may not compile on platforms with older compilers including Windows and RedHat/CentOS Linux. You can however create a package that takes advantage of Boost.SIMD where available and falls back to a non-SIMD implementation elsewhere.
125
122
126
-
The result of specifying `simd = TRUE` in Makevars to to define the `RCPP_PARALLEL_USE_SIMD` preprocessor variable. This is interpreted as a *request* for Boost.SIMD. If the current compiler doesn't support C++11 (as determined by `__cplusplus <= 199711L`) the variable will be undefined. This allows you to write code like this:
123
+
You can test for the availability of Boost.SIMD on a given platform using the `RCPP_PARALLEL_USE_SIMD` preprocessor variable. If the current compiler doesn't support C++11 (as determined by `__cplusplus <= 199711L`) the variable will be undefined. This allows you to write code like this:
Note that the two functions have the same name (only one will be compiled and linked based on whether the target platform supports Boost.SIMD).
155
+
The two `transformDataImpl` functions have the same name, but only one will be compiled and linked based on whether the target platform supports Boost.SIMD.
154
156
157
+
Note that if you conditionally compile all uses of Boost.SIMD within your package then you can actually drop the `C++11` from `SystemRequirements` (it's no longer required as a result of your fallback implementation).
0 commit comments