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 Types

using StrideType = typename std::conditional< GENERIC, Char, T >::type
 

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
 
T * GetPtr (Int index) const
 

Static Public Attributes

static const Bool SIMD
 
static const Bool GENERIC
 

Private Attributes

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

Member Typedef Documentation

◆ StrideType

using StrideType = typename std::conditional<GENERIC, Char, T>::type

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

◆ GetPtr()

T* GetPtr ( Int  index) const

Member Data Documentation

◆ SIMD

const Bool SIMD
static

◆ GENERIC

const Bool GENERIC
static

◆ _ptr

T* _ptr
private

Pointer to first element.

◆ _size

Int _size
private

Number of elements.

◆ _stride

Int _stride
private

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
private

◆ _logComponentSize

Int _logComponentSize
private