Vc 1.4.5
SIMD Vector Classes for C++
 
Loading...
Searching...
No Matches
SimdArray< T, N, V, Wt > Class Template Reference

Detailed Description

template<typename T, size_t N, typename V, size_t Wt>
class Vc::SimdArray< T, N, V, Wt >

Data-parallel arithmetic type with user-defined number of elements.

Template Parameters
TThe type of the vector's elements. The supported types currently are limited to the types supported by Vc::Vector<T>.
NThe 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.
VDon'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).
WtDon't ever change the default value. This parameter is an unfortunate implementation detail shining through.
Warning
Choosing 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().
A special portability concern arises from a current limitation in the MIC implementation (Intel Knights Corner), where SimdArray types with T = (u)short require an N either less than short_v::size() or a multiple of short_v::size().

Definition at line 616 of file simdarray.h.

#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.
 
using MaskType = Mask
 The type of the mask used for masked operations and returned from comparisons.
 
using EntryType = value_type
 The type of the elements (i.e. T)
 
using IndexType = index_type
 The type of the vector used for indexes in gather and scatter operations.
 

Public Member Functions

fixed_size_simd< T, N > operator+ () const
 Returns a copy of itself.
 
Common::WriteMaskedVector< SimdArray, mask_typeoperator() (const mask_type &mask)
 
value_type min () const
 Returns the smallest entry in the vector.
 
value_type min (const mask_type &mask) const
 Returns the smallest entry in the vector.
 
value_type max () const
 Returns the largest entry in the vector.
 
value_type max (const mask_type &mask) const
 Returns the largest entry in the vector.
 
value_type product () const
 Returns the product of all entries in the vector.
 
value_type product (const mask_type &mask) const
 Returns the product of all entries in the vector.
 
value_type sum () const
 Returns the sum of all entries in the vector.
 
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
 
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.
 
Compile-Time Constant Initialization
 SimdArray ()=default
 Construct a zero-initialized vector object.
 
Conversion/Broadcast Constructors
 SimdArray (value_type a)
 
Gather constructors and member functions

Constructs or loads a vector from the objects at mem[indexes[0]], mem[indexes[1]], mem[indexes[2]], ...

All gather functions optionally take a mask as last argument. In that case only the entries that are selected in the mask are accessed in memory and copied to the vector. This enables invalid indexes in the indexes vector if those are masked off in mask.

Gathers from structured data (AoS: arrays of struct) are possible via a special subscript operator of the container (array). You can use array and vector as drop-in replacements for std::array and std::vector. These container classes contain the necessary subscript operator overload. Example:

std::iota(data.begin(), data.end(), 0.f); // fill with values 0, 1, 2, ...
float_v gathered = data[indexes]; // gathered == [0, 1, 2, ...]
static Vector IndexesFromZero()
Common::AdaptSubscriptOperator< std::vector< T, Allocator > > vector
An adapted std::vector container with an additional subscript operator which implements gather and sc...
Definition vector:55
Vector< float > float_v
vector of single precision
Definition vector.h:54

This also works for gathers into arrays of structures:

struct Point { float x, y, z; };
// fill points ...
float_v xs = data[indexes][&Point::x]; // [points[0].x, points[1].x, points[2].x, ...]
float_v ys = data[indexes][&Point::y]; // [points[0].y, points[1].y, points[2].y, ...]
float_v zs = data[indexes][&Point::z]; // [points[0].z, points[1].z, points[2].z, ...]
This is std::array with additional subscript operators supporting gather and scatter operations.
Definition types.h:188

Alternatively, you can use Vc::Common::AdaptSubscriptOperator to extend a given container class with the necessary subscript operator. Example:

template <typename T, typename Allocator = std::allocator<T>>
using my_vector = Vc::Common::AdaptSubscriptOperator<std::vector<T, Allocator>>;
Parameters
memA pointer to memory which contains objects of type MT at the offsets given by indexes.
indexesA container/vector of offsets into mem. The type of indexes (IT) may either be a pointer to integers (C-array) or a vector of integers (preferrably IndexType).
maskIf a mask is given, only the active entries will be copied from memory.
Note
If you use a masked gather constructor the masked-off entries of the vector are zero-initilized.
template<typename MT, typename IT, typename = enable_if<Traits::has_subscript_operator<IT>::value>>
 SimdArray (const MT *mem, const IT &indexes)
 Gather constructor.
 
