Skip to main content

Module reference

Module reference 

Source
Expand description

CPU reference microkernels — one per KernelClass.

These serve two roles at once (plan §3 + §5 step 4):

  1. The panel’s CPU measurement — each is the representative microkernel timed to give the CPU’s per-class throughput row.
  2. The correctness reference — any GPU/NPU/vendor kernel for a class must match its CPU reference within the class tolerance before it may be the default. “A faster wrong answer is a regression.”

They are plain, correct, scalar/rayon implementations over caller-owned slices. The CPU path is always present and never hard-fails (plan §7).

Functions§

allpairs_potential
AllPairs: total pairwise inverse-distance potential Σ_{i<j} 1/|p_i − p_j| over 3-D points (pts.len()==3·n). A representative N-body reduction.
axpb
ElementwiseMap: fused y = a·x + b over a large vector.
fft_radix2
Fft: in-place iterative radix-2 Cooley–Tukey FFT of a complex signal held as parallel re/im slices. re.len()==im.len() must be a power of two. inverse=false is the forward transform (no 1/N scaling — matches the textbook DFT the tests check against).
gemv
DenseLinear: GEMV y = W·x, W row-major n×n. y.len()==n, x.len()==n.
monte_carlo_pi
Divergent: a branch-heavy Monte-Carlo step — estimate π by the fraction of steps deterministic-LCG samples landing inside the unit circle (×4). The branch (inside ? ... : ...) is the divergence this class represents. Deterministic so it is reproducible as a correctness reference.
prefix_sum
Scan: inclusive prefix sum y[i] = Σ_{k≤i} x[k]. y.len()==x.len().
reduce_sum
Reduction: sum of a large vector (pairwise/parallel; deterministic enough for the tolerance gate).
stencil3
Stencil: 1-D 3-point Laplacian y[i] = x[i-1] - 2·x[i] + x[i+1], with the ends clamped (one-sided zero). y.len()==x.len().