Data transfer

From memory:

load()

load values from memory

load_aligned()

load values from aligned memory

load_unaligned()

load values from unaligned memory

load_as()

load values, forcing a type conversion

From a scalar:

broadcast()

broadcasting a value to all slots

broadcast_as()

broadcasting a value, forcing a type conversion

To memory:

store()

store values to memory

store_aligned()

store values to aligned memory

store_unaligned()

store values to unaligned memory

store_as()

store values, forcing a type conversion

In place:

swizzle()

rearrange slots within the batch

slide_left()

bitwise shift the whole batch to the left

slide_right()

bitwise shift the whole batch to the right

rotate_left()

bitwise rotate the whole batch to the left

rotate_right()

bitwise rotate the whole batch to the right

insert()

modify a single batch slot

compress()

pack elements according to a mask

expand()

select contiguous elements from the batch

Between batches:

zip_lo()

interleave low halves of two batches

zip_hi()

interleave high halves of two batches


template <class T, class A = default_arch>
XSIMD_INLINE batch<T, A> xsimd::broadcast(T v)

Creates a batch from the single value v.

Return

a new batch instance

Parameters
  • v: the value used to initialize the batch

template <class To, class A = default_arch, class From>
XSIMD_INLINE simd_return_type<From, To, A> xsimd::broadcast_as(From v)

Creates a batch from the single value v and the specified batch value type To.

Return

a new batch instance

Parameters
  • v: the value used to initialize the batch

template <class T, class A>
XSIMD_INLINE batch<T, A> xsimd::compress(batch< T, A > const & x, batch_bool< T, A > const & mask)

Pick elements from x selected by mask, and append them to the resulting vector, zeroing the remaining slots.

template <class T, class A>
XSIMD_INLINE batch<T, A> xsimd::expand(batch< T, A > const & x, batch_bool< T, A > const & mask)

Load contiguous elements from x and place them in slots selected by mask, zeroing the other slots.

template <class T, class A, size_t I>
XSIMD_INLINE batch<T, A> xsimd::insert(batch< T, A > const & x, T val, index< I > pos)

Create a new batch equivalent to x but with element val set at position pos.

Return

copy of x with position pos set to val

Parameters
  • x: batch

  • val: value to set

  • pos: index of the updated slot

template <class To, class A = default_arch, class From>
XSIMD_INLINE simd_return_type<From, To, A> xsimd::load_as(From const * ptr, aligned_mode)

Creates a batch from the buffer ptr and the specifed batch value type To.

The memory needs to be aligned.

Return

a new batch instance

Parameters
  • ptr: the memory buffer to read

template <class To, class A = default_arch, class From>
XSIMD_INLINE simd_return_type<From, To, A> xsimd::load_as(From const * ptr, unaligned_mode)

Creates a batch from the buffer ptr and the specifed batch value type To.

The memory does not need to be aligned.

Return

a new batch instance

Parameters
  • ptr: the memory buffer to read

template <class A = default_arch, class From>
XSIMD_INLINE batch<From, A> xsimd::load(From const * ptr, aligned_mode = {})

Creates a batch from the buffer ptr.

The memory needs to be aligned.

Return

a new batch instance

Parameters
  • ptr: the memory buffer to read

template <class A = default_arch, class From>
XSIMD_INLINE batch<From, A> xsimd::load(From const * ptr, unaligned_mode)

Creates a batch from the buffer ptr.

The memory does not need to be aligned.

Return

a new batch instance

Parameters
  • ptr: the memory buffer to read

template <class A = default_arch, class From>
XSIMD_INLINE batch<From, A> xsimd::load_aligned(From const * ptr)

Creates a batch from the buffer ptr.

The memory needs to be aligned.

Return

a new batch instance

Parameters
  • ptr: the memory buffer to read

template <class A = default_arch, class From>
XSIMD_INLINE batch<From, A> xsimd::load_unaligned(From const * ptr)

Creates a batch from the buffer ptr.

The memory does not need to be aligned.

Return

a new batch instance

Parameters
  • ptr: the memory buffer to read

template <class T, class A, class Vt, Vt… Values>
XSIMD_INLINE std::enable_if<std::is_arithmetic<T>::value, batch<T, A> >::type xsimd::shuffle(batch< T, A > const & x, batch< T, A > const & y, batch_constant< Vt, A, Values... > mask)

Combine elements from x and y according to selector mask.

Return

combined batch