template<typename MT, typename IT, typename = enable_if<Vc::Traits::has_subscript_operator<IT>::value>>
 SimdArray (const MT *mem, const IT &indexes, MaskArgument mask)
 Masked gather constructor.
 
template<typename MT, typename IT, typename = enable_if<Vc::Traits::has_subscript_operator<IT>::value>>
void gather (const MT *mem, const IT &indexes)
 Gather function.
 
template<typename MT, typename IT, typename = enable_if<Vc::Traits::has_subscript_operator<IT>::value>>
void gather (const MT *mem, const IT &indexes, MaskArgument mask)
 Masked gather function.
 
Scatter functions

Stores a vector to the objects at mem[indexes[0]], mem[indexes[1]], mem[indexes[2]], ...

Parameters
memA pointer to memory which contains objects of type MT at the offsets given by indexes.
indexes
mask
template<typename MT, typename IT, typename = enable_if<Vc::Traits::has_subscript_operator<IT>::value>>
void scatter (MT *mem, IT &&indexes) const
 Scatter function.
 
template<typename MT, typename IT, typename = enable_if<Vc::Traits::has_subscript_operator<IT>::value>>
void scatter (MT *mem, IT &&indexes, MaskArgument mask) const
 Masked scatter function.
 
new/delete overloads for correct alignment
void * operator new (size_t size)
 Allocates correctly aligned memory.
 
void * operator new (size_t, void *p)
 Returns p.
 
void * operator new[] (size_t size)
 Allocates correctly aligned memory.
 
void * operator new[] (size_t, void *p)
 Returns p.
 
void operator delete (void *ptr, size_t)
 Frees aligned memory.
 
void operator delete (void *, void *)
 Does nothing.
 
void operator delete[] (void *ptr, size_t)
 Frees aligned memory.
 
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.
 

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.
 

Deprecated Members

static constexpr std::size_t Size = size()
 Returns N, the number of scalar components in an object of this type.
 
template<typename S1, typename IT>
 SimdArray (const S1 *array, const EntryType S1::*member1, IT indexes)
 
template<typename S1, typename IT>
 SimdArray (const S1 *array, const EntryType S1::*member1, IT indexes, MaskArgument mask)
 
template<typename S1, typename S2, typename IT>
 SimdArray (const S1 *array, const S2 S1::*member1, const EntryType S2::*member2, IT indexes)
 
template<typename S1, typename S2, typename IT>
 SimdArray (const S1 *array, const S2 S1::*member1, const EntryType S2::*member2, IT indexes, MaskArgument mask)
 
template<typename S1, typename IT1, typename IT2>
 SimdArray (const S1 *array, const EntryType *const S1::*ptrMember1, IT1 outerIndexes, IT2 innerIndexes)
 
template<typename S1, typename IT1, typename IT2>
 SimdArray (const S1 *array, const EntryType *const S1::*ptrMember1, IT1 outerIndexes, IT2 innerIndexes, MaskArgument mask)
 
template<typename S1, typename IT>
void gather (const S1 *array, const EntryType S1::*member1, IT indexes)
 
template<typename S1, typename IT>
void gather (const S1 *array, const EntryType S1::*member1, IT indexes, MaskArgument mask)
 
template<typename S1, typename S2, typename IT>
void gather (const S1 *array, const S2 S1::*member1, const EntryType S2::*member2, IT indexes)
 
template<typename S1, typename S2, typename IT>
void gather (const S1 *array, const S2 S1::*member1, const EntryType S2::*member2, IT indexes, MaskArgument mask)
 
template<typename S1, typename IT1, typename IT2>
void gather (const S1 *array, const EntryType *const S1::*ptrMember1, IT1 outerIndexes, IT2 innerIndexes)
 
template<typename S1, typename IT1, typename IT2>
void gather (const S1 *array, const EntryType *const S1::*ptrMember1, IT1 outerIndexes, IT2 innerIndexes, MaskArgument mask)
 
template<typename S1, typename IT>
void scatter (S1 *array, EntryType S1::*member1, IT indexes) const
 
template<typename S1, typename IT>
void scatter (S1 *array, EntryType S1::*member1, IT indexes, MaskArgument mask) const
 
template<typename S1, typename S2, typename IT>
void scatter (S1 *array, S2 S1::*member1, EntryType S2::*member2, IT indexes) const
 
