SimdBlock< T > Class Template Reference

#include <datatype.h>

Detailed Description

template<typename T>
class maxon::SimdBlock< T >

A SimdBlock represents a block of memory which is organized as an array of struct of arrays (AOSOA). For example a normal Block<Vector> is layouted internally as xyzxyzxyzxyz (an array of structures, AOS). If you want to make use of SIMD, it is important to build groups of the x-, y- and z-components. Often this is done by making a structure of arrays (SOA), which for the example means having a structure of an x-array holding all x-components, a y-array and a z-array. But you can combine both to an array of struct of arrays (AOSOA): Only as many components are grouped to a fixed-size array as fit into one SIMD value, and then these small arrays are combined to a struct. This yields (in the case of four components per SIMD value) a memory layout xxxxyyyyzzzzxxxxyyyyzzzz which provides better cache locality than a simple structure of arrays.

Public Member Functions

T & operator[] (Int index) const
const StridedBlock< T > & ToBlock () const
StridedBlock< T > & ToBlock ()
T * GetFirst () const
Int GetCount () const
Int GetStride () const
Int GetComponentStride () const
Int GetMultiplicityMask () const
Int GetAlignmentMask () const
Int GetExtraStride () const
void ResetSimdIndexing ()
void SetSimdIndexing (const SimdInfo::Compact &simd, Int logComponentSize)
const SimdInfo::CompactGetInfo () const

Static Public Attributes

static const Bool SIMD

Private Attributes

T * _ptr
Int _size
Int _stride
SimdInfo::Compact _simd
Int _logComponentSize

Member Function Documentation

◆ operator[]()

T& operator[] ( Int  index) const

◆ ToBlock() [1/2]

const StridedBlock<T>& ToBlock ( ) const

◆ ToBlock() [2/2]

StridedBlock<T>& ToBlock ( )

◆ GetFirst()

T* GetFirst ( ) const

◆ GetCount()

Int GetCount ( ) const

◆ GetStride()

Int GetStride ( ) const

◆ GetComponentStride()

Int GetComponentStride ( ) const

◆ GetMultiplicityMask()

Int GetMultiplicityMask ( ) const

◆ GetAlignmentMask()

Int GetAlignmentMask ( ) const

◆ GetExtraStride()

Int GetExtraStride ( ) const

◆ ResetSimdIndexing()

void ResetSimdIndexing ( )

◆ SetSimdIndexing()

void SetSimdIndexing ( const SimdInfo::Compact simd,
Int  logComponentSize 

◆ GetInfo()

const SimdInfo::Compact& GetInfo ( ) const

Member Data Documentation


const Bool SIMD

◆ _ptr

T* _ptr

Pointer to first element.

◆ _size

Int _size

Number of elements.

◆ _stride

Int _stride

Stride in bytes between elements. In the SIMD case, this is the size of a hypothetical non-SIMD vector (having dimension components). E.g., 24 for a double precision Vec3.

◆ _simd

SimdInfo::Compact _simd

◆ _logComponentSize

Int _logComponentSize