Skip to main content

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.

info

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 integers
  • int32x4_t - the vector of four 32-bit signed integers
  • int32x8_t - the vector of eight 32-bit signed integers
  • uint16x8_t - the vector of eight 16-bit unsigned integers
  • uint32x4_t - the vector of four 32-bit unsigned integers
  • uint32x8_t - the vector of eight 32-bit unsigned integers
  • float16x4_t - the vector of four 16-bit floating-point numbers
  • float16x8_t - the vector of eight 16-bit floating-point numbers
  • float32x4_t - the vector of four 32-bit floating-point numbers
  • float32x8_t - the vector of eight 32-bit floating-point numbers
  • float64x2_t - the vector of two 64-bit floating-point numbers
  • float64x4_t - the vector of four 64-bit floating-point numbers
  • float64x8_t - the vector of eight 64-bit floating-point numbers

SIMD Modes

Selectable SIMD instruction modes:

  • TS_SSE=1 - enable SSE1 mode
  • TS_SSE=2 - enable SSE2 mode
  • TS_SSE=3 - enable SSE3 mode
  • TS_SSE=4 - enable SSE4 mode
  • TS_AVX=1 - enable AVX1 mode
  • TS_AVX=2 - enable AVX2 mode
  • TS_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