SIMD
The SIMD types provide accelerated numerical types for high-performance computations. They support SSE1, SSE2, SSE3, SSE4, AVX1, AVX2, NEON, and compatibility modes, selectable via preprocessor definitions. SIMD types can be used independently or as underlying storage for other containers, enabling efficient SOA-style algorithms.
All types support flexible initialization from scalars, arrays, or other vectors, and offer component-wise access, swizzling, and reordering for advanced manipulation. In addition to core arithmetic and logical operations, the SIMD vector types provide a rich set of utility functions for common vector math tasks. Many of these functions are implemented using platform-specific intrinsics to maximize performance, while falling back to scalar code when necessary to ensure consistent behavior across platforms.
By default, compatibility mode is used. It remains effective as modern compilers can autovectorize these layouts.
#include <math/TellusimSimd.h>
SIMD Types
Available SIMD vector types:
int16x8_t
- the vector of eight 16-bit signed integersint32x4_t
- the vector of four 32-bit signed integersint32x8_t
- the vector of eight 32-bit signed integersuint16x8_t
- the vector of eight 16-bit unsigned integersuint32x4_t
- the vector of four 32-bit unsigned integersuint32x8_t
- the vector of eight 32-bit unsigned integersfloat16x4_t
- the vector of four 16-bit floating-point numbersfloat16x8_t
- the vector of eight 16-bit floating-point numbersfloat32x4_t
- the vector of four 32-bit floating-point numbersfloat32x8_t
- the vector of eight 32-bit floating-point numbersfloat64x2_t
- the vector of two 64-bit floating-point numbersfloat64x4_t
- the vector of four 64-bit floating-point numbersfloat64x8_t
- the vector of eight 64-bit floating-point numbers
SIMD Modes
Selectable SIMD instruction modes:
TS_SSE=1
- enable SSE1 modeTS_SSE=2
- enable SSE2 modeTS_SSE=3
- enable SSE3 modeTS_SSE=4
- enable SSE4 modeTS_AVX=1
- enable AVX1 modeTS_AVX=2
- enable AVX2 modeTS_NEON=1
- enable NEON mode
Example
The following example demonstrates a Structure of Arrays SOA-style calculation using the Vector4 type, where each component is a SIMD vector:
using Vector4x4f = Vector4<float32x4_t>;
Vector4x4f a = Vector4x4f(float32x4_t(1.0f, 2.0f, 3.0f, 4.0f));
Vector4x4f b = Vector4x4f(float32x4_t(1.0f), float32x4_t(2.0f), float32x4_t(3.0f), float32x4_t(4.0f));
Vector4x4f c = a + normalize(b * float32x4_t(2.0f, 3.0f, 4.0f, 5.0f));
x: 1.182574 2.182574 3.182574 4.182574
y: 1.365148 2.365148 3.365148 4.365149
z: 1.547723 2.547723 3.547723 4.547723
w: 1.730297 2.730297 3.730297 4.730297