template<typename S1, typename S2, typename IT>
void scatter (S1 *array, S2 S1::*member1, EntryType S2::*member2, IT indexes, MaskArgument mask) const
 
template<typename S1, typename IT1, typename IT2>
void scatter (S1 *array, EntryType *S1::*ptrMember1, IT1 outerIndexes, IT2 innerIndexes) const
 
template<typename S1, typename IT1, typename IT2>
void scatter (S1 *array, EntryType *S1::*ptrMember1, IT1 outerIndexes, IT2 innerIndexes, MaskArgument mask) const
 
fixed_size_simd< T, N > exponent () const
 Returns the exponents of the floating-point values in the vector.
 
MaskType isNegative () const
 Returns whether a value is negative.
 
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.
 

Scalar Subscript Operators

reference operator[] (size_t i) noexcept
 This operator can be used to modify scalar entries of the vector.
 
value_type operator[] (size_t index) const noexcept
 This operator can be used to read scalar entries of the vector.
 

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.
 
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).
 

Member Typedef Documentation

◆ Mask

template<typename T, size_t N, typename V, size_t Wt>
using Mask = mask_type

The type of the mask used for masked operations and returned from comparisons.

Definition at line 678 of file simdarray.h.

◆ MaskType

template<typename T, size_t N, typename V, size_t Wt>
using MaskType = Mask

The type of the mask used for masked operations and returned from comparisons.

Definition at line 680 of file simdarray.h.

◆ EntryType

template<typename T, size_t N, typename V, size_t Wt>
using EntryType = value_type

The type of the elements (i.e. T)

Definition at line 684 of file simdarray.h.

◆ IndexType

template<typename T, size_t N, typename V, size_t Wt>
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.

Constructor & Destructor Documentation

◆ SimdArray() [1/8]

template<typename T, size_t N, typename V, size_t Wt>
SimdArray ( )
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.

◆ SimdArray() [2/8]

template<typename T, size_t N, typename V, size_t Wt>
SimdArray ( value_type a)
inline

Definition at line 755 of file simdarray.h.

◆ SimdArray() [3/8]

template<typename T, size_t N, typename V, size_t Wt>
template<typename S1, typename IT>
SimdArray ( const S1 * array,
const EntryType S1::* member1,
IT indexes )
inline
Deprecated
Use Vc::array or Vc::vector subscripting instead.
Parameters
arrayA pointer into memory (without alignment restrictions).
member1If array points to a struct, member1 determines the member in the struct to be read. Thus the offsets in indexes are relative to the array and not to the size of the gathered type (i.e. array[i].*member1 is accessed instead of (&(array->*member1))[i])
indexesDetermines the offsets into array where the values are gathered from/scattered to. The type of indexes can either be an integer vector or a type that supports operator[] access.

Definition at line 19 of file simdarray.h.

◆ SimdArray() [4/8]

template<typename T, size_t N, typename V, size_t Wt>
template<typename S1, typename IT>
SimdArray ( const S1 * array,
const EntryType S1::* member1,
IT indexes,
MaskArgument mask )
inline
Deprecated
Use Vc::array or Vc::vector subscripting instead.
Parameters
arrayA pointer into memory (without alignment restrictions).
member1If array points to a struct, member1 determines the member in the struct to be read. Thus the offsets in indexes are relative to the array and not to the size of the gathered type (i.e. array[i].*member1 is accessed instead of (&(array->*member1))[i])
indexesDetermines the offsets into array where the values are gathered from/scattered to. The type of indexes can either be an integer vector or a type that supports operator[] access.
maskIf a mask is given only the active entries will be gathered/scattered.

Definition at line 43 of file simdarray.h.

◆ SimdArray() [5/8]

template<typename T, size_t N, typename V, size_t Wt>
template<typename S1, typename S2, typename IT>
SimdArray ( const S1 * array,
const S2 S1::* member1,
const EntryType S2::* member2,
IT indexes )
inline
Deprecated
Use Vc::array or Vc::vector subscripting instead.
Parameters
arrayA pointer into memory (without alignment restrictions).
member1If array points to a struct, member1 determines the member in the struct to be read. Thus the offsets in indexes are relative to the array and not to the size of the gathered type (i.e. array[i].*member1 is accessed instead of (&(array->*member1))[i])
member2If member1 is a struct then member2 selects the member to be read from that struct (i.e. array[i].*member1.*member2 is read).
indexesDetermines the offsets into array where the values are gathered from/scattered to. The type of indexes can either be an integer vector or a type that supports operator[] access.

