T-SIMD v31.1.0
A C++ template SIMD library
Loading...
Searching...
No Matches
Swizzling

Description

Swizzle/deinterleave functions on Vec's.

Functions

template<size_t N, typename T , size_t SIMD_WIDTH>
static void simd::swizzle (Vec< T, SIMD_WIDTH > v[N])
 Swizzle/de-interleave/convert from AoS to SoA multiple Vec's in-place.
 
template<size_t N, typename T , size_t SIMD_WIDTH>
static void simd::swizzle2 (Vec< T, SIMD_WIDTH > v[2 *N])
 Swizzle/de-interleave/convert from AoS to SoA multiple Vec's in-place.
 
template<size_t N, typename T , size_t SIMD_WIDTH>
static void simd::unswizzle (Vec< T, SIMD_WIDTH > v[2 *N])
 Unswizzle/interleave/convert from SoA to AoS multiple Vec's in-place.
 

Function Documentation

◆ swizzle()

template<size_t N, typename T , size_t SIMD_WIDTH>
static void simd::swizzle ( Vec< T, SIMD_WIDTH > v[N])
inlinestatic

Swizzle/de-interleave/convert from AoS to SoA multiple Vec's in-place.

This function swizzles/de-interleaves/converts from AoS (Array of Structs) to SoA (Struct of Arrays) multiple Vec's in-place.

Example:

Example for a swizzle distance of 3 with 3 Vec's of 8 elements each:

input stream (structures indicated by curly brackets):

{0 1 2} {3 4 5} {6 7 8} {9 10 11} ... {21 22 23}

input vectors:

v[0] = 0 1 2 3 4 5 6 7
v[1] = 8 9 10 11 12 13 14 15
v[2] = 16 17 18 19 20 21 22 23

output vectors:

v[0] = 0 3 6 9 12 15 18 21
v[1] = 1 4 7 10 13 16 19 22
v[2] = 2 5 8 11 14 17 20 23
Template Parameters
Nswizzle distance, must be between 1 and 5
Parameters
[in,out]varray of Vec's to swizzle
See also
swizzle2(): swizzle function that takes double the number of Vec's with potentially better performance
unswizzle()

◆ swizzle2()

template<size_t N, typename T , size_t SIMD_WIDTH>
static void simd::swizzle2 ( Vec< T, SIMD_WIDTH > v[2 *N])
inlinestatic

Swizzle/de-interleave/convert from AoS to SoA multiple Vec's in-place.

This function swizzles/de-interleaves/converts from AoS (Array of Structs) to SoA (Struct of Arrays) multiple Vec's in-place.

In contrast to swizzle(), this function takes double the number of Vec's as input and might be faster.

Example:

Example for a swizzle distance of 3 with 6 Vec's of 8 elements each:

input stream (structures indicated by curly brackets):

{0 1 2} {3 4 5} {6 7 8} {9 10 11} ... {45 46 47}

input vectors:

v[0] = 0 1 2 3 4 5 6 7
v[1] = 8 9 10 11 12 13 14 15
v[2] = 16 17 18 19 20 21 22 23
v[3] = 24 25 26 27 28 29 30 31
v[4] = 32 33 34 35 36 37 38 39
v[5] = 40 41 42 43 44 45 46 47

output vectors:

v[0] = 0 6 12 18 24 30 36 42
v[1] = 1 7 13 19 25 31 37 43
v[2] = 2 8 14 20 26 32 38 44
v[3] = 3 9 15 21 27 33 39 45
v[4] = 4 10 16 22 28 34 40 46
v[5] = 5 11 17 23 29 35 41 47
Template Parameters
Nswizzle distance, must be between 1 and 5
Parameters
[in,out]varray of Vec's to swizzle
See also
swizzle(): swizzles half the number of Vec's as this function
unswizzle()

◆ unswizzle()

template<size_t N, typename T , size_t SIMD_WIDTH>
static void simd::unswizzle ( Vec< T, SIMD_WIDTH > v[2 *N])
inlinestatic

Unswizzle/interleave/convert from SoA to AoS multiple Vec's in-place.

This function unswizzles/interleaves/converts from SoA (Struct of Arrays) to AoS (Array of Structs) multiple Vec's in-place.

Example:

Example for an unswizzle distance of 3 with 6 Vec's of 8 elements each:

input vectors:

v[0] = 0 6 12 18 24 30 36 42
v[1] = 1 7 13 19 25 31 37 43
v[2] = 2 8 14 20 26 32 38 44
v[3] = 3 9 15 21 27 33 39 45
v[4] = 4 10 16 22 28 34 40 46
v[5] = 5 11 17 23 29 35 41 47

output vectors:

v[0] = 0 1 2 3 4 5 6 7
v[1] = 8 9 10 11 12 13 14 15
v[2] = 16 17 18 19 20 21 22 23
v[3] = 24 25 26 27 28 29 30 31
v[4] = 32 33 34 35 36 37 38 39
v[5] = 40 41 42 43 44 45 46 47
Template Parameters
Nunswizzle distance
Parameters
[in,out]varray of Vec's to unswizzle
See also
swizzle(), swizzle2(): swizzle functions