Parameters
  • x: batch

  • y: batch

  • mask: constant batch mask of integer elements of the same size as element of x and y. Each element of the mask index the vector that would be formed by the concatenation of x and y. For instance

    batch_constant<uint32_t, sse2, 0, 4, 3, 7>
    
    Picks x[0], y[0], x[3], y[3]

template <size_t N, class T, class A>
XSIMD_INLINE batch<T, A> xsimd::slide_left(batch< T, A > const & x)

Slide the whole batch to the left by n bytes.

This is different from bitwise_lshift that shifts each batch element to the left.

Return

slided batch.

Template Parameters
  • N: Amount of bytes to slide to the left.

Parameters
  • x: batch of integer values.

template <size_t N, class T, class A>
XSIMD_INLINE batch<T, A> xsimd::slide_right(batch< T, A > const & x)

Slide the whole batch to the right by N bytes.

This is different from bitwise_rshift that shifts each batch element to the right.

Return

slided batch.

Template Parameters
  • N: Amount of bytes to slide to the right.

Parameters
  • x: batch of integer values.

template <class To, class A = default_arch, class From>
XSIMD_INLINE void xsimd::store_as(To * dst, batch< From, A > const & src, aligned_mode)

Copy content of batch src to the buffer dst.

The memory needs to be aligned.

Parameters
  • dst: the memory buffer to write to

  • src: the batch to copy

template <class To, class A = default_arch, class From>
XSIMD_INLINE void xsimd::store_as(To * dst, batch< From, A > const & src, unaligned_mode)

Copy content of batch src to the buffer dst.

The memory does not need to be aligned.

Parameters
  • dst: the memory buffer to write to

  • src: the batch to copy

template <class A, class T>
XSIMD_INLINE void xsimd::store(T * mem, batch< T, A > const & val, aligned_mode = {})

Copy content of batch val to the buffer mem.

The memory does not need to be aligned.

Parameters
  • mem: the memory buffer to write to

  • val: the batch to copy from

template <class A, class T>
XSIMD_INLINE void xsimd::store(T * mem, batch< T, A > const & val, unaligned_mode)

Copy content of batch val to the buffer mem.

The memory does not need to be aligned.

Parameters
  • mem: the memory buffer to write to

  • val: the batch to copy from

template <class A, class T>
XSIMD_INLINE void xsimd::store_aligned(T * mem, batch< T, A > const & val)

Copy content of batch val to the buffer mem.

The memory needs to be aligned.

Parameters
  • mem: the memory buffer to write to

  • val: the batch to copy from

template <class A, class T>
XSIMD_INLINE void xsimd::store_unaligned(T * mem, batch< T, A > const & val)

Copy content of batch val to the buffer mem.

The memory does not need to be aligned.

Parameters
  • mem: the memory buffer to write to

  • val: the batch to copy

template <class T, class A, class Vt, Vt… Values>
XSIMD_INLINE std::enable_if<std::is_arithmetic<T>::value, batch<T, A> >::type xsimd::swizzle(batch< T, A > const & x, batch_constant< Vt, A, Values... > mask)

Rearrange elements from x according to constant mask mask.

Return

swizzled batch

Parameters
  • x: batch

  • mask: constant batch mask of integer elements of the same size as element of x

template <class T, class A, class Vt>
XSIMD_INLINE std::enable_if<std::is_arithmetic<T>::value, batch<T, A> >::type xsimd::swizzle(batch< T, A > const & x, batch< Vt, A > mask)

Rearrange elements from x according to mask mask.

Return

swizzled batch

Parameters
  • x: batch

  • mask: batch mask of integer elements of the same size as element of x

template <class T, class A>
XSIMD_INLINE batch<T, A> xsimd::zip_hi(batch< T, A > const & x, batch< T, A > const & y)

Unpack and interleave data from the HIGH half of batches x and y.

Store the results in the Return value.

Return

a batch of the high part of shuffled values.

Parameters
  • x: a batch of integer or floating point or double precision values.

  • y: a batch of integer or floating point or double precision values.

template <class T, class A>
XSIMD_INLINE batch<T, A> xsimd::zip_lo(batch< T, A > const & x, batch< T, A > const & y)

Unpack and interleave data from the LOW half of batches x and y.

Store the results in the Return value.

Return

a batch of the low part of shuffled values.

Parameters
  • x: a batch of integer or floating point or double precision values.

  • y: a batch of integer or floating point or double precision values.

The following empty types are used for tag dispatching:

struct xsimd::aligned_mode

tag for load and store of aligned memory.

struct xsimd::unaligned_mode

tag for load and store of unaligned memory.