Definition at line 69 of file simdarray.h.

◆ SimdArray() [6/8]

template<typename T, size_t N, typename V, size_t Wt>
template<typename S1, typename S2, typename IT>
SimdArray ( const S1 * array,
const S2 S1::* member1,
const EntryType S2::* member2,
IT indexes,
MaskArgument mask )
inline
Deprecated
Use Vc::array or Vc::vector subscripting instead.
Parameters
arrayA pointer into memory (without alignment restrictions).
member1If array points to a struct, member1 determines the member in the struct to be read. Thus the offsets in indexes are relative to the array and not to the size of the gathered type (i.e. array[i].*member1 is accessed instead of (&(array->*member1))[i])
member2If member1 is a struct then member2 selects the member to be read from that struct (i.e. array[i].*member1.*member2 is read).
indexesDetermines the offsets into array where the values are gathered from/scattered to. The type of indexes can either be an integer vector or a type that supports operator[] access.
maskIf a mask is given only the active entries will be gathered/scattered.

Definition at line 96 of file simdarray.h.

◆ SimdArray() [7/8]

template<typename T, size_t N, typename V, size_t Wt>
template<typename S1, typename IT1, typename IT2>
SimdArray ( const S1 * array,
const EntryType *const S1::* ptrMember1,
IT1 outerIndexes,
IT2 innerIndexes )
inline
Deprecated
Use Vc::array or Vc::vector subscripting instead.
Parameters
arrayA pointer into memory (without alignment restrictions).
ptrMember1If array points to a struct, member1 determines the member in the struct to be read. Thus the offsets in indexes are relative to the array and not to the size of the gathered type (i.e. array[i].*member1 is accessed instead of (&(array->*member1))[i])
outerIndexes
innerIndexes

Definition at line 121 of file simdarray.h.

◆ SimdArray() [8/8]

template<typename T, size_t N, typename V, size_t Wt>
template<typename S1, typename IT1, typename IT2>
SimdArray ( const S1 * array,
const EntryType *const S1::* ptrMember1,
IT1 outerIndexes,
IT2 innerIndexes,
MaskArgument mask )
inline
Deprecated
Use Vc::array or Vc::vector subscripting instead.
Parameters
arrayA pointer into memory (without alignment restrictions).
ptrMember1If array points to a struct, member1 determines the member in the struct to be read. Thus the offsets in indexes are relative to the array and not to the size of the gathered type (i.e. array[i].*member1 is accessed instead of (&(array->*member1))[i])
outerIndexes
innerIndexes
maskIf a mask is given only the active entries will be gathered/scattered.

Definition at line 145 of file simdarray.h.

Member Function Documentation

◆ size()

template<typename T, size_t N, typename V, size_t Wt>
static constexpr std::size_t size ( )
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.

Returns
The number of scalar values stored and manipulated concurrently by objects of this type.

Definition at line 675 of file simdarray.h.

◆ Random()

template<typename T, size_t N, typename V, size_t Wt>
static fixed_size_simd< T, N > Random ( )
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.

Returns
a new random vector. Floating-point values will be in the 0-1 range. Integers will use the full range the integer representation allows.
Note
This function may use a very small amount of state and thus will be a weak random number generator.

Definition at line 719 of file simdarray.h.

◆ gather() [1/6]

template<typename T, size_t N, typename V, size_t Wt>
template<typename S1, typename IT>
void gather ( const S1 * array,
const EntryType S1::* member1,
IT indexes )
inline
Deprecated
Use Vc::array or Vc::vector subscripting instead.
Parameters
arrayA pointer into memory (without alignment restrictions).
member1If array points to a struct, member1 determines the member in the struct to be read. Thus the offsets in indexes are relative to the array and not to the size of the gathered type (i.e. array[i].*member1 is accessed instead of (&(array->*member1))[i])
indexesDetermines the offsets into array where the values are gathered from/scattered to. The type of indexes can either be an integer vector or a type that supports operator[] access.

Definition at line 170 of file simdarray.h.

◆ gather() [2/6]

