From 8a1b0f8b044ffbaf7341325de978d21382d7ef60 Mon Sep 17 00:00:00 2001 From: Linmiao Xu Date: Thu, 2 Apr 2026 20:28:12 +0200 Subject: [PATCH] Reorder NNUE accumulator evals Makes eval calls more cache-friendly on a hot path. Hints of a speedup found locally: ``` Result of 30 runs ================== base (...ockfish-base) = 1754124 +/- 2887 test (...h-eval-order) = 1757848 +/- 2412 diff = +3724 +/- 1368 speedup = +0.0021 P(speedup > 0) = 1.0000 CPU: 16 x arm Hyperthreading: off ``` Passed STC: https://tests.stockfishchess.org/tests/view/69c84f3cf40d95b975597c21 LLR: 3.36 (-2.94,2.94) <0.00,2.00> Total: 335840 W: 87022 L: 86257 D: 162561 Ptnml(0-2): 932, 36760, 91816, 37435, 977 closes https://github.com/official-stockfish/Stockfish/pull/6693 No functional change --- src/nnue/nnue_accumulator.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/nnue/nnue_accumulator.cpp b/src/nnue/nnue_accumulator.cpp index 5922275d0..554060dd8 100644 --- a/src/nnue/nnue_accumulator.cpp +++ b/src/nnue/nnue_accumulator.cpp @@ -145,14 +145,13 @@ void AccumulatorStack::evaluate(const Position& pos, constexpr bool UseThreats = (Dimensions == TransformedFeatureDimensionsBig); evaluate_side(WHITE, pos, featureTransformer, cache); - - if (UseThreats) - evaluate_side(WHITE, pos, featureTransformer, cache); - evaluate_side(BLACK, pos, featureTransformer, cache); if (UseThreats) + { + evaluate_side(WHITE, pos, featureTransformer, cache); evaluate_side(BLACK, pos, featureTransformer, cache); + } } template