Commit Graph
7154 Commits
Author SHA1 Message Date
anematodeandJoost VandeVondele dc1686345c Hyperbola quintessence for ARM
Passed STC

https://tests.stockfishchess.org/tests/view/69f44c1e1e5788938e86aa2a
LLR: 2.93 (-2.94,2.94) <0.00,2.00>
Total: 27680 W: 7340 L: 7053 D: 13287
Ptnml(0-2): 72, 2862, 7683, 3153, 70

x86 is unaffected

Data from Joost's machine (Neoverse V2):

```
==== master ====
==== Bench: 2723949 ====
1 Nodes/second : 276819933
2 Nodes/second : 273971948
3 Nodes/second : 275567995
Average (over 3):  275453292
==== 5b54755db23a3de29407b805b85e7bbdef28df49 ====
==== Bench: 2723949 ====
1 Nodes/second : 282861542
2 Nodes/second : 279085277
3 Nodes/second : 279612223
Average (over 3):  280519680 (+1.8%)
```

Data from my M1 macbook

```
Result of 100 runs
==================
base (./stockfish    ) =    1474702  +/- 6169
test (...fish.rbit-pr) =    1500236  +/- 6690
diff                   =     +25533  +/- 4011

speedup        = +0.0173
P(speedup > 0) =  1.0000
```

Hyperbola quintessence works nicely on ARM because it has an efficient bit reversal instruction `rbit`. This lets us avoid the large magic bitboards lookup table. Codegen looks nice (this is for rook attacks I think):

```
0000000100001ecc <__ZN9Stockfish10attacks_bbILNS_9PieceTypeE3EEEyNS_6SquareEy>:
100001ecc: 2a0003e8     mov w8, w0
100001ed0: f002cb09     adrp x9, 0x105964000 <dyld_stub_binder+0x105964000>
100001ed4: 91200129     add x9, x9, #0x800
100001ed8: 8b081928     add x8, x9, x8, lsl #6
100001edc: a9402909     ldp x9, x10, [x8]
100001ee0: 8a01012b     and x11, x9, x1
100001ee4: dac0016c     rbit x12, x11
100001ee8: a941210d     ldp x13, x8, [x8, #0x10]
100001eec: cb08018c     sub x12, x12, x8
100001ef0: dac0018c     rbit x12, x12
100001ef4: cb0d016b     sub x11, x11, x13
100001ef8: ca0b018b     eor x11, x12, x11
100001efc: 8a090169     and x9, x11, x9
100001f00: 8a01014b     and x11, x10, x1
100001f04: dac0016c     rbit x12, x11
100001f08: cb080188     sub x8, x12, x8
100001f0c: dac00108     rbit x8, x8
100001f10: cb0d016b     sub x11, x11, x13
100001f14: ca0b0108     eor x8, x8, x11
100001f18: 8a0a0108     and x8, x8, x10
100001f1c: 8b090100     add x0, x8, x9
100001f20: d65f03c0     ret
```

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

No functional change
2026-05-04 08:32:23 +02:00
fe1d2b456c Update CI Binaries
- split into multiple jobs
- remove binaries which are already covered by the universal binary

superseeds https://github.com/official-stockfish/Stockfish/pull/6779

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

No functional change

Co-authored-by: Disservin <disservin.social@gmail.com>
2026-05-04 08:32:03 +02:00
Robert Nurnberg @ elitebookandJoost VandeVondele 7e754e17dd Simplify away completedDepth
Recent changes to this part of the code mean that the variable `completedDepth` is no longer neeeded. The only *functional* part of this patch is the effect on the thread voting formula. Basically, compared to master this patch raises the depth weight in the formula uniformly by 1. For very, very low depths this may have a tiny effect on thread selection compared to master. But in general we expect this patch to have no effect on game play at STC and LTC.

Passed STC SMP non-reg:
LLR: 2.95 (-2.94,2.94) <-1.75,0.25>
Total: 284808 W: 72944 L: 72994 D: 138870
Ptnml(0-2): 351, 32192, 77370, 32138, 353
https://tests.stockfishchess.org/tests/view/69eddd011e5788938e86a075

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

No functional change
2026-05-04 08:31:44 +02:00
FauziAkramandJoost VandeVondele 4055a9fb27 Remove the limit from the formula
Passed STC:
LLR: 2.96 (-2.94,2.94) <-1.75,0.25>
Total: 364768 W: 94115 L: 94250 D: 176403
Ptnml(0-2): 1101, 40158, 99989, 40047, 1089
https://tests.stockfishchess.org/tests/view/69e7ca530e9667dd5a7655a7

