Signet Forge 0.1.0
C++20 Parquet library with AI-native extensions
DEMO
Loading...
Searching...
No Matches
signet::forge::simd Namespace Reference

Platform-optimized SIMD routines for common vector operations. More...

Functions

float dot_product (const float *a, const float *b, size_t n) noexcept
 Compute the dot product (inner product) of two float vectors.
 
float l2_distance_sq (const float *a, const float *b, size_t n) noexcept
 Compute the squared L2 (Euclidean) distance between two float vectors.
 
float sum_of_squares (const float *data, size_t n) noexcept
 Compute the sum of squares of a float vector.
 
void l2_normalize (float *data, size_t n) noexcept
 L2-normalize a float vector in-place (divide each element by the L2 norm).
 
void copy_floats (float *dst, const float *src, size_t n) noexcept
 Fast copy of n floats from src to dst.
 

Detailed Description

Platform-optimized SIMD routines for common vector operations.

Compile-time dispatch: AVX2 → 8-wide float (256-bit) using mm256* SSE4_2 / SSE2 → 4-wide float (128-bit) using mm* __ARM_NEON → 4-wide float (128-bit) using NEON intrinsics fallback → scalar loop

All functions accept unaligned pointers and handle tail elements correctly.

Function Documentation

◆ copy_floats()

void signet::forge::simd::copy_floats ( float *  dst,
const float *  src,
size_t  n 
)
inlinenoexcept

Fast copy of n floats from src to dst.

Uses SIMD stores/loads when available for bandwidth. Handles unaligned pointers and non-multiple-of-SIMD-width sizes correctly.

Parameters
dstDestination (n floats).
srcSource (n floats).
nNumber of floats to copy.

Definition at line 736 of file vector_type.hpp.

◆ dot_product()

float signet::forge::simd::dot_product ( const float *  a,
const float *  b,
size_t  n 
)
inlinenoexcept

Compute the dot product (inner product) of two float vectors.

Parameters
aFirst vector (n elements).
bSecond vector (n elements).
nNumber of elements.
Returns
sum(a[i] * b[i]) for i in [0, n).

Definition at line 509 of file vector_type.hpp.

◆ l2_distance_sq()

float signet::forge::simd::l2_distance_sq ( const float *  a,
const float *  b,
size_t  n 
)
inlinenoexcept

Compute the squared L2 (Euclidean) distance between two float vectors.

Parameters
aFirst vector (n elements).
bSecond vector (n elements).
nNumber of elements.
Returns
sum((a[i] - b[i])^2) for i in [0, n).

Definition at line 572 of file vector_type.hpp.

◆ l2_normalize()

void signet::forge::simd::l2_normalize ( float *  data,
size_t  n 
)
inlinenoexcept

L2-normalize a float vector in-place (divide each element by the L2 norm).

If the vector has zero norm (all zeros), it is left unchanged.

Parameters
dataVector to normalize (n elements, modified in-place).
nNumber of elements.

Definition at line 690 of file vector_type.hpp.

◆ sum_of_squares()

float signet::forge::simd::sum_of_squares ( const float *  data,
size_t  n 
)
inlinenoexcept

Compute the sum of squares of a float vector.

Parameters
dataInput vector (n elements).
nNumber of elements.
Returns
sum(data[i]^2) for i in [0, n).

Definition at line 634 of file vector_type.hpp.