The value and policy networks now run on hand-written vector kernels
(src/simd.h) instead of plain loops left to the auto-vectoriser. Paths for
AVX-512BW (VNNI dpwssd when present), AVX2 (AVX-VNNI when present), SSE2
(SSE4.1 sign extend when present) and NEON, chosen at compile time by
-march=native, plus a scalar fallback (-DRIGBY_NO_SIMD).
All arithmetic is exact integer maths, so every path gives the same results
as before and the bench is unchanged.
Value net:
- refresh sums the feature rows in registers, one tile at a time, and
writes the accumulator once instead of once per piece
- update adds and subtracts the changed rows in one vector pass
- evaluate does SCReLU as v * (v * w) with mullo + madd; v * w fits
16 bits because the output weights are at most 32767 / QA = 128 (now
checked on load; the v1 net's largest is 127), and each half's sum fits
32 bits (static_assert)
Policy net:
- the hidden layer sums the i8 rows (sign-extended on load) into
register tiles of 8 vectors; row by row in memory was 1.8x slower
- CReLU and the pairwise product in one vector pass
- the output dot products run four moves at a time, sharing the loads of
the activations (output stage about 20% faster than one at a time)
Tried and dropped: software prefetch of the weight rows (slower), storing
the policy's first layer as i16 to skip the sign extend (slower: the
accumulation is bound by memory, not by the extend).
Measured on a Ryzen 9 5900X (AVX2), bench 50000, four runs each:
main 4.43M nps, this 5.21M nps (+18%).
Checked: bench 615835 identical for AVX2, SSE2, SSE4.1 and scalar builds;
AVX-512 (skylake-avx512, icelake-server) and AVX-VNNI (alderlake) builds
compile; the NEON kernels compile for aarch64 (not run). UCI: uci,
isready, position, go nodes, setoption PolicyFile.
Bench: 615835
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>