Passed LTC:
LLR: 2.94 (-2.94,2.94) <-1.75,0.25>
Total: 146382 W: 37335 L: 37247 D: 71800
Ptnml(0-2): 64, 14682, 43630, 14732, 83
https://tests.stockfishchess.org/tests/view/69eeaf551e5788938e86a1e6

Passed VLTC:
LLR: 3.00 (-2.94,2.94) <-1.75,0.25>
Total: 48308 W: 12350 L: 12172 D: 23786
Ptnml(0-2): 4, 4303, 15362, 4481, 4
https://tests.stockfishchess.org/tests/view/69f25adb1e5788938e86a794

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

No functional change
2026-05-04 08:31:25 +02:00
3e3e976fdf [bugfix] Respect bound flags for searched moves in multiPV analysis
Master in `pv()` incorrectly assumes that any root move with `i != pvIdx` has an exact score. This can lead to the suppression of bound flags for (a) root moves that have been partially searched in an iteration but do not end up to be best move, or (b) when an aborted search for `pvIdx > 0` leads to a new best move. This latter case is the cause for issue #6783.

Fixes #6783.

The bug in its incarnation (a) was independently discovered by @ciekce a couple of weeks ago, and we have jointly discussed a patch that fixes it. He is therefore a co-author of the bugfix part of this patch.

While at it, we also fix three minor oversights in the PV roll-back for aborted searches with a loss score:
* We only roll back the PV if the aborted search would report an exact score.
* Master inadvertently may have reported a bound for the rolled-back score+PV.
* We ensure a final UCI info line with the correct search depth and searched nodes statistics etc.

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

No functional change

Co-Authored-By: Ciekce <44617491+Ciekce@users.noreply.github.com>
2026-05-04 08:31:06 +02:00
FauziAkramandJoost VandeVondele 2be0b2cdb4 Change ttmove reduction logic, and values
Passed STC:
LLR: 2.93 (-2.94,2.94) <0.00,2.00>
Total: 38112 W: 10024 L: 9708 D: 18380
Ptnml(0-2): 104, 4365, 9830, 4625, 132
https://tests.stockfishchess.org/tests/view/69dd25a33ca80bdf151d4b33

Passed LTC:
LLR: 2.94 (-2.94,2.94) <0.50,2.50>
Total: 256926 W: 65744 L: 64977 D: 126205
Ptnml(0-2): 126, 27919, 71612, 28674, 132
https://tests.stockfishchess.org/tests/view/69de48645c67bee7d241ff4e

Passed VLTC non-reg:
LLR: 2.95 (-2.94,2.94) <-1.75,0.25>
Total: 174386 W: 44640 L: 44578 D: 85168
Ptnml(0-2): 26, 17847, 51384, 17911, 25
https://tests.stockfishchess.org/tests/view/69e767370e9667dd5a76551b

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

Bench: 2788824
2026-05-04 08:30:47 +02:00
FauziAkramandJoost VandeVondele 7bd32a51f5 Replacing the futility margin static value with a continuous transition
Smooth the futility margin by interpolating the multiplier based on depth, replacing the previous static value with a continuous transition between depth 1 and 10.

Passed STC:
LLR: 2.93 (-2.94,2.94) <0.00,2.00>
Total: 208448 W: 53891 L: 53324 D: 101233
Ptnml(0-2): 629, 24426, 53574, 24939, 656
https://tests.stockfishchess.org/tests/view/69e232206f344a19176002f3

Passed LTC:
LLR: 2.94 (-2.94,2.94) <0.50,2.50>
Total: 208938 W: 53432 L: 52765 D: 102741
Ptnml(0-2): 105, 22531, 58550, 23158, 125
https://tests.stockfishchess.org/tests/view/69e8b5d00e9667dd5a7656c6

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

Bench: 2661424
2026-05-04 08:30:28 +02:00
Timothy HerchenandJoost VandeVondele 04ce2c04d7 Faster movepick sorting on AVX512ICL
The core idea here is to greatly speed up the backwards insertion loop of the insertion sort. We can store up to 16 sorted moves and their values/scores in vectors. We obtain all moves with a smaller score (i.e., sorted later than the move-to-insert) as a mask, giving us something like `1111111111000000`. If we subtract one this gives us `1111111110111111` which can be can be used as an expand mask, to insert the new move.