template<typename T, size_t N, typename V, size_t Wt>
template<typename S1, typename IT>
void gather ( const S1 * array,
const EntryType S1::* member1,
IT indexes,
MaskArgument mask )
inline
Deprecated
Use Vc::array or Vc::vector subscripting instead.
Parameters
arrayA pointer into memory (without alignment restrictions).
member1If array points to a struct, member1 determines the member in the struct to be read. Thus the offsets in indexes are relative to the array and not to the size of the gathered type (i.e. array[i].*member1 is accessed instead of (&(array->*member1))[i])
indexesDetermines the offsets into array where the values are gathered from/scattered to. The type of indexes can either be an integer vector or a type that supports operator[] access.
maskIf a mask is given only the active entries will be gathered/scattered.

Definition at line 193 of file simdarray.h.

◆ gather() [3/6]

template<typename T, size_t N, typename V, size_t Wt>
template<typename S1, typename S2, typename IT>
void gather ( const S1 * array,
const S2 S1::* member1,
const EntryType S2::* member2,
IT indexes )
inline
Deprecated
Use Vc::array or Vc::vector subscripting instead.
Parameters
arrayA pointer into memory (without alignment restrictions).
member1If array points to a struct, member1 determines the member in the struct to be read. Thus the offsets in indexes are relative to the array and not to the size of the gathered type (i.e. array[i].*member1 is accessed instead of (&(array->*member1))[i])
member2If member1 is a struct then member2 selects the member to be read from that struct (i.e. array[i].*member1.*member2 is read).
indexesDetermines the offsets into array where the values are gathered from/scattered to. The type of indexes can either be an integer vector or a type that supports operator[] access.

Definition at line 220 of file simdarray.h.

◆ gather() [4/6]

template<typename T, size_t N, typename V, size_t Wt>
template<typename S1, typename S2, typename IT>
void gather ( const S1 * array,
const S2 S1::* member1,
const EntryType S2::* member2,
IT indexes,
MaskArgument mask )
inline
Deprecated
Use Vc::array or Vc::vector subscripting instead.
Parameters
arrayA pointer into memory (without alignment restrictions).
member1If array points to a struct, member1 determines the member in the struct to be read. Thus the offsets in indexes are relative to the array and not to the size of the gathered type (i.e. array[i].*member1 is accessed instead of (&(array->*member1))[i])
member2If member1 is a struct then member2 selects the member to be read from that struct (i.e. array[i].*member1.*member2 is read).
indexesDetermines the offsets into array where the values are gathered from/scattered to. The type of indexes can either be an integer vector or a type that supports operator[] access.
maskIf a mask is given only the active entries will be gathered/scattered.

Definition at line 245 of file simdarray.h.

◆ gather() [5/6]

template<typename T, size_t N, typename V, size_t Wt>
template<typename S1, typename IT1, typename IT2>
void gather ( const S1 * array,
const EntryType *const S1::* ptrMember1,
IT1 outerIndexes,
IT2 innerIndexes )
inline
Deprecated
Use Vc::array or Vc::vector subscripting instead.
Parameters
arrayA pointer into memory (without alignment restrictions).
ptrMember1If array points to a struct, member1 determines the member in the struct to be read. Thus the offsets in indexes are relative to the array and not to the size of the gathered type (i.e. array[i].*member1 is accessed instead of (&(array->*member1))[i])
outerIndexes
innerIndexes

Definition at line 268 of file simdarray.h.

◆ gather() [6/6]

template<typename T, size_t N, typename V, size_t Wt>
template<typename S1, typename IT1, typename IT2>
void gather ( const S1 * array,
const EntryType *const S1::* ptrMember1,
IT1 outerIndexes,
IT2 innerIndexes,
MaskArgument mask )
inline
Deprecated
Use Vc::array or Vc::vector subscripting instead.
Parameters
arrayA pointer into memory (without alignment restrictions).
ptrMember1If array points to a struct, member1 determines the member in the struct to be read. Thus the offsets in indexes are relative to the array and not to the size of the gathered type (i.e. array[i].*member1 is accessed instead of (&(array->*member1))[i])
outerIndexes
innerIndexes
maskIf a mask is given only the active entries will be gathered/scattered.

Definition at line 291 of file simdarray.h.

◆ scatter() [1/6]

