Hi everyone,
I'm interested in how Boost.SIMD can be used at a high level -- in particular, using `boost::simd::transform()` and `boost::simd::accumulate()` together with the high-level functions that Boost.SIMD defines. The goal is that clients of the wrapper wouldn't need to worry about alignment or what SIMD operations are available, but would just 'automagically' get all the benefits that Boost.SIMD provides when appropriate.
It seems like the general way these functions could be used is with:
1) Create a class with a template call operator, using the desired function;
2) Pass an instance of that functor to the appropriate algorithm.
However, it would 'be nice' if we could directly use these functions, or functors, in the algorithm wrappers provided by Boost.SIMD, e.g. I'd love to just write something like
boost::simd::accumulate(data.begin(), data.end(), 0.0, boost::simd::sqrt);
Is there another mechanism for handling this -- preferably, without the use of wrapper structs?
It seems like C++14 generic lambdas might be helpful here, e.g.
boost::simd::accumulate(data.begin(), data.end(), 0.0, [](auto el) { return boost::simd::sqrt(el); })
but unfortunately the version of clang I'm using seems to barf when attempting to run in C++14 mode (perhaps I'm missing a support header, not sure). For reference, the sample program + output is available here:
https://gist.github.com/kevinushey/5e800b68fc028302ebbc. Note that I'm using the Boost.SIMD headers as included in RcppParallel; these were generated by building + installing nt2 then copying the headers over.
Any thoughts on a lower-overhead, C++11-ish way of using 'transform()' and 'accumulate()' with the available SIMD functions? Or, what can I do to get a C++14 version with generic lambdas to work?
Thanks!
Kevin