Passed STC:
https://tests.stockfishchess.org/tests/view/69e9c9190e9667dd5a765853
LLR: 2.94 (-2.94,2.94) <0.00,2.00>
Total: 45024 W: 11867 L: 11550 D: 21607
Ptnml(0-2): 101, 4938, 12142, 5205, 126

Local test:
```
Result of  50 runs
==================
base (...kfish.master) =    2026071  +/- 5124
test (./stockfish    ) =    2083770  +/- 5964
diff                   =     +57699  +/- 8535

speedup         = +0.0285
P(speedup > 0) =  1.0000
```

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

No functional change
2026-05-04 08:30:09 +02:00
anematodeandJoost VandeVondele 1a882efc7f Simplify out double_inc_update
Passed STC
https://tests.stockfishchess.org/tests/view/69e82e200e9667dd5a765631
LLR: 2.93 (-2.94,2.94) <-1.75,0.25>
Total: 115424 W: 29950 L: 29822 D: 55652
Ptnml(0-2): 318, 12712, 31544, 12800, 338

Passed AVX2-only STC
https://tests.stockfishchess.org/tests/view/69e953080e9667dd5a7657c0
LLR: 2.93 (-2.94,2.94) <-1.75,0.25>
Total: 134720 W: 34773 L: 34665 D: 65282
Ptnml(0-2): 344, 14958, 36694, 14974, 390

Now that our L1 size is much smaller, the overhead of tracking diffs for
`double_inc_update` is a larger share of the cost.

Interestingly ces42 measured a -0.9% slowdown locally (avxvnni build).
Meanwhile Torom and I find this branch to be 2% faster. I'm not sure exactly
what's going on but more tests may be in order

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

No functional change
2026-04-26 09:43:42 +02:00
Ryan Hirsch rhirsch123andJoost VandeVondele 0e78190b72 Speed up find_nnz on neon (Refactored)
Passed STC:
LLR: 2.97 (-2.94,2.94) <0.00,2.00>
Total: 349568 W: 90131 L: 89393 D: 170044
Ptnml(0-2): 725, 37712, 97280, 38234, 833
https://tests.stockfishchess.org/tests/view/69e470510e9667dd5a765046

This is a refactor of https://github.com/official-stockfish/Stockfish/pull/6766 so we don't have to include nnue_architecture.h
It also includes the fix in https://github.com/official-stockfish/Stockfish/pull/6769 which was needed to make this work.
mstembera made rhirsch123 the author.  credits also to anematode.

[Edit] Also fixes a bug where _mm512_packus_epi32 was being used instead of the correct _mm512_packs_epi32 for the IceLake version.

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

No functional change
2026-04-26 09:41:09 +02:00
ppigazziniandJoost VandeVondele b35a064eae ci: cancel stale workflow runs per PR or ref
Add workflow-level concurrency to the direct GitHub Actions entrypoints so a
newer run for the same pull request or repository ref cancels the older
in-progress run.

Keep the reusable workflow graph, release guards, triggers, and permissions
unchanged while documenting the concurrency policy and the official GitHub
references used for the change.

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

No functional change.
2026-04-26 09:39:38 +02:00
mstemberaandJoost VandeVondele 692d90bd74 Simplify FullThreats::append_active_indices()
Also add an else to FullThreats::append_changed_indices() because dp2removed
can't be equal to both from and to simultaneously.

passed STC
https://tests.stockfishchess.org/tests/view/69e71a490e9667dd5a76549f
LLR: 2.93 (-2.94,2.94) <-1.75,0.25>
Total: 210688 W: 54362 L: 54335 D: 101991
Ptnml(0-2): 613, 23246, 57593, 23285, 607

Thanks to ces42 for an improvement suggestion.

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

No functional change
2026-04-26 09:37:18 +02:00
FauziAkramandJoost VandeVondele c787509663 Simplify time management reduction logic
Simplify the time management reduction logic by replacing the previous sigmoid
function with the linear interpolate function introduced in #6729 , resulting
in a cleaner and more efficient calculation of move stability that avoids
unnecessary exponential operations.

Passed STC non-reg:
LLR: 2.95 (-2.94,2.94) <-1.75,0.25>
Total: 161856 W: 41933 L: 41852 D: 78071
Ptnml(0-2): 418, 18137, 43792, 18108, 473
https://tests.stockfishchess.org/tests/view/69e117a46f344a1917600148

Passed LTC non-reg:
LLR: 2.95 (-2.94,2.94) <-1.75,0.25>
Total: 108726 W: 27819 L: 27692 D: 53215
Ptnml(0-2): 59, 11084, 31942, 11227, 51
https://tests.stockfishchess.org/tests/view/69e563c00e9667dd5a7652ac