template<typename T, size_t N, typename V, size_t Wt>
template<typename S1, typename IT>
void scatter ( S1 * array,
EntryType S1::* member1,
IT indexes ) const
inline
Deprecated
Use Vc::array or Vc::vector subscripting instead.
Parameters
arrayA pointer into memory (without alignment restrictions).
member1If array points to a struct, member1 determines the member in the struct to be read. Thus the offsets in indexes are relative to the array and not to the size of the gathered type (i.e. array[i].*member1 is accessed instead of (&(array->*member1))[i])
indexesDetermines the offsets into array where the values are gathered from/scattered to. The type of indexes can either be an integer vector or a type that supports operator[] access.

Definition at line 19 of file simdarray.h.

◆ scatter() [2/6]

template<typename T, size_t N, typename V, size_t Wt>
template<typename S1, typename IT>
void scatter ( S1 * array,
EntryType S1::* member1,
IT indexes,
MaskArgument mask ) const
inline
Deprecated
Use Vc::array or Vc::vector subscripting instead.
Parameters
arrayA pointer into memory (without alignment restrictions).
member1If array points to a struct, member1 determines the member in the struct to be read. Thus the offsets in indexes are relative to the array and not to the size of the gathered type (i.e. array[i].*member1 is accessed instead of (&(array->*member1))[i])
indexesDetermines the offsets into array where the values are gathered from/scattered to. The type of indexes can either be an integer vector or a type that supports operator[] access.
maskIf a mask is given only the active entries will be gathered/scattered.

Definition at line 42 of file simdarray.h.

◆ scatter() [3/6]

template<typename T, size_t N, typename V, size_t Wt>
template<typename S1, typename S2, typename IT>
void scatter ( S1 * array,
S2 S1::* member1,
EntryType S2::* member2,
IT indexes ) const
inline
Deprecated
Use Vc::array or Vc::vector subscripting instead.
Parameters
arrayA pointer into memory (without alignment restrictions).
member1If array points to a struct, member1 determines the member in the struct to be read. Thus the offsets in indexes are relative to the array and not to the size of the gathered type (i.e. array[i].*member1 is accessed instead of (&(array->*member1))[i])
member2If member1 is a struct then member2 selects the member to be read from that struct (i.e. array[i].*member1.*member2 is read).
indexesDetermines the offsets into array where the values are gathered from/scattered to. The type of indexes can either be an integer vector or a type that supports operator[] access.

Definition at line 67 of file simdarray.h.

◆ scatter() [4/6]

template<typename T, size_t N, typename V, size_t Wt>
template<typename S1, typename S2, typename IT>
void scatter ( S1 * array,
S2 S1::* member1,
EntryType S2::* member2,
IT indexes,
MaskArgument mask ) const
inline
Deprecated
Use Vc::array or Vc::vector subscripting instead.
Parameters
arrayA pointer into memory (without alignment restrictions).
member1If array points to a struct, member1 determines the member in the struct to be read. Thus the offsets in indexes are relative to the array and not to the size of the gathered type (i.e. array[i].*member1 is accessed instead of (&(array->*member1))[i])
member2If member1 is a struct then member2 selects the member to be read from that struct (i.e. array[i].*member1.*member2 is read).
indexesDetermines the offsets into array where the values are gathered from/scattered to. The type of indexes can either be an integer vector or a type that supports operator[] access.
maskIf a mask is given only the active entries will be gathered/scattered.

Definition at line 93 of file simdarray.h.

◆ scatter() [5/6]

template<typename T, size_t N, typename V, size_t Wt>
template<typename S1, typename IT1, typename IT2>
void scatter ( S1 * array,
EntryType *S1::* ptrMember1,
IT1 outerIndexes,
IT2 innerIndexes ) const
inline
Deprecated
Use Vc::array or Vc::vector subscripting instead.
Parameters
arrayA pointer into memory (without alignment restrictions).
ptrMember1If array points to a struct, member1 determines the member in the struct to be read. Thus the offsets in indexes are relative to the array and not to the size of the gathered type (i.e. array[i].*member1 is accessed instead of (&(array->*member1))[i])
outerIndexes
innerIndexes

Definition at line 116 of file simdarray.h.

◆ scatter() [6/6]

template<typename T, size_t N, typename V, size_t Wt>
template<typename S1, typename IT1, typename IT2>
void scatter ( S1 * array,
EntryType *S1::* ptrMember1,
IT1 outerIndexes,
IT2 innerIndexes,
MaskArgument mask ) const
inline
Deprecated
Use Vc::array or Vc::vector subscripting instead.
Parameters
arrayA pointer into memory (without alignment restrictions).
ptrMember1If array points to a struct, member1 determines the member in the struct to be read. Thus the offsets in indexes are relative to the array and not to the size of the gathered type (i.e. array[i].*member1 is accessed instead of (&(array->*member1))[i])
outerIndexes
innerIndexes
maskIf a mask is given only the active entries will be gathered/scattered.

