Data-parallel arithmetic type with user-defined number of elements.
T | The type of the vector's elements. The supported types currently are limited to the types supported by Vc::Vector<T>. |
N | The number of elements to store and process concurrently. You can choose an arbitrary number, though not every number is a good idea. Generally, a power of two value or the sum of two power of two values might work efficiently, though this depends a lot on the target system. |
V | Don't change the default value unless you really know what you are doing. This type is set to the underlying native Vc::Vector type used in the implementation of the type. Having it as part of the type name guards against some cases of ODR violations (i.e. linking incompatible translation units / libraries). |
Wt | Don't ever change the default value. This parameter is an unfortunate implementation detail shining through. |
N
too large (what “too large” means depends on the target) will result in excessive compilation times and high (or too high) register pressure, thus potentially negating the improvement from concurrent execution. As a rule of thumb, keep N
less or equal to 2 * float_v::size()
.T
=
(u)short require an N
either less than short_v::size() or a multiple of short_v::size(). #include <Vc/SimdArray>
Public Types | |
using | value_type = T |
The type of the elements (i.e. T ) | |
using | mask_type = fixed_size_simd_mask< T, N > |
The type of the mask used for masked operations and returned from comparisons. | |
using | index_type = fixed_size_simd< int, N > |
The type of the vector used for indexes in gather and scatter operations. | |
using | Mask = mask_type |
The type of the mask used for masked operations and returned from comparisons. More... | |
using | MaskType = Mask |
The type of the mask used for masked operations and returned from comparisons. More... | |
using | EntryType = value_type |
The type of the elements (i.e. T ) More... | |
using | IndexType = index_type |
The type of the vector used for indexes in gather and scatter operations. More... | |
Public Member Functions | |
fixed_size_simd< T, N > | operator+ () const |
Returns a copy of itself. | |
Common::WriteMaskedVector< SimdArray, mask_type > | operator() (const mask_type &mask) |
Writemask the vector before an assignment. More... | |
Vc_INTRINSIC value_type | min () const |
Returns the smallest entry in the vector. | |
Vc_INTRINSIC value_type | min (const mask_type &mask) const |
Returns the smallest entry in the vector. | |
Vc_INTRINSIC value_type | max () const |
Returns the largest entry in the vector. | |
Vc_INTRINSIC value_type | max (const mask_type &mask) const |
Returns the largest entry in the vector. | |
Vc_INTRINSIC value_type | product () const |
Returns the product of all entries in the vector. | |
Vc_INTRINSIC value_type | product (const mask_type &mask) const |
Returns the product of all entries in the vector. | |
Vc_INTRINSIC value_type | sum () const |
Returns the sum of all entries in the vector. | |
Vc_INTRINSIC value_type | sum (const mask_type &mask) const |
Returns the sum of all entries in the vector. | |
fixed_size_simd< T, N > | partialSum () const |
Returns a vector containing the sum of all entries with smaller index. | |
template<typename F > | |
fixed_size_simd< T, N > | apply (F &&f) const |
Call f on every entry of the vector and return the results as a new vector. | |
template<typename F > | |
fixed_size_simd< T, N > | apply (F &&f, const mask_type &k) const |
As above, but skip the entries where mask is not set. | |
fixed_size_simd< T, N > | shifted (int amount) const |
Shift vector entries to the left by amount ; shifting in zeros. | |
fixed_size_simd< T, N > | rotated (int amount) const |
Rotate vector entries to the left by amount . | |
fixed_size_simd< T, N > | reversed () const |
Returns a vector with all components reversed. | |
fixed_size_simd< T, N > | sorted () const |
Return a sorted copy of the vector. More... | |
Compile-Time Constant Initialization | |
SimdArray ()=default | |
Construct a zero-initialized vector object. More... | |
Conversion/Broadcast Constructors | |
SimdArray (value_type a) | |
Broadcast Constructor. More... | |
template<typename U , typename = enable_if<std::is_same<U, int>::value && !std::is_same<int, value_type>::value>> | |
SimdArray (U a) | |
new/delete overloads for correct alignment | |
void * | operator new (size_t size) |
Allocates correctly aligned memory. | |
Vc_ALWAYS_INLINE void * | operator new (size_t, void *p) |
Returns p . | |
Vc_ALWAYS_INLINE void * | operator new[] (size_t size) |
Allocates correctly aligned memory. | |
Vc_ALWAYS_INLINE void * | operator new[] (size_t, void *p) |
Returns p . | |
Vc_ALWAYS_INLINE void | operator delete (void *ptr, size_t) |
Frees aligned memory. | |
Vc_ALWAYS_INLINE void | operator delete (void *, void *) |
Does nothing. | |
Vc_ALWAYS_INLINE void | operator delete[] (void *ptr, size_t) |
Frees aligned memory. | |
Vc_ALWAYS_INLINE void | operator delete[] (void *, void *) |
Does nothing. | |
Static Public Member Functions | |
static constexpr std::size_t | size () |
Returns N , the number of scalar components in an object of this type. More... | |
Static Public Attributes | |
static constexpr std::size_t | MemoryAlignment |
Specifies the alignment requirement for aligned load and store calls for objects of this vector type. More... | |
Generators | |
static fixed_size_simd< T, N > | Zero () |
Returns a vector with the entries initialized to zero. | |
static fixed_size_simd< T, N > | One () |
Returns a vector with the entries initialized to one. | |
static fixed_size_simd< T, N > | IndexesFromZero () |
Returns a vector with the entries initialized to 0, 1, 2, 3, 4, 5, ... | |
static fixed_size_simd< T, N > | Random () |
Returns a vector with pseudo-random entries. More... | |
template<typename G > | |
static fixed_size_simd< T, N > | generate (const G &gen) |
Generate a vector object from return values of gen (static variant of fill). | |
template<class G , class = decltype(std::declval<G>()(std::size_t())), class = enable_if<!Traits::is_simd_vector<G>::value>> | |
SimdArray (const G &gen) | |
Scalar Subscript Operators | |
reference | operator[] (size_t i) noexcept |
This operator can be used to modify scalar entries of the vector. More... | |
value_type | operator[] (size_t index) const noexcept |
This operator can be used to read scalar entries of the vector. More... | |
Deprecated Members | |
static constexpr std::size_t | Size = size() |
Returns N , the number of scalar components in an object of this type. More... | |
fixed_size_simd< T, N > | exponent () const |
Returns the exponents of the floating-point values in the vector. More... | |
MaskType | isNegative () const |
Returns whether a value is negative. More... | |
fixed_size_simd< T, N > | copySign (const SimdArray &x) const |
Copies the signs of the components of reference to the components of the current vector, returning the result. More... | |
The type of the mask used for masked operations and returned from comparisons.
Definition at line 678 of file simdarray.h.
The type of the mask used for masked operations and returned from comparisons.
Definition at line 680 of file simdarray.h.
using EntryType = value_type |
The type of the elements (i.e. T
)
Definition at line 684 of file simdarray.h.
using IndexType = index_type |
The type of the vector used for indexes in gather and scatter operations.
Definition at line 686 of file simdarray.h.
|
default |
Construct a zero-initialized vector object.
This constructor follows the behavior of the underlying arithmetic type T
in that the expression T()
zero-initializes the object. On the other hand the variable x
in T x;
is uninitialized. Since, for class types, both expressions call the default constructor Vector<T> x
must zero-initialize x
as well.
|
inline |
Broadcast Constructor.
Constructs a vector with all entries of the vector filled with the given value.
a | The scalar value to broadcast to all entries of the constructed vector. |
Definition at line 755 of file simdarray.h.
|
inlinestaticconstexpr |
Returns N
, the number of scalar components in an object of this type.
The size of the SimdArray, i.e. the number of scalar elements in the vector. In contrast to Vector::size() you have control over this value via the N
template parameter of the SimdArray class template.
Definition at line 675 of file simdarray.h.
|
inlinestatic |
Returns a vector with pseudo-random entries.
Currently the state of the random number generator cannot be modified and starts off with the same state. Thus you will get the same sequence of numbers for the same sequence of calls.
Definition at line 719 of file simdarray.h.
|
inlinenoexcept |
This operator can be used to modify scalar entries of the vector.
index | A value between 0 and Size. This value is not checked internally so you must make/be sure it is in range. |
index
.Definition at line 1035 of file simdarray.h.
|
inlinenoexcept |
This operator can be used to read scalar entries of the vector.
index | A value between 0 and Size. This value is not checked internally so you must make/be sure it is in range. |
index
. Definition at line 1042 of file simdarray.h.
Writemask the vector before an assignment.
mask | The writemask to be used. |
The returned object is only to be used for assignments and should not be assigned to a variable.
Examples:
Definition at line 1050 of file simdarray.h.
|
inline |
Return a sorted copy of the vector.
v[0] <= v[1] <= v[2] <= v[3] ...
Example:
With SSE the output would be:
[1513634383, -963914658, 1763536262, -1285037745] [-1285037745, -963914658, 1513634383, 1763536262]
With the Scalar implementation:
[1513634383] [1513634383]
Definition at line 1361 of file simdarray.h.