This is a follow-up for #6091  #6729

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

No functional change
2026-04-26 09:35:37 +02:00
mstemberaandJoost VandeVondele 767dcfe48d Fix Universal build on Windows
TRACKED_TOP previously used a shell pipeline (xargs, awk, sort) to extract
unique top-level directory/file names from SRCS and HEADERS. When invoking make
from cmd.exe on Windows, $(shell ...) uses cmd.exe rather than sh.exe, so the
pipeline fails because cmd.exe does not support Unix pipe syntax. Other MSYS2
tools (e.g. the compiler) work fine because they are invoked directly as
commands, not through a shell pipeline. This caused TRACKED_TOP to be empty, so
ln -s never ran and the per-arch temp_builds subdirectories were left without a
Makefile symlink, breaking the universal build with: "No rule to make target
'universal-object-nopgo'". Fixed by replacing the shell pipeline with pure GNU
make built-in functions (sort, foreach, firstword, subst) which have no shell
or PATH dependencies and work identically on Windows, Linux and macOS.

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

No functional change
2026-04-26 09:33:03 +02:00
anematodeandJoost VandeVondele 8f181af8fb Get universal binary working for clang on Linux
A few changes were necessary, mainly because clang LTO works a bit differently than GCC

Doesn't yet work on Windows

small Makefile cleanups

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

No functional change
2026-04-26 09:31:30 +02:00
Robert Nurnberg @ elitebookandJoost VandeVondele 86853a60ce [bugfix] Send correct search depth in final UCI info line
For quite some time SF has reported a too low final search depth in rare cases
(in multi-threaded search if a non-main thread was selected). Unfortunately,
the recent refactoring in #6704 means that this now happens for almost every
stopped search.

This PR fixes this issue, which was first spotted and reported by joergoster,
by ensuring that `rootDepth` always holds the last depth for which a search was
started.

Fixes #6756.

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

No functional change.
2026-04-26 09:28:54 +02:00
Dieter DobbelaereandJoost VandeVondele e68ca3c187 Rename Linux universal release package/binary
Rename Linux universal release package from
`stockfish-ubuntu-x86-64-universal.tar.gz`  to
`stockfish-linux-x86-64-universal.tar.gz` (and similar for the binary), as the
bundled binary should run on any Linux distro with glibc >= 2.35 (which is the
glibc version of the Ubuntu 22.04 build server).

Note that the Linux universal binary is built with static libstdc++ linkage, so
this adds no extra dependency.

This change will hopefully make it less confusing for users, and in line with
how we show it on stockfishchess.org (as Linux).

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

No functional change
2026-04-26 09:27:08 +02:00
FauziAkramandJoost VandeVondele 38d887ac64 Reuse Promotion Type Natively
Piece promotion is generated, and then type_of(promotion) is used to retrieve
the underlying type. The class Move provides .promotion_type() natively,
meaning we can cache the type directly and avoid extracting it indirectly
afterward.  By extracting pt = m.promotion_type(); up front, we don't need to
call type_of(promotion) iteratively inside the assertions or conditions below.

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

No functional change
2026-04-26 09:25:45 +02:00
Robert NurnbergandJoost VandeVondele 50e8ff1e23 multiPV: protect mated-ins and allow thread selection
This PR is a replacement for #6652 and takes into account the changes made to this part of the code since then.

In multiPV analysis master may suppress genuine proven mated-in scores, if the iteration for a secondary PV line is aborted. In very rare cases, it may also evict a proven mated-in score from the best PV line with a score from an incomplete iteration of a secondary PV line. This PR avoids both.

In addition, we allow best thread selection in multithreaded multiPV searches. This was originally disabled in #524.

Single PV searches are not affected by this patch at all.

Fixes #6642.

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

No functional change.
2026-04-26 09:24:34 +02:00
anematodeandJoost VandeVondele e17725f445 Constexpr attacks (pext only)
LLR: 2.97 (-2.94,2.94) <0.00,2.00>
Total: 38400 W: 10057 L: 9749 D: 18594
Ptnml(0-2): 93, 4110, 10498, 4394, 105
https://tests.stockfishchess.org/tests/view/69d2073261a12cebe17edc04

compile time generation leads to sharing tables through the binary, resulting
in gain on fishtest, as well as reduced memory usage. The downside is slightly
longer compilation time.

Using pdep reduces table size 4x, and gains a little outside of fishtest as well.

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

