Skip to main content

UNROLL

Constant UNROLL 

Source
pub const UNROLL: usize = 4;
Expand description

Independent accumulators carried through the vectorised loops.

Both add and fma have roughly four cycles of latency against a two-per-cycle issue rate, and the argmin’s compare-and-blend chain has the same shape. A single accumulator serialises on that latency and leaves most of the issue width idle regardless of vector width. Four covers it; more only lengthens the final cross-accumulator fold.

Indicative, from an A/B of argmin_diff_simd_f32 on one aarch64 machine: 1.4x at len 200 rising to 2.9x by len 16384, the gain growing with length because the fixed fold cost amortises. Retune by flipping this constant and timing the same call, not by reasoning about the number.