Expand description
Kernel dispatch layer — safe public API + runtime CPU feature detection.
§For application code (safe, no unsafe)
Use only:
axpy—y[i] ^= c * x[i](equal lengths; non-overlapping buffers)scale—y[i] = c * x[i](equal lengths; non-overlapping; usescale_inplacefor in-place)scale_inplace—y[i] = c * y[i]axpy_multi— adaptive blocked/fused multi-source AXPY for encodingdot— GF(2⁸) dot product (GFNI accelerated when available)active_kernel_name— which SIMD tier is active
Length and overlap are asserted in release on the safe wrappers.
Tier modules (x86, arm, wasm) are pub(crate) — not part of the
external API.
§Dispatch
All SIMD variants are compiled in. On the first call to axpy /
scale / scale_inplace (with std), the best tier is selected via
is_x86_feature_detected! and cached in OnceLock<KernelSet>.
§Dispatch priority (x86_64)
| Tier | Runtime check | Width | Instruction |
|---|---|---|---|
| 1 | gfni + avx512f + avx512bw | 512-bit | GF2P8MULB zmm |
| 2 | gfni + avx2 | 256-bit | GF2P8MULB ymm |
| 3 | gfni + sse4.2 | 128-bit | GF2P8MULB xmm |
| 4 | avx512f + avx512bw + ssse3 | 512-bit | vpshufb zmm |
| 5 | avx2 + ssse3 | 256-bit | vpshufb ymm |
| 6 | ssse3 | 128-bit | pshufb xmm |
| 7 | neon (AArch64) | 128-bit | vqtbl1q |
| 8 | wasm simd128 (compile-time) | 128-bit | i8x16_swizzle |
| 9 | scalar (universal fallback) | 1 byte | table lookup |
§no_std targets
OnceLock requires std. Without std, dispatch uses compile-time
#[cfg(target_feature)] selection (bare-metal / embedded).
Functions§
- active_
kernel_ name - Returns the name of the currently active kernel tier.
- axpy
y[i] ^= c * x[i]in GF(2⁸) — the fundamental RLNC primitive.- axpy_
multi - Multi-source fused AXPY with improved cache behaviour:
for each chunk of the destination, apply
y ^= c_i * source_ifor alli. - dot
sum(a[i] * b[i])in GF(2⁸).- scale
y[i] = c * x[i]in GF(2⁸).- scale_
inplace - In-place scale:
y[i] = c * y[i]in GF(2⁸).