Vector Triple

template<typename VectorT>
class VectorTriple

Class that packs sets of 3 coordinates into a single unit for operations on interleaved or deinterleaved data. The number of coordinates held is determined by the SIMD width. If constructing a SIMD typed VectorTriple from a scalar array, the requisite deinterleave operations are performed in the constructor.

tparam VectorT

(SIMD datatype) or scalar (float or double) type

Public Types

using ScalarT = VectorToScalarT<VectorT>

Maps the input SIMD or scalar datatype onto its corresponding scalar type. For example __mm256 maps to float and double maps to double

Public Functions

VectorTriple() = default

we allow a default constructor

inline VectorTriple(const VectorT a, const VectorT b, const VectorT c)

Construct from three pre-existing VectorT vector types.

Parameters
  • a – data to load into the x SIMD or scalar register

  • b – data to load into the y SIMD or scalar register

  • c – data to load into the z SIMD or scalar register

inline explicit VectorTriple(const ScalarT *source)

construct by loading from an array of ScalarT eg float* or double * with an automatic deinterleave being applied.

Parameters

source – scalar array to load from

inline void load(const ScalarT *source)

refresh the VectorTriple by loading from an array of ScalarT eg float* or double * with an automatic deinterleave being applied. Equivalent operations to the scalar constructor are performed.

Parameters

source – scalar array to load from

template<unsigned char stride = 1>
inline void idxload(const ScalarT *source, const std::size_t *idxs)

construct by loading discontiguously from an array of ScalarT eg float* or double* using the indices in idxs

Template Parameters

stride – the stride at which to use the indices, take every nth index

Parameters
  • source – scalar array to load from

  • idxs – indices to the coordinate array

template<bool streaming = false>
inline void store(ScalarT *target)

construct by loading discontiguously from an array of ScalarT eg float* or double* using the indices in idxs

Template Parameters

allow – streaming if true, otherwise use store instructions

Parameters

target – scalar array to store/stream to

inline VectorTriple<VectorT> deinterleave()

deinterleave the values in the x, y and z SIMD or scalar registers. WARNING this should only be used if you know the that x, y and z are in deinterleaved form, ie x=xyzxyzxyz...

inline void debugprint(const char *nm)

print the values in SIMD or scalar register x, y and z.

Public Members

VectorT x

SIMD or scalar type that contains x coordinates

VectorT y

SIMD or scalar type that contains y coordinates

VectorT z

SIMD or scalar type that contains z coordinates

Public Static Attributes

static constexpr std::size_t n_scalars = ValuesPerPack<VectorT> * 3

number of scalar values in the packed into the whole 3 x VectorT class