Definition at line 139 of file simdarray.h.

◆ operator[]() [1/2]

template<typename T, size_t N, typename V, size_t Wt>
reference operator[] ( size_t i)
inlinenoexcept

This operator can be used to modify scalar entries of the vector.

Parameters
indexA value between 0 and Size. This value is not checked internally so you must make/be sure it is in range.
Returns
a reference to the vector entry at the given index.
Warning
The use of this function may result in suboptimal performance. Please check whether you can find a more vector-friendly way to do what you intended.
Note
the returned object models the concept of a reference and as such it can exist longer than the data it is referencing.
to avoid lifetime issues, we strongly advice not to store any reference objects.
the returned object models the concept of a reference and as such it can exist longer than the data it is referencing.
to avoid lifetime issues, we strongly advice not to store any reference objects.

Definition at line 1035 of file simdarray.h.

◆ operator[]() [2/2]

template<typename T, size_t N, typename V, size_t Wt>
value_type operator[] ( size_t index) const
inlinenoexcept

This operator can be used to read scalar entries of the vector.

Parameters
indexA value between 0 and Size. This value is not checked internally so you must make/be sure it is in range.
Returns
a copy of the vector entry at the given index.

Definition at line 1042 of file simdarray.h.

◆ operator()()

template<typename T, size_t N, typename V, size_t Wt>
Common::WriteMaskedVector< SimdArray, mask_type > operator() ( const mask_type & mask)
inline

Definition at line 1050 of file simdarray.h.

◆ sorted()

template<typename T, size_t N, typename V, size_t Wt>
fixed_size_simd< T, N > sorted ( ) const
inline

Return a sorted copy of the vector.

Returns
a sorted vector. The returned values are in ascending order:
v[0] <= v[1] <= v[2] <= v[3] ...
Note
If the vector contains NaNs the result is undefined.

Example:

int_v s = v.sorted();
std::cout << v << '\n' << s << '\n';
static Vector Random()
Vector sorted() const
Return a sorted copy of the vector.
Vector< int > int_v
vector of signed integers
Definition vector.h:56

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.

◆ exponent()

template<typename T, size_t N, typename V, size_t Wt>
fixed_size_simd< T, N > exponent ( ) const
inline

Returns the exponents of the floating-point values in the vector.

Returns
A new vector object of the same type containing the exponents.
Deprecated
use Vc::exponent instead.

Definition at line 1432 of file simdarray.h.

◆ isNegative()

template<typename T, size_t N, typename V, size_t Wt>
MaskType isNegative ( ) const
inline

Returns whether a value is negative.

Returns
A new mask object indicating the sign of each vector element.
Deprecated
use Vc::isnegative instead.

Definition at line 1438 of file simdarray.h.

◆ copySign()

template<typename T, size_t N, typename V, size_t Wt>
fixed_size_simd< T, N > copySign ( const SimdArray< T, N, V, Wt > & x) const
inline

Copies the signs of the components of reference to the components of the current vector, returning the result.

Parameters
referenceA vector object that determines the sign of the the result.
Returns
A new vector with sign taken from reference and absolute value taken from the current vector object.
Deprecated
Use Vc::copysign instead.

Definition at line 1445 of file simdarray.h.

Member Data Documentation

◆ MemoryAlignment

template<typename T, size_t N, typename V, size_t Wt>
std::size_t MemoryAlignment
staticconstexpr
Initial value:
=
storage_type0::MemoryAlignment > storage_type1::MemoryAlignment
? storage_type0::MemoryAlignment
: storage_type1::MemoryAlignment

Specifies the alignment requirement for aligned load and store calls for objects of this vector type.

Definition at line 692 of file simdarray.h.

◆ Size

template<typename T, size_t N, typename V, size_t Wt>
std::size_t Size = size()
staticconstexpr

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.

Returns
The number of scalar values stored and manipulated concurrently by objects of this type.
Deprecated
Use size() instead.

Definition at line 1428 of file simdarray.h.


The documentation for this class was generated from the following files: