Expand description
Low-level SIMD operations trait implemented per architecture and primitive type.
§Extension Surface (v2+)
New in this iteration:
sub(a, b)— elementwise subtraction, required forSubElementOp strategy.mask_from_bitmask(bm)— convertBitMask<LANE_COUNT>to native mask; default callsmask_from_boolsviaBitMask::to_bools(). AVX-512 impls override with direct cast.zero()— returns a vector of zeros; default implementation usessplat(T::ZERO). Backends may override with an architecture-specific XOR-zero idiom if profiling shows benefit.
§Extension Surface (v2)
Beyond the base load/store/arithmetic/reduce methods, SimdKernel now exposes:
-
Masked operations (
masked_load_unaligned,masked_store_unaligned,masked_add,masked_mul,masked_fmadd,masked_sum_reduce) — predicated arithmetic using hardware mask registers. Thesrcparameter follows AVX-512 merge-masking semantics: lanes wheremask[i] = 0are taken fromsrc. -
Compress / expand — scatter/gather from/to contiguous storage:
compress: packs selected lanes (mask[i]=1) to low lanes of result.expand: scatters low lanes ofsrcto positions wheremask[i]=1.
-
Gather (
gather,gather_masked) — indirect indexed load from a base pointer. -
Mask construction (
mask_from_bools,leading_k_mask) — build masks from boolean arrays or lane counts for tail handling.
§Architecture Mapping
| Method | AVX-512 | AVX2 | NEON | Scalar |
|---|---|---|---|---|
masked_add | _mm512_mask_add_ps | _mm256_blendv_ps(src,add,mask) | vbslq_f32 | loop+if |
compress | _mm512_mask_compressstoreu_ps | emulated | emulated | loop+if |
gather | _mm512_i32gather_ps | _mm256_i32gather_ps | emulated | loop |
Constants§
- MAX_
SIMD_ LANES - Lane capacity of the fixed scalar-fallback stack buffers used by the default
SimdKernelmethods (scan_vector,swap_adjacent,dup_even/dup_odd, and thekernel_helpersscalar emulations). A backend’sSimdKernel::LANE_COUNTmust not exceed this, orstore_unalignedinto those buffers would overflow the stack. The current workspace maximum is 64 (AVX-512i8, 64×i8); the bound is checked at compile time bySimdKernel::LANE_BOUND_CHECK, so a future wider backend fails to build rather than silently overflowing the stack.
Traits§
- Simd
Kernel - Abstract trait defining low-level vector operations.