Commit Graph
6 Commits
Author SHA1 Message Date
Timothy HerchenandJoost VandeVondele 229bd1e2e3 check for material key validity in tbprobe
During recent work on threat inputs, there was a hard-to-debug crash in tbprobe
caused by incorrectly computing st->materialKey. This PR adds correctness
checking to pos_is_ok and a faster check in tbprobe that will actually run in
CI (because pos_is_ok checking is disabled even in debug mode, for performance
purposes).

closes https://github.com/official-stockfish/Stockfish/pull/6410

No functional change
2025-11-13 22:42:10 +01:00
Timothy HerchenandJoost VandeVondele fa4f05d3ef Don't copy around DirtyThreats
The contents of DirtyThreats gets memcpyed twice for each call to do_move.
(Return value optimization doesn't apply to the do_move function itself because
it constructs a std::pair, so it gets copied; and the calls to reset also
require a copy.) This patch inserts the dirty info in place.

Sometimes the caller of do_move ignores the DirtyThreats info, so we pass in
scratch objects. I found that stack-allocating these scratch objects was bad on
Fishtest, so I begrudgingly put them in the Position struct. Both templating
the do_move function on whether dirty threats are needed and putting a
null-check branch for each use of dirty threats were slowdowns locally. Of
course, nothing prevents a future attempt at cleaning this up.

passed STC
LLR: 2.96 (-2.94,2.94) <0.00,2.00>
Total: 68448 W: 17770 L: 17418 D: 33260
Ptnml(0-2): 198, 7425, 18630, 7769, 202
https://tests.stockfishchess.org/tests/view/6914c01a7ca87818523318ba

closes https://github.com/official-stockfish/Stockfish/pull/6414

No functional change
2025-11-13 22:17:03 +01:00
Timothy HerchenandJoost VandeVondele 6764561916 Improve index generation
The speedup seems to vary by machine.  The indexing function can be changed w/o needing to understand intrinsics.

Result of 100 runs
==================
base (...ish_baseline) =    1719637  +/- 3233
test (./stockfish    ) =    1734245  +/- 3534
diff                   =     +14608  +/- 4868

speedup        = +0.0085
P(speedup > 0) =  1.0000

closes https://github.com/official-stockfish/Stockfish/pull/6366

No functional change
2025-11-01 10:42:42 +01:00
Timothy HerchenandJoost VandeVondele 3bb01ce7a9 prefetch earlier if checKEP is false
Only a modest amount of work happens between the transposition table prefetch
and the probe, so the probe still often stalls waiting for DRAM. The vast
majority of the time (in particular, if !checkEP), the key is known much
earlier in the do_move function and the latency can be better hidden.

passed STC SMP
https://tests.stockfishchess.org/tests/view/68f337c528e6d77fcffa066a
LLR: 2.95 (-2.94,2.94) <0.00,2.00>
Total: 65256 W: 16806 L: 16462 D: 31988
Ptnml(0-2): 76, 7386, 17362, 7726, 78

but failed to gain STC
https://tests.stockfishchess.org/tests/view/68f3378328e6d77fcffa0665
LLR: -2.94 (-2.94,2.94) <0.00,2.00>
Total: 109824 W: 28523 L: 28618 D: 52683
Ptnml(0-2): 311, 11799, 30788, 11702, 312

In local tests, the speedup grows with thread count

closes https://github.com/official-stockfish/Stockfish/pull/6372

No functional change
2025-11-01 10:40:23 +01:00
b09339a420 Split accumulator 3-Way
Squeeze a tiny bit more juice from the original idea in #6336 which this is on top of.

https://tests.stockfishchess.org/tests/view/68dddd85fa806e2e8393c0b9
LLR: 2.95 (-2.94,2.94) <0.00,2.00>
Total: 156320 W: 40925 L: 40447 D: 74948
Ptnml(0-2): 427, 17330, 42172, 17800, 431

4-way doesn't look to be better than this.
https://tests.stockfishchess.org/tests/view/68dde19efa806e2e8393c0c1

closes https://github.com/official-stockfish/Stockfish/pull/6339

No functional change

Co-authored-by: M Stembera <m_stembera@yahoo.com>
2025-10-05 09:33:23 +02:00
Timothy HerchenandJoost VandeVondele 9b164d9520 Shave some instructions off a hot loop in affine transform
On x86, GCC generates highly suboptimal code for this loop in its old form,
about 2x as many instructions as necessary. This decreases throughput
especially in an SMT setting. Clang does a better job but this change still has
some improvement. Note that the std::ptrdiff_t type is not optional; using an
unsigned type brings back the bad assembly. (Not sure why, but it seems
reliable on all the GCC versions I tested.)

passed STC:
LLR: 2.93 (-2.94,2.94) <0.00,2.00>
Total: 44672 W: 11841 L: 11527 D: 21304
Ptnml(0-2): 165, 4625, 12415, 4993, 138
https://tests.stockfishchess.org/tests/view/68d8111efa806e2e8393b10e

closes https://github.com/official-stockfish/Stockfish/pull/6331

No functional change
2025-09-28 21:04:29 +02:00