high-level use of Boost.SIMD

25 views
Skip to first unread message

Kevin Ushey

unread,
Jan 15, 2016, 2:48:36 PM1/15/16
to nt2-dev
Hi,

(sorry if this is a repost -- it seems my first attempt got lost in the ether; at least I can't see it as part of the group's posts)

I'm curious whether it's possible to easily combine the SIMD algorithm functions (boost::simd::transform(), boost::simd::accumulate()) with the functions wrappers exposed by Boost.SIMD (e.g. sqrt). The goal is to provide a high-level interface where users don't need to think about alignment issues, while writing the least amount of code necessary to benefit from Boost.SIMD.

An example of this is done in the unit tests here:


It seems like this can be accomplished by:

    1) Creating a functor with a templated call operator (written in a somewhat Boost.SIMD-ish style), and
    2) Passing an instance of that functor to the appropriate algorithm.

I'm wondering if it's possible to skip that step for builtin functions -- ie, in a perfect world, I'd be able to write something like:

    boost::simd::transform(data.begin(), data.end(), data.begin(), boost::simd::sqrt);

Alternatively, it seems like C++14 + generic lambdas could be useful here, e.g.

    boost::simd::transform(data.begin(), data.end(), data.begin(), [](auto el) { return boost::simd::sqrt(el); });

but I unfortunately get a number of dispatch errors. (code is here: https://gist.github.com/kevinushey/5e800b68fc028302ebbc)

Any thoughts on what the lowest-overhead way of accomplishing this is? Is there another way of looking at this that I'm missing?

Thanks!
Kevin

Reply all
Reply to author
Forward
0 new messages