Automatic type vectorization.
The Vc::simdize<T>
expression transforms the type T
to a vectorized type. This requires the type T
to be a class template instance or an arithmetic type.
Example: First, we declare a class template for a three-dimensional point. The template parameter T
determines the type of the members and is float
in the scalar (classical) case.
In the following we create a type alias for the scalar type, which simply means instantiating PointTemplate
with float
. The resulting type can then be transformed with simdize.
The following shows a code example using the above Point
and PointV
types.
Vc::simdize<Iterator>
can also be used to turn an iterator type into a new iterator type with Vc::simdize<Iterator::value_type>
as its value_type
. Note that Vc::simdize<double>
turns into Vc::Vector<double>
, which makes it easy to iterate over a given container of builtin arithmetics using Vc::Vector
.
Macros | |
#define | Vc_SIMDIZE_INTERFACE(MEMBERS_) |
Typedefs | |
template<typename T , size_t N = 0, typename MT = void> | |
using | simdize = SimdizeDetail::simdize<T, N, MT> |
Functions | |
template<typename S , typename T , size_t N> | |
Adapter< S, T, N > | shifted (const Adapter< S, T, N > &a, int shift) |
Returns a new vectorized object where each entry is shifted by shift . | |
template<typename S , typename T , std::size_t N> | |
void | swap (Adapter< S, T, N > &a, std::size_t i, S &x) |
Swaps one scalar object x with a SIMD slot at offset i in the simdized object a . | |
template<typename A > | |
void | swap (Scalar< A > &&a, typename A::scalar_type &b) |
std::swap interface to swapping one scalar object with a (virtual) reference to another object inside a vectorized object | |
template<typename A > | |
void | swap (typename A::scalar_type &b, Scalar< A > &&a) |
std::swap interface to swapping one scalar object with a (virtual) reference to another object inside a vectorized object | |
template<class F , class = decltype(static_cast<Scalar>(std::declval<F>()( size_t())))> | |
Adapter (F &&fun) | |
Generator constructor {{{. | |
#define Vc_SIMDIZE_INTERFACE | ( | MEMBERS_ | ) |
Declares functions and constants for introspection by the simdize functions. This allows e.g. conversion between scalar T
and simdize<T>
.
MEMBERS_ | The data members of this struct/class listed inside extra parenthesis. The extra parenthesis are required because the macro would otherwise see a variable number of arguments. |
Example:
using simdize = SimdizeDetail::simdize<T, N, MT> |
Vectorize/Simdize the given type T.
T | This type must be a class template instance where the template arguments can be recursively replaced with their vectorized variant. If the type implements a specific interface for introspection and member modification, the resulting type can easily be constructed from objects of type T and scalar objects of type T can be extracted from it. |
N | This value determines the width of the vectorization. Per default it is set to 0 making the implementation choose the value considering the compilation target and the given type T. |
MT | This type determines the type to be used when replacing bool with Mask<MT>. If it is set to void the implementation choosed the type as smart as possible. |
|
inline |
Returns a new vectorized object where each entry is shifted by shift
.
This basically calls Vector<T>::shifted on every entry.
a | The object to apply the shift on. |
shift | The number of entries to shift by. |
a
shifted by shift
. Definition at line 1069 of file simdize.h.
Referenced by Vc::SimdizeDetail::shifted().