No functional change
2026-04-26 09:18:06 +02:00
FauziAkramandJoost VandeVondele ed651aab54 Replacing std::clamp with std::min
No functional change

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

No functional change
2026-04-20 17:45:03 +02:00
FauziAkramandJoost VandeVondele 7faecd75ac Combine duplicated - tb.plies subtraction logic
closes https://github.com/official-stockfish/Stockfish/pull/6752

No functional change
2026-04-20 17:44:01 +02:00
DisservinandJoost VandeVondele 583e0c1c75 cleanup feature detection code
makes the main dispatch logic more easy to follow and possibly update

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

No functional change
2026-04-20 17:42:47 +02:00
Dieter DobbelaereandJoost VandeVondele 9dd58542c9 Compress Linux universal release package
`stockfish-ubuntu-x86-64-universal.tar` goes from 94.8MiB to 67.4MiB (tar.gz)

Note that the CI code is written such that it easy to select other compression
schemes in the future (e.g. tar.xz) by simply changing the `archive_ext`
parameter.

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

No functional change
2026-04-20 17:41:06 +02:00
anematodeandJoost VandeVondele 20a8d8d3c0 Remove git dependency from Makefile
To build the universal binaries, use already defined variables with sources and
headers, as well as Makefile and incbin explicitly.

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

No functional change
2026-04-20 17:39:02 +02:00
ppigazziniandJoost VandeVondele 463f5a6ee1 ci: pin root workflow actions to immutable SHAs
Pin every external action used by the root GitHub workflow set to a full-length
commit SHA and keep the selected release tag as a same-line comment.

Update the root workflows to the latest stable tagged action versions found
during the audit while preserving existing release guards, permissions, and
reusable workflow wiring.

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

No functional change.
2026-04-20 17:37:39 +02:00
Joost VandeVondele 4a6c7e77a5 [CI] Cleanup artifact content (part 2)
removes temp_builds directory before packaging, even more.

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

No functional change
2026-04-19 13:51:09 +02:00
Joost VandeVondele edfd021257 [CI] Cleanup artifact content
removes temp_builds directory before packaging

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

No functional change
2026-04-19 12:26:47 +02:00
anematodeandJoost VandeVondele 1e333b341c Add universal binaries to prerelease page
closes https://github.com/official-stockfish/Stockfish/pull/6744

No functional change
2026-04-19 11:09:24 +02:00
FauziAkramandJoost VandeVondele ce7848f7cc Remove the Redundant ply Variables in Benchmark Calculations
In setup_benchmark, the variables evaluating the current ply simply mirror the
exact iterative progress of the string arrays loop (since ply just increments
by 1 with every pass). We can delete the separate integer assignment and
execute it securely within the loop declaration.

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

No functional change
2026-04-19 07:23:25 +02:00
FauziAkramandJoost VandeVondele c66acdac99 Restructure Futility pruning
to a simpler and cleaner version

Passed non-reg test:
LLR: 2.95 (-2.94,2.94) <-1.75,0.25>
Total: 175648 W: 45156 L: 45091 D: 85401
Ptnml(0-2): 459, 19228, 48383, 19297, 457
https://tests.stockfishchess.org/tests/view/69d8d9263ca80bdf151d454a

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

No functional change
2026-04-19 07:21:27 +02:00
Maxim MasiutinandJoost VandeVondele 40ac93b8f8 Fix MultiArray::at(); use operator[] on hot paths
Fix MultiArray::at() which was marked noexcept despite delegating to
std::array::at() that throws on out-of-range. Per review feedback, at() now
keeps standard bounds-checking semantics (only noexcept removed), and
operator[] gains an assert for debug-mode safety.

All eight correction history lookups in search.cpp (correction_value and
update_correction_history) are switched from .at(us) to [us].

Passed STC:
https://tests.stockfishchess.org/tests/view/69de7a735c67bee7d241ff92
LLR: 2.96 (-2.94,2.94) <-1.75,0.25>
Total: 77536 W: 20031 L: 19860 D: 37645
Ptnml(0-2): 221, 8411, 21338, 8572, 226

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

No functional change
2026-04-19 07:19:23 +02:00
FauziAkramandJoost VandeVondele cc4637b52b Remove Redundant Cast in MovePicker
closes https://github.com/official-stockfish/Stockfish/pull/6735

No functional change
2026-04-19 07:18:02 +02:00
FauziAkramandJoost VandeVondele 95f3680080 Replace constant LMR history divisor with depth-based array
Passed STC:
LLR: 2.97 (-2.94,2.94) <0.00,2.00>
Total: 677344 W: 175301 L: 174041 D: 328002
Ptnml(0-2): 2018, 79669, 174166, 80673, 2146
https://tests.stockfishchess.org/tests/view/69cfae021668971c9da23b80

Passed LTC:
LLR: 2.95 (-2.94,2.94) <0.50,2.50>
Total: 46470 W: 11988 L: 11651 D: 22831
Ptnml(0-2): 37, 4877, 13055, 5244, 22
https://tests.stockfishchess.org/tests/view/69dcd13c3ca80bdf151d4ab5

Passed VLTC (non-reg.):
LLR: 2.95 (-2.94,2.94) <-1.75,0.25>
Total: 58986 W: 15120 L: 14947 D: 28919
Ptnml(0-2): 7, 5835, 17636, 6008, 7
https://tests.stockfishchess.org/tests/view/69debc6c5c67bee7d241ffe9

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

Bench: 2723949
2026-04-19 07:15:43 +02:00
sscg13andJoost VandeVondele de7b0cd7a6 Update trace eval
Updates the information printed in the "eval" command. Removes piece value estimation, and adds both small and big net eval information.

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

No functional change
2026-04-19 07:10:20 +02:00
anematodeandJoost VandeVondele c3bcf74925 Universal binary for x86-64 Linux and Windows
We maintain support for quite a few x86 ISA extensions but relied on the end
user to select the binary that is best for their system.  We can detect at
runtime which architecture to use, and ship a single binary (per OS/ISA
combination). This PR does so, maintaining performance.

This is what I've landed on after quite a few iterations. Basically, we build
each arch separately, use `cpuid` to select one, and jump to that arch's main
function. Some details:

- The preprocessor macro `UNIVERSAL_BINARY` is defined when building for the universal binary.

- The Makefile target `universal-object-[no]pgo` is added, which produces a `stockfish.o` in each arch's build directory.

- To prevent symbol collisions between the multiple builds, we `#define Stockfish Stockfish_[arch]`. Furthermore we wrap the `main` function in `namespace Stockfish { }`.

- We can still get PGO data by linking to a per-arch binary, with `Stockfish_x86_64_avx2::main` as `main`, and running `bench`.
    - For arches not supported by the host we can use Intel SDE – this is what we do in CI.

- When embedding the NNUE, we use C++26/C23 `#embed` instead of `INCBIN`. The issue with `INCBIN` is that it injects assembly directives that we have no control over.
    - To ensure there's only one copy of the networks in the final binary, we define the network data as weak symbols in each per-arch build. Then, in the final link, we add a special nnue_embed.cpp which provides strong symbols.
    - This does require GCC 15. Statically linking libstdc++ allows the binary to still run on older OSes though. And latest msys2 already does static linking + is based off GCC 15.2.0

building can be as simple as

make -j profile-build ARCH=x86-64-universal

or using the sde if the host doesn't support all architectures supported in the
universal binary, and the default host compiler is not recent enough.

make -j profile-build ARCH=x86-64-universal RUN_PREFIX="/path/to/sde -future --" CXX=g++-15

This change is also integrated in CI, so universal binaries are available as
downloadable artifacts.

Next we could also do ARM64, especially Android (all Apple silicon users use
the same binary). It also might be worth getting this to work with clang.

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

No functional change
2026-04-19 07:07:11 +02:00
rn5f107s2andJoost VandeVondele b1fb50ae69 Simplify away the special case for en passant in the legality check
Since as of 94175524b1 the en passant square is
only set if there is a legal en passant capture, the special handling is
redundant

Passed Non-Regression STC:
https://tests.stockfishchess.org/tests/view/696ffb6512ee1f6231b96fe8
LLR: 2.95 (-2.94,2.94) <-1.75,0.25>
Total: 79072 W: 20380 L: 20210 D: 38482.

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

No functional change
2026-04-15 20:35:32 +02:00
DisservinandJoost VandeVondele 45711fceb4 Add PVMoves Struct
Use a dedicated struct for keeping track of the pv moves.

anematode pointed out that we can use the ValueList for this as well, left that open for a future patch.

Passed Non Regression
https://tests.stockfishchess.org/tests/view/69d399cfec2dc6794cf18376
LLR: 2.95 (-2.94,2.94) <-1.75,0.25>
Total: 267264 W: 68895 L: 68927 D: 129442
Ptnml(0-2): 790, 29238, 73566, 29290, 748

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

