Skip to main content

Module simd_math

Module simd_math 

Source
Expand description

SIMD-accelerated math kernels for batch vector and particle operations.

This module provides Structure-of-Arrays (SoA) layouts and batch operations optimized for CPU cache locality and auto-vectorization. The batch operations process multiple elements at once, enabling the compiler to emit SIMD instructions on supported platforms.

§Layout

Instead of the traditional Array-of-Structures (AoS) layout:

[x0,y0,z0, x1,y1,z1, x2,y2,z2, ...]

We use Structure-of-Arrays (SoA):

xs: [x0, x1, x2, ...]
ys: [y0, y1, y2, ...]
zs: [z0, z1, z2, ...]

This layout allows the compiler to vectorize operations across contiguous memory, improving throughput for large batches.

Structs§

Vec3Batch
Structure-of-Arrays layout for batch Vec3 operations.

Enums§

SimdMathError
Errors that can occur in SIMD batch operations.

Functions§

accumulate_forces_batch
Accumulate forces onto a mutable force batch.
compute_distances_batch
Compute distances from a single reference point to many positions.
cubic_spline_kernel_batch
Evaluate the cubic spline kernel (M4 kernel) for a batch of distances.