◆ aligned_store()

template<typename Value , typename Pointer , typename Offset , typename Mask >
void boost::simd::aligned_store ( Value const &  val,
Pointer const &  ptr,
Offset const &  offset,
Mask const &  mask 
)

Store a value at an aligned memory location.

Store a given value into an aligned memory location referenced by either a pointer or a pointer and an offset. To support SIMD idioms like data scattering or non-POD values, both Pointer and Offset arguments can themselves be SIMD register or Fusion Sequences.

Header <boost/simd/function/aligned_store.hpp>
Semantic:

Depending on the type of its arguments, store exhibits different semantics. For any x of type Value, ptr of type Pointer, offset of type Offset and mask of type Mask, consider:

aligned_store(x,ptr,offset,mask);

If x is a SIMD value, this code is equivalent to:

  • If offset is a scalar integer:
for(int i=0;i<Value::static_size;++i)
if mask[i]
*(ptr+offset+i) = x[i];
  • If offset is a SIMD integral register:
for(int i=0;i<Value::static_size;++i)
if mask[i]
*(ptr+offset[i]) = x[i];

In this case, the store operation is equivalent to a scatter operation.

If x and ptr are Fusion Sequences of size N, this code is equivalent to:

aligned_storeat_c<0>(x),at_c<0>(ptr),offset);
...
aligned_storeat_c<N-1>(x),at_c<N-1>(ptr),offset);

If x is a scalar value, this code is equivalent to:

if (mask)
*(ptr+offset) = x;
Precondition

If Type is a SIMD register type:

is_aligned( ptr + offset - Misalignment )

evaluates to true

Parameters
valValue to store
ptrMemory location to store val to
offsetOptional memory offset.
maskOptional logical mask. Only stores values for which the mask is true.