No functional change
2026-04-15 20:30:00 +02:00
87andJoost VandeVondele 4bdeb6352c Remove unnecessary use of _mm512_zextsi256_si512
[Some build environments](https://tests.stockfishchess.org/actions?max_count=400&sort=time&order=desc&action=failed_task&user=gaster319&text=executing) do not have this intrinsic.

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

No functional change.
2026-04-15 20:26:21 +02:00
FauziAkramandJoost VandeVondele 0694742a31 Remove redundant std::skipws from fresh string streams
In C++, all standard input streams (including std::istringstream) are initialized with the skipws format flag enabled by default. Because these stream objects are scoped locally and freshly constructed on each loop iteration, we are guaranteed that skipws is already active.

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

No functional change
2026-04-15 20:26:10 +02:00
J. OsterandJoost VandeVondele 5f3dcb92ee Simplify stalemate detection in qsearch.
Conditions for no pawn pushes, non-pawn material and last captured piece are already such restrictive that we don't need to artificially set checkers bitboard for legal move generation.
Also moving the check for available pawn pushes at first place, as it should already filter about 90% of cases.

Passed STC and LTC non-regression tests.
 LLR: 2.96 (-2.94,2.94) <-1.75,0.25>
Total: 171232 W: 44202 L: 44131 D: 82899
Ptnml(0-2): 466, 18809, 47023, 18824, 494
https://tests.stockfishchess.org/tests/view/69d3623b61a12cebe17ededa

LLR: 2.94 (-2.94,2.94) <-1.75,0.25>
Total: 55662 W: 14424 L: 14247 D: 26991
Ptnml(0-2): 38, 5479, 16609, 5678, 27
https://tests.stockfishchess.org/tests/view/69d64cada07a818b0a25f95e

And also neutral on 10k fixed games test with custom stalemate book.
 Elo: 0.24 ± 0.9 (95%) LOS: 69.9%
Total: 10000 W: 4681 L: 4674 D: 645
Ptnml(0-2): 0, 87, 4819, 94, 0
nElo: 1.81 ± 6.8 (95%) PairsRatio: 1.08
https://tests.stockfishchess.org/tests/view/69d7e4183ca80bdf151d43b8

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

Bench: 2984258
2026-04-15 20:15:36 +02:00
DubslowandJoost VandeVondele 3cce652564 Simplify relative_age and its constants
STC: https://tests.stockfishchess.org/tests/view/69cf29ed1668971c9da23a5a
LLR: 3.47 (-2.94,2.94) <-1.75,0.25>
Total: 193760 W: 50142 L: 50051 D: 93567
Ptnml(0-2): 534, 21375, 52980, 21448, 543

* Simplify retval and arithmetic semantics
* Remove mixing of int and uint8_t

I find this overall much easier to reason about

(Also rename a DEPTH constant per mstembera's suggestion https://github.com/official-stockfish/Stockfish/pull/5766#issuecomment-2586449296)

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

No functional change
2026-04-15 20:13:22 +02:00
DisservinandJoost VandeVondele 9bdf2f8d4c Update main network to nn-f68ec79f0fe3.nnue
Trained with the following yaml definition https://github.com/Disservin/nettest/blob/8da0a21503adb341bc89ca20b4e2f166c7c9720d/threats.yaml

and the following trainer change
https://github.com/official-stockfish/nnue-pytorch/commit/d87c248fbed584d08df59820ae0dd309e9b35c85

Initially I saw a lot of weird 0 scores in the binpack, since then @linrock has explained to me/us their meaning and mentioned that they are actually mostly skipped.. except a very small percentage, however it seems this change was still beneficial.

Passed STC:
https://tests.stockfishchess.org/tests/view/69db95f43ca80bdf151d4913
LLR: 2.95 (-2.94,2.94) <0.00,2.00>
Total: 106272 W: 27916 L: 27489 D: 50867
Ptnml(0-2): 420, 12533, 26841, 12884, 458

Passed LTC:
https://tests.stockfishchess.org/tests/view/69ddd9003ca80bdf151d4c4d
LLR: 2.94 (-2.94,2.94) <0.50,2.50>
Total: 29748 W: 7775 L: 7470 D: 14503
Ptnml(0-2): 24, 3136, 8247, 3445, 22

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

Bench: 3108996
2026-04-15 20:06:17 +02:00
mstemberaandJoost VandeVondele 7959885747 Interpolate highBestMoveEffort
STC: https://tests.stockfishchess.org/tests/view/69d586a64088e069540a22aa
LLR: 2.93 (-2.94,2.94) <0.00,2.00>
Total: 63520 W: 16579 L: 16233 D: 30708
Ptnml(0-2): 138, 7179, 16825, 7435, 183

LTC: https://tests.stockfishchess.org/tests/view/69d6ddd79ffee997bab13a98
LLR: 2.94 (-2.94,2.94) <0.50,2.50>
Total: 227100 W: 58279 L: 57591 D: 111230
Ptnml(0-2): 95, 23435, 65828, 24071, 121

Transition highBestMoveEffort smoothly instead of abruptly. May also be more amenable to future tuning.

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

Bench: 2923401
2026-04-15 20:03:49 +02:00
Ryan LefkowitzandJoost VandeVondele bb5f0100b0 fix syzygy crash on Apple Silicon by unrolling tbprobe adjustment loop
A bit tricky to identify, but in `apple-silicon` builds, specifying a value for
`SyzygyPath` could still lead to crashes at certain depths from a
SIGBUS/SIGSEGV.

This PR replaces the `std::count_if()` adjustment in `tbprobe.cpp`'s
`do_probe_table()` with an annotated handwritten loop, avoiding the clang/LTO
miscompilation behind the crash.

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

No functional change.
2026-04-15 19:05:14 +02:00
Shawn XuandJoost VandeVondele b63bd7b78e Fix assert
the assert checks for `bestThreadDecisive && newThreadDecisive`. However `newThreadDecisive` is not guaranteed at this point, leading to assertion failures. This PR rearranges the conditions to ensure correctness.

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

No functional change
2026-04-15 19:01:06 +02:00
Linmiao XuandDisservin bb4eb04a50 Don't store stand pat return value in TT
Passed non-regression STC:
https://tests.stockfishchess.org/tests/view/69d2d3de61a12cebe17ede38
LLR: 2.95 (-2.94,2.94) <-1.75,0.25>
Total: 68384 W: 17646 L: 17459 D: 33279
Ptnml(0-2): 200, 8058, 17496, 8231, 207

Passed non-regression LTC:
https://tests.stockfishchess.org/tests/view/69d4293433584dad27b3c8cb
LLR: 2.95 (-2.94,2.94) <-1.75,0.25>
Total: 37290 W: 9582 L: 9380 D: 18328
Ptnml(0-2): 18, 3915, 10579, 4113, 20

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

Bench: 2923401
2026-04-09 21:56:05 +02:00
Robert Nurnberg @ elitebookandDisservin 9db77822bd Simplify best thread selection
For some time now we can trust the threads' exact win/loss scores. This
allows for some simplification in the best thread selection code.

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

No functional change
2026-04-09 21:56:05 +02:00
FauziAkramandDisservin 5ae13d2bd4 Remove Redundant Branchless Execution
Passed STC non-reg:
LLR: 2.93 (-2.94,2.94) <-1.75,0.25>
Total: 102272 W: 26553 L: 26411 D: 49308
Ptnml(0-2): 269, 11212, 28036, 11346, 273
https://tests.stockfishchess.org/tests/view/69d0f1c5e2b443cb2670b710

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

No functional change
2026-04-09 21:56:05 +02:00
Robert Nurnberg @ elitebookandDisservin d3a4587fe8 Simplify uci pv output logic
The uci pv suppression and PV roll-back logic in master is a bit
convoluted, which makes it hard to reason about the code. In fact,
subtle bugs that led to wrong mated-in scores in game play or a mismatch
between bestmove and first PV move were only recently fixed. Moreover,
in master the uci pv output through `pv()` is called in four different
places.

This PR proposes to simplify this logic. In this patch, the PV is sent
to the GUI from within `iterative_deepening()` only (a) for fail
highs/lows or (b) when an iteration for a root move is completed. All
other PV outputs are now handled by `start_searching()`, just before the
bestmove extraction. This easily ensures that bestmove (and ponder move)
will always be in sync with the final PV output.

The only noticeable change to master is for multi-threaded searches that
do not involve `limits.depth`. Here master would show both the PV from
the aborted search in main thread, as well as the new PV from the
selected best thread. This patch would only show the latter.

While at it, we also remove the requirement to finish at least a depth 1
search and simplify the logic around stalemates/checkmates at root and
in particular avoid any PVs that start with `Move::none()`.

Passed STC non-reg:
LLR: 2.96 (-2.94,2.94) <-1.75,0.25>
Total: 72416 W: 18784 L: 18609 D: 35023
Ptnml(0-2): 200, 7762, 20127, 7901, 218
https://tests.stockfishchess.org/tests/view/69d3ef0c33584dad27b3c85a

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

No functional change
2026-04-09 21:56:05 +02:00