mirror of
https://github.com/opelly27/Stockfish.git
synced 2026-05-20 03:57:45 +00:00
Merge branch 'master' into clusterMergeMaster14
closes https://github.com/official-stockfish/Stockfish/pull/3980
This commit is contained in:
@@ -5,6 +5,7 @@ on:
|
||||
- master
|
||||
- tools
|
||||
- github_ci
|
||||
- github_ci_armv7
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
@@ -20,6 +21,12 @@ jobs:
|
||||
strategy:
|
||||
matrix:
|
||||
config:
|
||||
# set the variable for the required tests:
|
||||
# run_expensive_tests: true
|
||||
# run_32bit_tests: true
|
||||
# run_64bit_tests: true
|
||||
# run_armv8_tests: true
|
||||
# run_armv7_tests: true
|
||||
- {
|
||||
name: "Ubuntu 20.04 GCC",
|
||||
os: ubuntu-20.04,
|
||||
@@ -35,18 +42,31 @@ jobs:
|
||||
os: ubuntu-20.04,
|
||||
compiler: clang++,
|
||||
comp: clang,
|
||||
run_expensive_tests: false,
|
||||
run_32bit_tests: true,
|
||||
run_64bit_tests: true,
|
||||
shell: 'bash {0}'
|
||||
}
|
||||
- {
|
||||
name: "Ubuntu 20.04 NDK armv8",
|
||||
os: ubuntu-20.04,
|
||||
compiler: aarch64-linux-android21-clang++,
|
||||
comp: ndk,
|
||||
run_armv8_tests: true,
|
||||
shell: 'bash {0}'
|
||||
}
|
||||
- {
|
||||
name: "Ubuntu 20.04 NDK armv7",
|
||||
os: ubuntu-20.04,
|
||||
compiler: armv7a-linux-androideabi21-clang++,
|
||||
comp: ndk,
|
||||
run_armv7_tests: true,
|
||||
shell: 'bash {0}'
|
||||
}
|
||||
- {
|
||||
name: "MacOS 10.15 Apple Clang",
|
||||
os: macos-10.15,
|
||||
compiler: clang++,
|
||||
comp: clang,
|
||||
run_expensive_tests: false,
|
||||
run_32bit_tests: false,
|
||||
run_64bit_tests: true,
|
||||
shell: 'bash {0}'
|
||||
}
|
||||
@@ -55,33 +75,37 @@ jobs:
|
||||
os: macos-10.15,
|
||||
compiler: g++-10,
|
||||
comp: gcc,
|
||||
run_expensive_tests: false,
|
||||
run_32bit_tests: false,
|
||||
run_64bit_tests: true,
|
||||
shell: 'bash {0}'
|
||||
}
|
||||
- {
|
||||
name: "Windows 2019 Mingw-w64 GCC x86_64",
|
||||
os: windows-2019,
|
||||
name: "Windows 2022 Mingw-w64 GCC x86_64",
|
||||
os: windows-2022,
|
||||
compiler: g++,
|
||||
comp: gcc,
|
||||
run_expensive_tests: false,
|
||||
run_32bit_tests: false,
|
||||
comp: mingw,
|
||||
run_64bit_tests: true,
|
||||
msys_sys: 'mingw64',
|
||||
msys_env: 'x86_64',
|
||||
msys_env: 'x86_64-gcc',
|
||||
shell: 'msys2 {0}'
|
||||
}
|
||||
- {
|
||||
name: "Windows 2019 Mingw-w64 GCC i686",
|
||||
os: windows-2019,
|
||||
name: "Windows 2022 Mingw-w64 GCC i686",
|
||||
os: windows-2022,
|
||||
compiler: g++,
|
||||
comp: gcc,
|
||||
run_expensive_tests: false,
|
||||
comp: mingw,
|
||||
run_32bit_tests: true,
|
||||
run_64bit_tests: false,
|
||||
msys_sys: 'mingw32',
|
||||
msys_env: 'i686',
|
||||
msys_env: 'i686-gcc',
|
||||
shell: 'msys2 {0}'
|
||||
}
|
||||
- {
|
||||
name: "Windows 2022 Mingw-w64 Clang x86_64",
|
||||
os: windows-2022,
|
||||
compiler: clang++,
|
||||
comp: clang,
|
||||
run_64bit_tests: true,
|
||||
msys_sys: 'clang64',
|
||||
msys_env: 'clang-x86_64-clang',
|
||||
shell: 'msys2 {0}'
|
||||
}
|
||||
|
||||
@@ -98,14 +122,14 @@ jobs:
|
||||
if: runner.os == 'Linux'
|
||||
run: |
|
||||
sudo apt update
|
||||
sudo apt install expect valgrind g++-multilib
|
||||
sudo apt install expect valgrind g++-multilib qemu-user
|
||||
|
||||
- name: Setup msys and install required packages
|
||||
if: runner.os == 'Windows'
|
||||
uses: msys2/setup-msys2@v2
|
||||
with:
|
||||
msystem: ${{matrix.config.msys_sys}}
|
||||
install: mingw-w64-${{matrix.config.msys_env}}-gcc make git expect
|
||||
install: mingw-w64-${{matrix.config.msys_env}} make git expect
|
||||
|
||||
- name: Download the used network from the fishtest framework
|
||||
run: |
|
||||
@@ -118,6 +142,7 @@ jobs:
|
||||
|
||||
- name: Check compiler
|
||||
run: |
|
||||
export PATH=$PATH:$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin
|
||||
$COMPILER -v
|
||||
|
||||
- name: Test help target
|
||||
@@ -239,6 +264,37 @@ jobs:
|
||||
make clean
|
||||
make -j2 ARCH=x86-64-vnni256 build
|
||||
|
||||
# armv8 tests
|
||||
|
||||
- name: Test armv8 build
|
||||
if: ${{ matrix.config.run_armv8_tests }}
|
||||
run: |
|
||||
export PATH=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin:$PATH
|
||||
export LDFLAGS="-static -Wno-unused-command-line-argument"
|
||||
make clean
|
||||
make -j2 ARCH=armv8 build
|
||||
../tests/signature.sh $benchref
|
||||
|
||||
# armv7 tests
|
||||
|
||||
- name: Test armv7 build
|
||||
if: ${{ matrix.config.run_armv7_tests }}
|
||||
run: |
|
||||
export PATH=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin:$PATH
|
||||
export LDFLAGS="-static -Wno-unused-command-line-argument"
|
||||
make clean
|
||||
make -j2 ARCH=armv7 build
|
||||
../tests/signature.sh $benchref
|
||||
|
||||
- name: Test armv7-neon build
|
||||
if: ${{ matrix.config.run_armv7_tests }}
|
||||
run: |
|
||||
export PATH=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin:$PATH
|
||||
export LDFLAGS="-static -Wno-unused-command-line-argument"
|
||||
make clean
|
||||
make -j2 ARCH=armv7-neon build
|
||||
../tests/signature.sh $benchref
|
||||
|
||||
# Other tests
|
||||
|
||||
- name: Check perft and search reproducibility
|
||||
|
||||
@@ -31,6 +31,7 @@ Arjun Temurnikar
|
||||
Artem Solopiy (EntityFX)
|
||||
Auguste Pop
|
||||
Balint Pfliegel
|
||||
Ben Chaney (Chaneybenjamini)
|
||||
Ben Koshy (BKSpurgeon)
|
||||
Bill Henry (VoyagerOne)
|
||||
Bojun Guo (noobpwnftw, Nooby)
|
||||
@@ -132,6 +133,7 @@ Michael Whiteley (protonspring)
|
||||
Michel Van den Bergh (vdbergh)
|
||||
Miguel Lahoz (miguel-l)
|
||||
Mikael Bäckman (mbootsector)
|
||||
Mike Babigian (Farseer)
|
||||
Mira
|
||||
Miroslav Fontán (Hexik)
|
||||
Moez Jellouli (MJZ1977)
|
||||
@@ -153,6 +155,7 @@ Pascal Romaret
|
||||
Pasquale Pigazzini (ppigazzini)
|
||||
Patrick Jansen (mibere)
|
||||
pellanda
|
||||
Peter Schneider (pschneider1968)
|
||||
Peter Zsifkovits (CoffeeOne)
|
||||
Praveen Kumar Tummala (praveentml)
|
||||
Rahul Dsilva (silversolver1)
|
||||
@@ -165,6 +168,7 @@ Rodrigo Exterckötter Tjäder
|
||||
Ron Britvich (Britvich)
|
||||
Ronald de Man (syzygy1, syzygy)
|
||||
rqs
|
||||
Rui Coelho (ruicoelhopedro)
|
||||
Ryan Schmitt
|
||||
Ryan Takker
|
||||
Sami Kiminki (skiminki)
|
||||
@@ -194,6 +198,7 @@ tttak
|
||||
Unai Corzo (unaiic)
|
||||
Uri Blass (uriblass)
|
||||
Vince Negri (cuddlestmonkey)
|
||||
xefoci7612
|
||||
zz4032
|
||||
|
||||
|
||||
|
||||
@@ -10,24 +10,28 @@ Cute Chess, eboard, Arena, Sigma Chess, Shredder, Chess Partner or Fritz) in ord
|
||||
to be used comfortably. Read the documentation for your GUI of choice for information
|
||||
about how to use Stockfish with it.
|
||||
|
||||
The Stockfish engine features two evaluation functions for chess, the classical
|
||||
evaluation based on handcrafted terms, and the NNUE evaluation based on efficiently
|
||||
updatable neural networks. The classical evaluation runs efficiently on almost all
|
||||
CPU architectures, while the NNUE evaluation benefits from the vector
|
||||
intrinsics available on most CPUs (sse2, avx2, neon, or similar).
|
||||
|
||||
The Stockfish engine features two evaluation functions for chess. The efficiently
|
||||
updatable neural network (NNUE) based evaluation is the default and by far the strongest.
|
||||
The classical evaluation based on handcrafted terms remains available. The strongest
|
||||
network is integrated in the binary and downloaded automatically during the build process.
|
||||
The NNUE evaluation benefits from the vector intrinsics available on most CPUs (sse2,
|
||||
avx2, neon, or similar).
|
||||
|
||||
## Files
|
||||
|
||||
This distribution of Stockfish consists of the following files:
|
||||
|
||||
* [Readme.md](https://github.com/official-stockfish/Stockfish/blob/master/README.md), the file you are currently reading.
|
||||
* [Readme.md](https://github.com/official-stockfish/Stockfish/blob/master/README.md),
|
||||
the file you are currently reading.
|
||||
|
||||
* [Copying.txt](https://github.com/official-stockfish/Stockfish/blob/master/Copying.txt), a text file containing the GNU General Public License version 3.
|
||||
* [Copying.txt](https://github.com/official-stockfish/Stockfish/blob/master/Copying.txt),
|
||||
a text file containing the GNU General Public License version 3.
|
||||
|
||||
* [AUTHORS](https://github.com/official-stockfish/Stockfish/blob/master/AUTHORS), a text file with the list of authors for the project
|
||||
* [AUTHORS](https://github.com/official-stockfish/Stockfish/blob/master/AUTHORS),
|
||||
a text file with the list of authors for the project
|
||||
|
||||
* [src](https://github.com/official-stockfish/Stockfish/tree/master/src), a subdirectory containing the full source code, including a Makefile
|
||||
* [src](https://github.com/official-stockfish/Stockfish/tree/master/src),
|
||||
a subdirectory containing the full source code, including a Makefile
|
||||
that can be used to compile Stockfish on Unix-like systems.
|
||||
|
||||
* a file with the .nnue extension, storing the neural network for the NNUE
|
||||
@@ -37,7 +41,7 @@ This distribution of Stockfish consists of the following files:
|
||||
|
||||
The Universal Chess Interface (UCI) is a standard protocol used to communicate with
|
||||
a chess engine, and is the recommended way to do so for typical graphical user interfaces
|
||||
(GUI) or chess tools. Stockfish implements the majority of it options as described
|
||||
(GUI) or chess tools. Stockfish implements the majority of its options as described
|
||||
in [the UCI protocol](https://www.shredderchess.com/download/div/uci.zip).
|
||||
|
||||
Developers can see the default values for UCI options available in Stockfish by typing
|
||||
@@ -68,9 +72,9 @@ change them via a chess GUI. This is a list of available UCI options in Stockfis
|
||||
|
||||
* #### EvalFile
|
||||
The name of the file of the NNUE evaluation parameters. Depending on the GUI the
|
||||
filename might have to include the full path to the folder/directory that contains the file.
|
||||
Other locations, such as the directory that contains the binary and the working directory,
|
||||
are also searched.
|
||||
filename might have to include the full path to the folder/directory that contains
|
||||
the file. Other locations, such as the directory that contains the binary and the
|
||||
working directory, are also searched.
|
||||
|
||||
* #### UCI_AnalyseMode
|
||||
An option handled by your GUI.
|
||||
@@ -103,7 +107,7 @@ change them via a chess GUI. This is a list of available UCI options in Stockfis
|
||||
Example: `C:\tablebases\wdl345;C:\tablebases\wdl6;D:\tablebases\dtz345;D:\tablebases\dtz6`
|
||||
|
||||
It is recommended to store .rtbw files on an SSD. There is no loss in storing
|
||||
the .rtbz files on a regular HD. It is recommended to verify all md5 checksums
|
||||
the .rtbz files on a regular HDD. It is recommended to verify all md5 checksums
|
||||
of the downloaded tablebase files (`md5sum -c checksum.md5`) as corruption will
|
||||
lead to engine crashes.
|
||||
|
||||
@@ -138,8 +142,9 @@ change them via a chess GUI. This is a list of available UCI options in Stockfis
|
||||
For developers the following non-standard commands might be of interest, mainly useful for debugging:
|
||||
|
||||
* #### bench *ttSize threads limit fenFile limitType evalType*
|
||||
Performs a standard benchmark using various options. The signature of a version (standard node
|
||||
count) is obtained using all defaults. `bench` is currently `bench 16 1 13 default depth mixed`.
|
||||
Performs a standard benchmark using various options. The signature of a version
|
||||
(standard node count) is obtained using all defaults. `bench` is currently
|
||||
`bench 16 1 13 default depth mixed`.
|
||||
|
||||
* #### compiler
|
||||
Give information about the compiler and environment used for building a binary.
|
||||
@@ -175,22 +180,27 @@ on the evaluations of millions of positions at moderate search depth.
|
||||
The NNUE evaluation was first introduced in shogi, and ported to Stockfish afterward.
|
||||
It can be evaluated efficiently on CPUs, and exploits the fact that only parts
|
||||
of the neural network need to be updated after a typical chess move.
|
||||
[The nodchip repository](https://github.com/nodchip/Stockfish) provides additional
|
||||
tools to train and develop the NNUE networks. On CPUs supporting modern vector instructions
|
||||
(avx2 and similar), the NNUE evaluation results in much stronger playing strength, even
|
||||
if the nodes per second computed by the engine is somewhat lower (roughly 80% of nps
|
||||
is typical).
|
||||
[The nodchip repository](https://github.com/nodchip/Stockfish) provided the first
|
||||
version of the needed tools to train and develop the NNUE networks. Today, more
|
||||
advanced training tools are available in
|
||||
[the nnue-pytorch repository](https://github.com/glinscott/nnue-pytorch/),
|
||||
while data generation tools are available in
|
||||
[a dedicated branch](https://github.com/official-stockfish/Stockfish/tree/tools).
|
||||
|
||||
On CPUs supporting modern vector instructions (avx2 and similar), the NNUE evaluation
|
||||
results in much stronger playing strength, even if the nodes per second computed by
|
||||
the engine is somewhat lower (roughly 80% of nps is typical).
|
||||
|
||||
Notes:
|
||||
|
||||
1) the NNUE evaluation depends on the Stockfish binary and the network parameter
|
||||
file (see the EvalFile UCI option). Not every parameter file is compatible with a given
|
||||
Stockfish binary, but the default value of the EvalFile UCI option is the name of a network
|
||||
that is guaranteed to be compatible with that binary.
|
||||
1) the NNUE evaluation depends on the Stockfish binary and the network parameter file
|
||||
(see the EvalFile UCI option). Not every parameter file is compatible with a given
|
||||
Stockfish binary, but the default value of the EvalFile UCI option is the name of a
|
||||
network that is guaranteed to be compatible with that binary.
|
||||
|
||||
2) to use the NNUE evaluation, the additional data file with neural network parameters
|
||||
needs to be available. Normally, this file is already embedded in the binary or it
|
||||
can be downloaded. The filename for the default (recommended) net can be found as the default
|
||||
needs to be available. Normally, this file is already embedded in the binary or it can
|
||||
be downloaded. The filename for the default (recommended) net can be found as the default
|
||||
value of the `EvalFile` UCI option, with the format `nn-[SHA256 first 12 digits].nnue`
|
||||
(for instance, `nn-c157e0a5755b.nnue`). This file can be downloaded from
|
||||
```
|
||||
@@ -345,10 +355,10 @@ it (either by itself or as part of some bigger software package), or
|
||||
using it as the starting point for a software project of your own.
|
||||
|
||||
The only real limitation is that whenever you distribute Stockfish in
|
||||
some way, you MUST always include the full source code, or a pointer
|
||||
to where the source code can be found, to generate the exact binary
|
||||
you are distributing. If you make any changes to the source code,
|
||||
these changes must also be made available under the GPL.
|
||||
some way, you MUST always include the license and the full source code
|
||||
(or a pointer to where the source code can be found) to generate the
|
||||
exact binary you are distributing. If you make any changes to the
|
||||
source code, these changes must also be made available under the GPL v3.
|
||||
|
||||
For full details, read the copy of the GPL v3 found in the file named
|
||||
[*Copying.txt*](https://github.com/official-stockfish/Stockfish/blob/master/Copying.txt).
|
||||
|
||||
+93
-68
@@ -1,118 +1,127 @@
|
||||
Contributors to Fishtest with >10,000 CPU hours, as of Jun 29, 2021.
|
||||
Contributors to Fishtest with >10,000 CPU hours, as of 2022-02-05.
|
||||
Thank you!
|
||||
|
||||
Username CPU Hours Games played
|
||||
-----------------------------------------------------
|
||||
noobpwnftw 27649494 1834734733
|
||||
mlang 1426107 89454622
|
||||
dew 1380910 82831648
|
||||
------------------------------------------------------------------
|
||||
noobpwnftw 30730952 2158431735
|
||||
mlang 2729669 187335452
|
||||
technologov 1696847 74478658
|
||||
dew 1635640 97483012
|
||||
grandphish2 1062754 64955639
|
||||
tvijlbrief 795993 51894442
|
||||
okrout 773704 63465204
|
||||
TueRens 766198 47770388
|
||||
mibere 703840 46867607
|
||||
grandphish2 692707 41737913
|
||||
tvijlbrief 669642 42371594
|
||||
JojoM 597778 35297180
|
||||
TueRens 519226 31823562
|
||||
cw 458421 30307421
|
||||
fastgm 439667 25950040
|
||||
gvreuls 436599 28177460
|
||||
JojoM 703005 42689868
|
||||
pemo 634102 29868807
|
||||
linrock 626939 17408017
|
||||
gvreuls 517442 33605006
|
||||
cw 503905 33850487
|
||||
fastgm 482847 29004732
|
||||
crunchy 427035 27344275
|
||||
CSU_Dynasty 374765 25106278
|
||||
Fisherman 326901 21822979
|
||||
ctoks 325477 21767943
|
||||
velislav 295343 18844324
|
||||
linrock 292789 10624427
|
||||
bcross 278584 19488961
|
||||
okrout 262818 13803272
|
||||
pemo 245982 11376085
|
||||
CSU_Dynasty 415864 28116776
|
||||
ctoks 403102 26737127
|
||||
oz 357710 26490208
|
||||
bcross 331095 23165889
|
||||
Fisherman 327231 21829379
|
||||
velislav 321708 20729264
|
||||
leszek 303654 19063973
|
||||
Dantist 251015 15843226
|
||||
mgrabiak 231973 15162494
|
||||
glinscott 217799 13780820
|
||||
leszek 212346 12959025
|
||||
robal 213960 13665726
|
||||
nordlandia 211692 13484886
|
||||
drabel 200914 13755384
|
||||
bking_US 198894 11876016
|
||||
drabel 196463 13450602
|
||||
robal 195473 12375650
|
||||
mgrabiak 187226 12016564
|
||||
Dantist 183202 10990484
|
||||
mhoram 180229 11610075
|
||||
Thanar 179852 12365359
|
||||
vdv 175274 9889046
|
||||
vdv 175544 9904472
|
||||
spams 157128 10319326
|
||||
marrco 150295 9402141
|
||||
marrco 150300 9402229
|
||||
sqrt2 147963 9724586
|
||||
mhoram 141278 8901241
|
||||
vdbergh 137429 8955089
|
||||
CoffeeOne 137100 5024116
|
||||
vdbergh 137041 8926915
|
||||
malala 136182 8002293
|
||||
xoto 133702 9156676
|
||||
davar 122092 7960001
|
||||
xoto 133759 9159372
|
||||
rpngn 131285 8657757
|
||||
davar 122661 7996937
|
||||
dsmith 122059 7570238
|
||||
amicic 119659 7937885
|
||||
Data 113305 8220352
|
||||
BrunoBanani 112960 7436849
|
||||
CypressChess 108321 7759588
|
||||
MaZePallas 102823 6633619
|
||||
sterni1971 100532 5880772
|
||||
sunu 100167 7040199
|
||||
DesolatedDodo 99038 6414626
|
||||
ElbertoOne 99028 7023771
|
||||
skiminki 98123 6478402
|
||||
brabos 92118 6186135
|
||||
oz 92100 6486640
|
||||
cuistot 90358 5351004
|
||||
psk 89957 5984901
|
||||
amicic 89156 5392305
|
||||
sunu 88851 6028873
|
||||
racerschmacer 85712 6119648
|
||||
Vizvezdenec 83761 5344740
|
||||
sschnee 83003 4840890
|
||||
0x3C33 82614 5271253
|
||||
BRAVONE 81239 5054681
|
||||
racerschmacer 80899 5759262
|
||||
cuistot 80300 4606144
|
||||
nssy 76497 5259388
|
||||
teddybaer 75125 5407666
|
||||
Pking_cda 73776 5293873
|
||||
zeryl 73335 4774257
|
||||
jromang 72192 5057715
|
||||
solarlight 70517 5028306
|
||||
dv8silencer 70287 3883992
|
||||
Bobo1239 68515 4652287
|
||||
manap 66273 4121774
|
||||
skiminki 65088 4023328
|
||||
tinker 64333 4268790
|
||||
sschnee 60767 3500800
|
||||
qurashee 57344 3168264
|
||||
yurikvelo 63371 4335060
|
||||
qurashee 61208 3429862
|
||||
robnjr 57262 4053117
|
||||
Wolfgang 57014 3561352
|
||||
Freja 56938 3733019
|
||||
ttruscott 56010 3680085
|
||||
rkl 55132 4164467
|
||||
renouve 53811 3501516
|
||||
finfish 51360 3370515
|
||||
eva42 51272 3599691
|
||||
Calis007 51182 3131552
|
||||
eastorwest 51058 3451555
|
||||
rap 49985 3219146
|
||||
pb00067 49727 3298270
|
||||
Spprtr 48260 3141959
|
||||
bigpen0r 47667 3336927
|
||||
ronaldjerum 47654 3240695
|
||||
bigpen0r 47653 3335327
|
||||
eastorwest 47585 3221629
|
||||
MaxKlaxxMiner 47584 2972142
|
||||
biffhero 46564 3111352
|
||||
megaman7de 45992 2952006
|
||||
Fifis 45843 3088497
|
||||
VoyagerOne 45476 3452465
|
||||
yurikvelo 44834 3034550
|
||||
speedycpu 43842 3003273
|
||||
jbwiebe 43305 2805433
|
||||
Spprtr 42279 2680153
|
||||
DesolatedDodo 42007 2447516
|
||||
Antihistamine 41788 2761312
|
||||
mhunt 41735 2691355
|
||||
homyur 39893 2850481
|
||||
gri 39871 2515779
|
||||
Fifis 38776 2529121
|
||||
oryx 38724 2966648
|
||||
SC 37290 2731014
|
||||
oryx 38867 2976992
|
||||
SC 37299 2731694
|
||||
Garf 37213 2986270
|
||||
csnodgrass 36207 2688994
|
||||
jmdana 36157 2210661
|
||||
strelock 34716 2074055
|
||||
rpngn 33951 2057395
|
||||
Garf 33922 2751802
|
||||
EthanOConnor 33370 2090311
|
||||
slakovv 32915 2021889
|
||||
armo9494 32129 2551682
|
||||
tolkki963 32114 1932256
|
||||
manapbk 30987 1810399
|
||||
DMBK 30675 2383552
|
||||
Prcuvu 30377 2170122
|
||||
anst 30301 2190091
|
||||
jkiiski 30136 1904470
|
||||
gopeto 29886 1979118
|
||||
hyperbolic.tom 29840 2017394
|
||||
chuckstablers 29659 2093438
|
||||
Pyafue 29650 1902349
|
||||
Wolfgang 29260 1658936
|
||||
zeryl 28156 1579911
|
||||
OuaisBla 27636 1578800
|
||||
DMBK 27051 1999456
|
||||
chriswk 26902 1868317
|
||||
achambord 26582 1767323
|
||||
Patrick_G 26276 1801617
|
||||
@@ -121,11 +130,13 @@ SFTUser 25182 1675689
|
||||
nabildanial 24942 1519409
|
||||
Sharaf_DG 24765 1786697
|
||||
ncfish1 24411 1520927
|
||||
rodneyc 24227 1409514
|
||||
rodneyc 24275 1410450
|
||||
agg177 23890 1395014
|
||||
belzedar94 23707 1593860
|
||||
JanErik 23408 1703875
|
||||
Isidor 23388 1680691
|
||||
Norabor 23164 1591830
|
||||
Norabor 23339 1602636
|
||||
Ente 23093 1642458
|
||||
cisco2015 22897 1762669
|
||||
Zirie 22542 1472937
|
||||
team-oh 22272 1636708
|
||||
@@ -138,68 +149,82 @@ nesoneg 21494 1463031
|
||||
sphinx 21211 1384728
|
||||
jjoshua2 21001 1423089
|
||||
horst.prack 20878 1465656
|
||||
Ente 20865 1477066
|
||||
user213718 20783 1379584
|
||||
0xB00B1ES 20590 1208666
|
||||
j3corre 20405 941444
|
||||
Adrian.Schmidt123 20316 1281436
|
||||
wei 19973 1745989
|
||||
MaxKlaxxMiner 19850 1009176
|
||||
Roady 19848 1335928
|
||||
rstoesser 19569 1293588
|
||||
gopeto 19491 1174952
|
||||
eudhan 19274 1283717
|
||||
vulcan 18871 1729392
|
||||
jundery 18445 1115855
|
||||
megaman7de 18377 1067540
|
||||
iisiraider 18247 1101015
|
||||
ville 17883 1384026
|
||||
chris 17698 1487385
|
||||
purplefishies 17595 1092533
|
||||
dju 17353 978595
|
||||
kdave 17183 1242754
|
||||
DragonLord 17014 1162790
|
||||
thirdlife 16996 447356
|
||||
spcc 16932 1130940
|
||||
fishtester 16644 1123000
|
||||
Ulysses 16490 1184400
|
||||
IgorLeMasson 16064 1147232
|
||||
ako027ako 15671 1173203
|
||||
chuckstablers 15289 891576
|
||||
Nikolay.IT 15154 1068349
|
||||
Andrew Grant 15114 895539
|
||||
OssumOpossum 14857 1007129
|
||||
Karby 14808 867120
|
||||
AndreasKrug 14608 1152093
|
||||
enedene 14476 905279
|
||||
jsys14 14340 844792
|
||||
bpfliegel 14298 884523
|
||||
mpx86 14019 759568
|
||||
jpulman 13982 870599
|
||||
crocogoat 13803 1117422
|
||||
joster 13794 950160
|
||||
Nesa92 13786 1114691
|
||||
mbeier 13650 1044928
|
||||
Hjax 13535 915487
|
||||
jsys14 13459 785000
|
||||
Dark_wizzie 13422 1007152
|
||||
Rudolphous 13244 883140
|
||||
MarcusTullius 13221 843169
|
||||
Machariel 13010 863104
|
||||
mabichito 12903 749391
|
||||
thijsk 12886 722107
|
||||
AdrianSA 12860 804972
|
||||
infinigon 12807 937332
|
||||
Flopzee 12698 894821
|
||||
fatmurphy 12547 853210
|
||||
Rudolphous 12520 832340
|
||||
scuzzi 12511 845761
|
||||
SapphireBrand 12416 969604
|
||||
modolief 12386 896470
|
||||
Machariel 12335 810784
|
||||
Farseer 12249 694108
|
||||
pgontarz 12151 848794
|
||||
stocky 11954 699440
|
||||
mschmidt 11941 803401
|
||||
dbernier 11609 818636
|
||||
Maxim 11543 836024
|
||||
pirt 11516 894513
|
||||
infinity 11470 727027
|
||||
aga 11409 695071
|
||||
torbjo 11395 729145
|
||||
Thomas A. Anderson 11372 732094
|
||||
savage84 11358 670860
|
||||
markkulix 11331 739098
|
||||
FormazChar 11308 847735
|
||||
d64 11263 789184
|
||||
MooTheCow 11237 720174
|
||||
snicolet 11106 869170
|
||||
ali-al-zhrani 11086 767926
|
||||
AndreasKrug 10875 887457
|
||||
pirt 10806 836519
|
||||
ali-al-zhrani 11098 768494
|
||||
whelanh 11067 235676
|
||||
basepi 10637 744851
|
||||
michaelrpg 10508 739039
|
||||
Cubox 10621 826448
|
||||
michaelrpg 10509 739239
|
||||
OIVAS7572 10420 995586
|
||||
dzjp 10343 732529
|
||||
aga 10302 622975
|
||||
Garruk 10332 703905
|
||||
ols 10259 570669
|
||||
lbraesch 10252 647825
|
||||
FormazChar 10059 757283
|
||||
Jackfish 10098 682338
|
||||
|
||||
@@ -1,88 +0,0 @@
|
||||
version: 1.0.{build}
|
||||
clone_depth: 50
|
||||
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
|
||||
# Operating system (build VM template)
|
||||
os: Visual Studio 2019
|
||||
|
||||
# Build platform, i.e. x86, x64, AnyCPU. This setting is optional.
|
||||
platform:
|
||||
- x86
|
||||
- x64
|
||||
|
||||
# build Configuration, i.e. Debug, Release, etc.
|
||||
configuration:
|
||||
- Debug
|
||||
- Release
|
||||
|
||||
matrix:
|
||||
# The build fail immediately once one of the job fails
|
||||
fast_finish: true
|
||||
|
||||
# Scripts that are called at very beginning, before repo cloning
|
||||
init:
|
||||
- cmake --version
|
||||
- msbuild /version
|
||||
|
||||
before_build:
|
||||
- ps: |
|
||||
# Get sources
|
||||
$src = get-childitem -Path *.cpp -Recurse | select -ExpandProperty FullName
|
||||
$src = $src -join ' '
|
||||
$src = $src.Replace("\", "/")
|
||||
|
||||
# Build CMakeLists.txt
|
||||
$t = 'cmake_minimum_required(VERSION 3.17)',
|
||||
'project(Stockfish)',
|
||||
'set(CMAKE_CXX_STANDARD 17)',
|
||||
'set(CMAKE_CXX_STANDARD_REQUIRED ON)',
|
||||
'set (CMAKE_CXX_EXTENSIONS OFF)',
|
||||
'set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/src)',
|
||||
'set(source_files', $src, ')',
|
||||
'add_executable(stockfish ${source_files})'
|
||||
|
||||
# Write CMakeLists.txt withouth BOM
|
||||
$MyPath = (Get-Item -Path "." -Verbose).FullName + '\CMakeLists.txt'
|
||||
$Utf8NoBomEncoding = New-Object System.Text.UTF8Encoding $False
|
||||
[System.IO.File]::WriteAllLines($MyPath, $t, $Utf8NoBomEncoding)
|
||||
|
||||
# Obtain bench reference from git log
|
||||
$b = git log HEAD | sls "\b[Bb]ench[ :]+[0-9]{7}" | select -first 1
|
||||
$bench = $b -match '\D+(\d+)' | % { $matches[1] }
|
||||
Write-Host "Reference bench:" $bench
|
||||
$g = "Visual Studio 16 2019"
|
||||
If (${env:PLATFORM} -eq 'x64') { $a = "x64" }
|
||||
If (${env:PLATFORM} -eq 'x86') { $a = "Win32" }
|
||||
cmake -G "${g}" -A ${a} .
|
||||
Write-Host "Generated files for: " $g $a
|
||||
|
||||
build_script:
|
||||
- cmake --build . --config %CONFIGURATION% -- /verbosity:minimal
|
||||
- ps: |
|
||||
# Download default NNUE net from fishtest
|
||||
$nnuenet = Get-Content -Path src\evaluate.h | Select-String -CaseSensitive -Pattern "EvalFileDefaultName" | Select-String -CaseSensitive -Pattern "nn-[a-z0-9]{12}.nnue"
|
||||
$dummy = $nnuenet -match "(?<nnuenet>nn-[a-z0-9]{12}.nnue)"
|
||||
$nnuenet = $Matches.nnuenet
|
||||
Write-Host "Default net:" $nnuenet
|
||||
$nnuedownloadurl = "https://tests.stockfishchess.org/api/nn/$nnuenet"
|
||||
$nnuefilepath = "src\${env:CONFIGURATION}\$nnuenet"
|
||||
if (Test-Path -Path $nnuefilepath) {
|
||||
Write-Host "Already available."
|
||||
} else {
|
||||
Write-Host "Downloading $nnuedownloadurl to $nnuefilepath"
|
||||
Invoke-WebRequest -Uri $nnuedownloadurl -OutFile $nnuefilepath
|
||||
}
|
||||
|
||||
before_test:
|
||||
- cd src/%CONFIGURATION%
|
||||
- stockfish bench 2> out.txt >NUL
|
||||
- ps: |
|
||||
# Verify bench number
|
||||
$s = (gc "./out.txt" | out-string)
|
||||
$r = ($s -match 'Nodes searched \D+(\d+)' | % { $matches[1] })
|
||||
Write-Host "Engine bench:" $r
|
||||
Write-Host "Reference bench:" $bench
|
||||
If ($r -ne $bench) { exit 1 }
|
||||
+98
-48
@@ -1,5 +1,5 @@
|
||||
# Stockfish, a UCI chess playing engine derived from Glaurung 2.1
|
||||
# Copyright (C) 2004-2021 The Stockfish developers (see AUTHORS file)
|
||||
# Copyright (C) 2004-2022 The Stockfish developers (see AUTHORS file)
|
||||
#
|
||||
# Stockfish is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@@ -19,11 +19,29 @@
|
||||
### Section 1. General Configuration
|
||||
### ==========================================================================
|
||||
|
||||
### Establish the operating system name
|
||||
KERNEL = $(shell uname -s)
|
||||
ifeq ($(KERNEL),Linux)
|
||||
OS = $(shell uname -o)
|
||||
endif
|
||||
|
||||
### Target Windows OS
|
||||
ifeq ($(OS),Windows_NT)
|
||||
ifneq ($(COMP),ndk)
|
||||
target_windows = yes
|
||||
endif
|
||||
else ifeq ($(COMP),mingw)
|
||||
target_windows = yes
|
||||
ifeq ($(WINE_PATH),)
|
||||
WINE_PATH = $(shell which wine)
|
||||
endif
|
||||
endif
|
||||
|
||||
### Executable name
|
||||
ifeq ($(COMP),mingw)
|
||||
EXE = stockfish.exe
|
||||
ifeq ($(target_windows),yes)
|
||||
EXE = stockfish.exe
|
||||
else
|
||||
EXE = stockfish
|
||||
EXE = stockfish
|
||||
endif
|
||||
|
||||
### Installation dir definitions
|
||||
@@ -32,9 +50,9 @@ BINDIR = $(PREFIX)/bin
|
||||
|
||||
### Built-in benchmark for pgo-builds
|
||||
ifeq ($(SDE_PATH),)
|
||||
PGOBENCH = ./$(EXE) bench
|
||||
PGOBENCH = $(WINE_PATH) ./$(EXE) bench
|
||||
else
|
||||
PGOBENCH = $(SDE_PATH) -- ./$(EXE) bench
|
||||
PGOBENCH = $(SDE_PATH) -- $(WINE_PATH) ./$(EXE) bench
|
||||
endif
|
||||
|
||||
### Source and object files
|
||||
@@ -47,12 +65,6 @@ OBJS = $(notdir $(SRCS:.cpp=.o))
|
||||
|
||||
VPATH = syzygy:nnue:nnue/features
|
||||
|
||||
### Establish the operating system name
|
||||
KERNEL = $(shell uname -s)
|
||||
ifeq ($(KERNEL),Linux)
|
||||
OS = $(shell uname -o)
|
||||
endif
|
||||
|
||||
### ==========================================================================
|
||||
### Section 2. High-level Configuration
|
||||
### ==========================================================================
|
||||
@@ -78,6 +90,7 @@ endif
|
||||
# ssse3 = yes/no --- -mssse3 --- Use Intel Supplemental Streaming SIMD Extensions 3
|
||||
# sse41 = yes/no --- -msse4.1 --- Use Intel Streaming SIMD Extensions 4.1
|
||||
# avx2 = yes/no --- -mavx2 --- Use Intel Advanced Vector Extensions 2
|
||||
# avxvnni = yes/no --- -mavxvnni --- Use Intel Vector Neural Network Instructions AVX
|
||||
# avx512 = yes/no --- -mavx512bw --- Use Intel Advanced Vector Extensions 512
|
||||
# vnni256 = yes/no --- -mavx512vnni --- Use Intel Vector Neural Network Instructions 256
|
||||
# vnni512 = yes/no --- -mavx512vnni --- Use Intel Vector Neural Network Instructions 512
|
||||
@@ -101,8 +114,8 @@ endif
|
||||
# explicitly check for the list of supported architectures (as listed with make help),
|
||||
# the user can override with `make ARCH=x86-32-vnni256 SUPPORTED_ARCH=true`
|
||||
ifeq ($(ARCH), $(filter $(ARCH), \
|
||||
x86-64-vnni512 x86-64-vnni256 x86-64-avx512 x86-64-bmi2 x86-64-avx2 \
|
||||
x86-64-sse41-popcnt x86-64-modern x86-64-ssse3 x86-64-sse3-popcnt \
|
||||
x86-64-vnni512 x86-64-vnni256 x86-64-avx512 x86-64-avxvnni x86-64-bmi2 \
|
||||
x86-64-avx2 x86-64-sse41-popcnt x86-64-modern x86-64-ssse3 x86-64-sse3-popcnt \
|
||||
x86-64 x86-32-sse41-popcnt x86-32-sse2 x86-32 ppc-64 ppc-32 e2k \
|
||||
armv7 armv7-neon armv8 apple-silicon general-64 general-32))
|
||||
SUPPORTED_ARCH=true
|
||||
@@ -123,11 +136,13 @@ sse2 = no
|
||||
ssse3 = no
|
||||
sse41 = no
|
||||
avx2 = no
|
||||
avxvnni = no
|
||||
avx512 = no
|
||||
vnni256 = no
|
||||
vnni512 = no
|
||||
neon = no
|
||||
mpi = no
|
||||
arm_version = 0
|
||||
STRIP = strip
|
||||
|
||||
### 2.2 Architecture specific
|
||||
@@ -139,7 +154,7 @@ ifeq ($(findstring x86,$(ARCH)),x86)
|
||||
ifeq ($(findstring x86-32,$(ARCH)),x86-32)
|
||||
arch = i386
|
||||
bits = 32
|
||||
sse = yes
|
||||
sse = no
|
||||
mmx = yes
|
||||
else
|
||||
arch = x86_64
|
||||
@@ -194,6 +209,17 @@ ifeq ($(findstring -avx2,$(ARCH)),-avx2)
|
||||
avx2 = yes
|
||||
endif
|
||||
|
||||
ifeq ($(findstring -avxvnni,$(ARCH)),-avxvnni)
|
||||
popcnt = yes
|
||||
sse = yes
|
||||
sse2 = yes
|
||||
ssse3 = yes
|
||||
sse41 = yes
|
||||
avx2 = yes
|
||||
avxvnni = yes
|
||||
pext = yes
|
||||
endif
|
||||
|
||||
ifeq ($(findstring -bmi2,$(ARCH)),-bmi2)
|
||||
popcnt = yes
|
||||
sse = yes
|
||||
@@ -264,6 +290,7 @@ ifeq ($(ARCH),armv7)
|
||||
arch = armv7
|
||||
prefetch = yes
|
||||
bits = 32
|
||||
arm_version = 7
|
||||
endif
|
||||
|
||||
ifeq ($(ARCH),armv7-neon)
|
||||
@@ -272,6 +299,7 @@ ifeq ($(ARCH),armv7-neon)
|
||||
popcnt = yes
|
||||
neon = yes
|
||||
bits = 32
|
||||
arm_version = 7
|
||||
endif
|
||||
|
||||
ifeq ($(ARCH),armv8)
|
||||
@@ -279,6 +307,7 @@ ifeq ($(ARCH),armv8)
|
||||
prefetch = yes
|
||||
popcnt = yes
|
||||
neon = yes
|
||||
arm_version = 8
|
||||
endif
|
||||
|
||||
ifeq ($(ARCH),apple-silicon)
|
||||
@@ -286,6 +315,7 @@ ifeq ($(ARCH),apple-silicon)
|
||||
prefetch = yes
|
||||
popcnt = yes
|
||||
neon = yes
|
||||
arm_version = 8
|
||||
endif
|
||||
|
||||
ifeq ($(ARCH),ppc-32)
|
||||
@@ -349,29 +379,27 @@ ifeq ($(COMP),gcc)
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(target_windows),yes)
|
||||
LDFLAGS += -static
|
||||
endif
|
||||
|
||||
ifeq ($(COMP),mingw)
|
||||
comp=mingw
|
||||
|
||||
ifeq ($(KERNEL),Linux)
|
||||
ifeq ($(bits),64)
|
||||
ifeq ($(shell which x86_64-w64-mingw32-c++-posix),)
|
||||
ifeq ($(shell which x86_64-w64-mingw32-c++-posix 2> /dev/null),)
|
||||
CXX=x86_64-w64-mingw32-c++
|
||||
else
|
||||
CXX=x86_64-w64-mingw32-c++-posix
|
||||
endif
|
||||
else
|
||||
ifeq ($(shell which i686-w64-mingw32-c++-posix),)
|
||||
ifeq ($(shell which i686-w64-mingw32-c++-posix 2> /dev/null),)
|
||||
CXX=i686-w64-mingw32-c++
|
||||
else
|
||||
CXX=i686-w64-mingw32-c++-posix
|
||||
endif
|
||||
endif
|
||||
else
|
||||
CXX=g++
|
||||
endif
|
||||
|
||||
CXXFLAGS += -pedantic -Wextra -Wshadow
|
||||
LDFLAGS += -static
|
||||
endif
|
||||
|
||||
ifeq ($(COMP),icc)
|
||||
@@ -383,17 +411,19 @@ endif
|
||||
ifeq ($(COMP),clang)
|
||||
comp=clang
|
||||
CXX=clang++
|
||||
ifeq ($(target_windows),yes)
|
||||
CXX=x86_64-w64-mingw32-clang++
|
||||
endif
|
||||
|
||||
CXXFLAGS += -pedantic -Wextra -Wshadow
|
||||
|
||||
ifneq ($(KERNEL),Darwin)
|
||||
ifneq ($(KERNEL),OpenBSD)
|
||||
ifneq ($(KERNEL),FreeBSD)
|
||||
ifeq ($(filter $(KERNEL),Darwin OpenBSD FreeBSD),)
|
||||
ifeq ($(target_windows),)
|
||||
ifneq ($(RTLIB),compiler-rt)
|
||||
LDFLAGS += -latomic
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(arch),$(filter $(arch),armv7 armv8))
|
||||
ifeq ($(OS),Android)
|
||||
@@ -425,11 +455,19 @@ ifeq ($(COMP),ndk)
|
||||
ifeq ($(arch),armv7)
|
||||
CXX=armv7a-linux-androideabi16-clang++
|
||||
CXXFLAGS += -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon
|
||||
ifneq ($(shell which arm-linux-androideabi-strip 2>/dev/null),)
|
||||
STRIP=arm-linux-androideabi-strip
|
||||
else
|
||||
STRIP=llvm-strip
|
||||
endif
|
||||
endif
|
||||
ifeq ($(arch),armv8)
|
||||
CXX=aarch64-linux-android21-clang++
|
||||
ifneq ($(shell which aarch64-linux-android-strip 2>/dev/null),)
|
||||
STRIP=aarch64-linux-android-strip
|
||||
else
|
||||
STRIP=llvm-strip
|
||||
endif
|
||||
endif
|
||||
LDFLAGS += -static-libstdc++ -pie -lm -latomic
|
||||
endif
|
||||
@@ -443,6 +481,9 @@ else ifeq ($(comp),clang)
|
||||
else
|
||||
profile_make = gcc-profile-make
|
||||
profile_use = gcc-profile-use
|
||||
ifeq ($(KERNEL),Darwin)
|
||||
EXTRAPROFILEFLAGS = -fvisibility=hidden
|
||||
endif
|
||||
endif
|
||||
|
||||
### Travis CI script uses COMPILER to overwrite CXX
|
||||
@@ -503,10 +544,16 @@ ifeq ($(optimize),yes)
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(comp),$(filter $(comp),gcc clang icc))
|
||||
ifeq ($(KERNEL),Darwin)
|
||||
ifeq ($(comp),$(filter $(comp),clang icc))
|
||||
CXXFLAGS += -mdynamic-no-pic
|
||||
endif
|
||||
|
||||
ifeq ($(comp),gcc)
|
||||
ifneq ($(arch),arm64)
|
||||
CXXFLAGS += -mdynamic-no-pic
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(comp),clang)
|
||||
@@ -546,6 +593,13 @@ ifeq ($(avx2),yes)
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(avxvnni),yes)
|
||||
CXXFLAGS += -DUSE_VNNI -DUSE_AVXVNNI
|
||||
ifeq ($(comp),$(filter $(comp),gcc clang mingw))
|
||||
CXXFLAGS += -mavxvnni
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(avx512),yes)
|
||||
CXXFLAGS += -DUSE_AVX512
|
||||
ifeq ($(comp),$(filter $(comp),gcc clang mingw))
|
||||
@@ -596,7 +650,7 @@ ifeq ($(mmx),yes)
|
||||
endif
|
||||
|
||||
ifeq ($(neon),yes)
|
||||
CXXFLAGS += -DUSE_NEON
|
||||
CXXFLAGS += -DUSE_NEON=$(arm_version)
|
||||
ifeq ($(KERNEL),Linux)
|
||||
ifneq ($(COMP),ndk)
|
||||
ifneq ($(arch),armv8)
|
||||
@@ -621,9 +675,7 @@ ifeq ($(optimize),yes)
|
||||
ifeq ($(debug), no)
|
||||
ifeq ($(comp),clang)
|
||||
CXXFLAGS += -flto
|
||||
ifneq ($(findstring MINGW,$(KERNEL)),)
|
||||
CXXFLAGS += -fuse-ld=lld
|
||||
else ifneq ($(findstring MSYS,$(KERNEL)),)
|
||||
ifeq ($(target_windows),yes)
|
||||
CXXFLAGS += -fuse-ld=lld
|
||||
endif
|
||||
LDFLAGS += $(CXXFLAGS)
|
||||
@@ -634,25 +686,17 @@ ifeq ($(debug), no)
|
||||
ifeq ($(gccisclang),)
|
||||
CXXFLAGS += -flto
|
||||
LDFLAGS += $(CXXFLAGS) -flto=jobserver
|
||||
ifneq ($(findstring MINGW,$(KERNEL)),)
|
||||
LDFLAGS += -save-temps
|
||||
else ifneq ($(findstring MSYS,$(KERNEL)),)
|
||||
LDFLAGS += -save-temps
|
||||
endif
|
||||
else
|
||||
CXXFLAGS += -flto
|
||||
LDFLAGS += $(CXXFLAGS)
|
||||
endif
|
||||
|
||||
# To use LTO and static linking on windows, the tool chain requires a recent gcc:
|
||||
# gcc version 10.1 in msys2 or TDM-GCC version 9.2 are known to work, older might not.
|
||||
# So, only enable it for a cross from Linux by default.
|
||||
# To use LTO and static linking on Windows,
|
||||
# the tool chain requires gcc version 10.1 or later.
|
||||
else ifeq ($(comp),mingw)
|
||||
ifeq ($(KERNEL),Linux)
|
||||
ifneq ($(arch),i386)
|
||||
CXXFLAGS += -flto
|
||||
LDFLAGS += $(CXXFLAGS) -flto=jobserver
|
||||
endif
|
||||
LDFLAGS += $(CXXFLAGS) -save-temps
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
@@ -700,6 +744,7 @@ help:
|
||||
@echo "x86-64-vnni512 > x86 64-bit with vnni support 512bit wide"
|
||||
@echo "x86-64-vnni256 > x86 64-bit with vnni support 256bit wide"
|
||||
@echo "x86-64-avx512 > x86 64-bit with avx512 support"
|
||||
@echo "x86-64-avxvnni > x86 64-bit with avxvnni support"
|
||||
@echo "x86-64-bmi2 > x86 64-bit with bmi2 support"
|
||||
@echo "x86-64-avx2 > x86 64-bit with avx2 support"
|
||||
@echo "x86-64-sse41-popcnt > x86 64-bit with sse41 and popcnt support"
|
||||
@@ -762,7 +807,7 @@ profile-build: net config-sanity objclean profileclean
|
||||
$(MAKE) ARCH=$(ARCH) COMP=$(COMP) $(profile_make)
|
||||
@echo ""
|
||||
@echo "Step 2/4. Running benchmark for pgo-build ..."
|
||||
$(PGOBENCH) > /dev/null
|
||||
$(PGOBENCH) 2>&1 | tail -n 4
|
||||
@echo ""
|
||||
@echo "Step 3/4. Building optimized executable ..."
|
||||
$(MAKE) ARCH=$(ARCH) COMP=$(COMP) objclean
|
||||
@@ -777,7 +822,7 @@ strip:
|
||||
install:
|
||||
-mkdir -p -m 755 $(BINDIR)
|
||||
-cp $(EXE) $(BINDIR)
|
||||
-strip $(BINDIR)/$(EXE)
|
||||
$(STRIP) $(BINDIR)/$(EXE)
|
||||
|
||||
# clean all
|
||||
clean: objclean profileclean
|
||||
@@ -809,15 +854,16 @@ net:
|
||||
|
||||
# clean binaries and objects
|
||||
objclean:
|
||||
@rm -f $(EXE) *.o ./syzygy/*.o ./nnue/*.o ./nnue/features/*.o
|
||||
@rm -f stockfish stockfish.exe *.o ./syzygy/*.o ./nnue/*.o ./nnue/features/*.o
|
||||
|
||||
# clean auxiliary profiling files
|
||||
profileclean:
|
||||
@rm -rf profdir
|
||||
@rm -f bench.txt *.gcda *.gcno ./syzygy/*.gcda ./nnue/*.gcda ./nnue/features/*.gcda *.s
|
||||
@rm -f stockfish.profdata *.profraw
|
||||
@rm -f stockfish.exe.lto_wrapper_args
|
||||
@rm -f stockfish.exe.ltrans.out
|
||||
@rm -f stockfish.*args*
|
||||
@rm -f stockfish.*lt*
|
||||
@rm -f stockfish.res
|
||||
@rm -f ./-lstdc++.res
|
||||
|
||||
default:
|
||||
@@ -848,11 +894,13 @@ config-sanity: net
|
||||
@echo "ssse3: '$(ssse3)'"
|
||||
@echo "sse41: '$(sse41)'"
|
||||
@echo "avx2: '$(avx2)'"
|
||||
@echo "avxvnni: '$(avxvnni)'"
|
||||
@echo "avx512: '$(avx512)'"
|
||||
@echo "vnni256: '$(vnni256)'"
|
||||
@echo "vnni512: '$(vnni512)'"
|
||||
@echo "neon: '$(neon)'"
|
||||
@echo "mpi: '$(mpi)'"
|
||||
@echo "arm_version: '$(arm_version)'"
|
||||
@echo ""
|
||||
@echo "Flags:"
|
||||
@echo "CXX: $(CXX)"
|
||||
@@ -904,12 +952,14 @@ gcc-profile-make:
|
||||
@mkdir -p profdir
|
||||
$(MAKE) ARCH=$(ARCH) COMP=$(COMP) \
|
||||
EXTRACXXFLAGS='-fprofile-generate=profdir' \
|
||||
EXTRACXXFLAGS+=$(EXTRAPROFILEFLAGS) \
|
||||
EXTRALDFLAGS='-lgcov' \
|
||||
all
|
||||
|
||||
gcc-profile-use:
|
||||
$(MAKE) ARCH=$(ARCH) COMP=$(COMP) \
|
||||
EXTRACXXFLAGS='-fprofile-use=profdir -fno-peel-loops -fno-tracer' \
|
||||
EXTRACXXFLAGS+=$(EXTRAPROFILEFLAGS) \
|
||||
EXTRALDFLAGS='-lgcov' \
|
||||
all
|
||||
|
||||
|
||||
+2
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Stockfish, a UCI chess playing engine derived from Glaurung 2.1
|
||||
Copyright (C) 2004-2021 The Stockfish developers (see AUTHORS file)
|
||||
Copyright (C) 2004-2022 The Stockfish developers (see AUTHORS file)
|
||||
|
||||
Stockfish is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -87,6 +87,7 @@ const vector<string> Defaults = {
|
||||
// Chess 960
|
||||
"setoption name UCI_Chess960 value true",
|
||||
"bbqnnrkr/pppppppp/8/8/8/8/PPPPPPPP/BBQNNRKR w HFhf - 0 1 moves g2g3 d7d5 d2d4 c8h3 c1g5 e8d6 g5e7 f7f6",
|
||||
"nqbnrkrb/pppppppp/8/8/8/8/PPPPPPPP/NQBNRKRB w KQkq - 0 1",
|
||||
"setoption name UCI_Chess960 value false"
|
||||
};
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Stockfish, a UCI chess playing engine derived from Glaurung 2.1
|
||||
Copyright (C) 2004-2021 The Stockfish developers (see AUTHORS file)
|
||||
Copyright (C) 2004-2022 The Stockfish developers (see AUTHORS file)
|
||||
|
||||
Stockfish is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Stockfish, a UCI chess playing engine derived from Glaurung 2.1
|
||||
Copyright (C) 2004-2021 The Stockfish developers (see AUTHORS file)
|
||||
Copyright (C) 2004-2022 The Stockfish developers (see AUTHORS file)
|
||||
|
||||
Stockfish is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Stockfish, a UCI chess playing engine derived from Glaurung 2.1
|
||||
Copyright (C) 2004-2021 The Stockfish developers (see AUTHORS file)
|
||||
Copyright (C) 2004-2022 The Stockfish developers (see AUTHORS file)
|
||||
|
||||
Stockfish is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Stockfish, a UCI chess playing engine derived from Glaurung 2.1
|
||||
Copyright (C) 2004-2021 The Stockfish developers (see AUTHORS file)
|
||||
Copyright (C) 2004-2022 The Stockfish developers (see AUTHORS file)
|
||||
|
||||
Stockfish is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Stockfish, a UCI chess playing engine derived from Glaurung 2.1
|
||||
Copyright (C) 2004-2021 The Stockfish developers (see AUTHORS file)
|
||||
Copyright (C) 2004-2022 The Stockfish developers (see AUTHORS file)
|
||||
|
||||
Stockfish is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
+52
-34
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Stockfish, a UCI chess playing engine derived from Glaurung 2.1
|
||||
Copyright (C) 2004-2021 The Stockfish developers (see AUTHORS file)
|
||||
Copyright (C) 2004-2022 The Stockfish developers (see AUTHORS file)
|
||||
|
||||
Stockfish is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -109,6 +109,7 @@ namespace Eval {
|
||||
|
||||
MemoryBuffer buffer(const_cast<char*>(reinterpret_cast<const char*>(gEmbeddedNNUEData)),
|
||||
size_t(gEmbeddedNNUESize));
|
||||
(void) gEmbeddedNNUEEnd; // Silence warning on unused variable
|
||||
|
||||
istream stream(&buffer);
|
||||
if (load_eval(eval_file, stream))
|
||||
@@ -196,8 +197,8 @@ using namespace Trace;
|
||||
namespace {
|
||||
|
||||
// Threshold for lazy and space evaluation
|
||||
constexpr Value LazyThreshold1 = Value(3130);
|
||||
constexpr Value LazyThreshold2 = Value(2204);
|
||||
constexpr Value LazyThreshold1 = Value(3631);
|
||||
constexpr Value LazyThreshold2 = Value(2084);
|
||||
constexpr Value SpaceThreshold = Value(11551);
|
||||
|
||||
// KingAttackWeights[PieceType] contains king attack weights by piece type
|
||||
@@ -232,58 +233,58 @@ namespace {
|
||||
// BishopPawns[distance from edge] contains a file-dependent penalty for pawns on
|
||||
// squares of the same color as our bishop.
|
||||
constexpr Score BishopPawns[int(FILE_NB) / 2] = {
|
||||
S(3, 8), S(3, 9), S(2, 8), S(3, 8)
|
||||
S(3, 8), S(3, 9), S(2, 7), S(3, 7)
|
||||
};
|
||||
|
||||
// KingProtector[knight/bishop] contains penalty for each distance unit to own king
|
||||
constexpr Score KingProtector[] = { S(8, 9), S(6, 9) };
|
||||
constexpr Score KingProtector[] = { S(9, 9), S(7, 9) };
|
||||
|
||||
// Outpost[knight/bishop] contains bonuses for each knight or bishop occupying a
|
||||
// pawn protected square on rank 4 to 6 which is also safe from a pawn attack.
|
||||
constexpr Score Outpost[] = { S(57, 38), S(31, 24) };
|
||||
constexpr Score Outpost[] = { S(54, 34), S(31, 25) };
|
||||
|
||||
// PassedRank[Rank] contains a bonus according to the rank of a passed pawn
|
||||
constexpr Score PassedRank[RANK_NB] = {
|
||||
S(0, 0), S(7, 27), S(16, 32), S(17, 40), S(64, 71), S(170, 174), S(278, 262)
|
||||
S(0, 0), S(2, 38), S(15, 36), S(22, 50), S(64, 81), S(166, 184), S(284, 269)
|
||||
};
|
||||
|
||||
constexpr Score RookOnClosedFile = S(10, 5);
|
||||
constexpr Score RookOnOpenFile[] = { S(19, 6), S(47, 26) };
|
||||
constexpr Score RookOnOpenFile[] = { S(18, 8), S(49, 26) };
|
||||
|
||||
// ThreatByMinor/ByRook[attacked PieceType] contains bonuses according to
|
||||
// which piece type attacks which one. Attacks on lesser pieces which are
|
||||
// pawn-defended are not considered.
|
||||
constexpr Score ThreatByMinor[PIECE_TYPE_NB] = {
|
||||
S(0, 0), S(5, 32), S(55, 41), S(77, 56), S(89, 119), S(79, 162)
|
||||
S(0, 0), S(6, 37), S(64, 50), S(82, 57), S(103, 130), S(81, 163)
|
||||
};
|
||||
|
||||
constexpr Score ThreatByRook[PIECE_TYPE_NB] = {
|
||||
S(0, 0), S(3, 44), S(37, 68), S(42, 60), S(0, 39), S(58, 43)
|
||||
S(0, 0), S(3, 44), S(36, 71), S(44, 59), S(0, 39), S(60, 39)
|
||||
};
|
||||
|
||||
constexpr Value CorneredBishop = Value(50);
|
||||
|
||||
// Assorted bonuses and penalties
|
||||
constexpr Score UncontestedOutpost = S( 1, 10);
|
||||
constexpr Score UncontestedOutpost = S( 0, 10);
|
||||
constexpr Score BishopOnKingRing = S( 24, 0);
|
||||
constexpr Score BishopXRayPawns = S( 4, 5);
|
||||
constexpr Score FlankAttacks = S( 8, 0);
|
||||
constexpr Score Hanging = S( 69, 36);
|
||||
constexpr Score Hanging = S( 72, 40);
|
||||
constexpr Score KnightOnQueen = S( 16, 11);
|
||||
constexpr Score LongDiagonalBishop = S( 45, 0);
|
||||
constexpr Score MinorBehindPawn = S( 18, 3);
|
||||
constexpr Score PassedFile = S( 11, 8);
|
||||
constexpr Score PawnlessFlank = S( 17, 95);
|
||||
constexpr Score ReachableOutpost = S( 31, 22);
|
||||
constexpr Score RestrictedPiece = S( 7, 7);
|
||||
constexpr Score PassedFile = S( 13, 8);
|
||||
constexpr Score PawnlessFlank = S( 19, 97);
|
||||
constexpr Score ReachableOutpost = S( 33, 19);
|
||||
constexpr Score RestrictedPiece = S( 6, 7);
|
||||
constexpr Score RookOnKingRing = S( 16, 0);
|
||||
constexpr Score SliderOnQueen = S( 60, 18);
|
||||
constexpr Score ThreatByKing = S( 24, 89);
|
||||
constexpr Score SliderOnQueen = S( 62, 21);
|
||||
constexpr Score ThreatByKing = S( 24, 87);
|
||||
constexpr Score ThreatByPawnPush = S( 48, 39);
|
||||
constexpr Score ThreatBySafePawn = S(173, 94);
|
||||
constexpr Score ThreatBySafePawn = S(167, 99);
|
||||
constexpr Score TrappedRook = S( 55, 13);
|
||||
constexpr Score WeakQueenProtection = S( 14, 0);
|
||||
constexpr Score WeakQueen = S( 56, 15);
|
||||
constexpr Score WeakQueen = S( 57, 19);
|
||||
|
||||
|
||||
#undef S
|
||||
@@ -992,7 +993,9 @@ namespace {
|
||||
|
||||
// Early exit if score is high
|
||||
auto lazy_skip = [&](Value lazyThreshold) {
|
||||
return abs(mg_value(score) + eg_value(score)) > lazyThreshold + pos.non_pawn_material() / 32;
|
||||
return abs(mg_value(score) + eg_value(score)) > lazyThreshold
|
||||
+ std::abs(pos.this_thread()->bestValue) * 5 / 4
|
||||
+ pos.non_pawn_material() / 32;
|
||||
};
|
||||
|
||||
if (lazy_skip(LazyThreshold1))
|
||||
@@ -1071,8 +1074,8 @@ make_v:
|
||||
&& pos.piece_on(SQ_G7) == B_PAWN)
|
||||
correction += CorneredBishop;
|
||||
|
||||
return pos.side_to_move() == WHITE ? Value(5 * correction)
|
||||
: -Value(5 * correction);
|
||||
return pos.side_to_move() == WHITE ? Value(3 * correction)
|
||||
: -Value(3 * correction);
|
||||
}
|
||||
|
||||
} // namespace Eval
|
||||
@@ -1084,27 +1087,37 @@ make_v:
|
||||
Value Eval::evaluate(const Position& pos) {
|
||||
|
||||
Value v;
|
||||
bool useClassical = false;
|
||||
|
||||
// Deciding between classical and NNUE eval: for high PSQ imbalance we use classical,
|
||||
// Deciding between classical and NNUE eval (~10 Elo): for high PSQ imbalance we use classical,
|
||||
// but we switch to NNUE during long shuffling or with high material on the board.
|
||||
|
||||
if ( !useNNUE
|
||||
|| abs(eg_value(pos.psq_score())) * 5 > (850 + pos.non_pawn_material() / 64) * (5 + pos.rule50_count()))
|
||||
v = Evaluation<NO_TRACE>(pos).value(); // classical
|
||||
else
|
||||
|| ((pos.this_thread()->depth > 9 || pos.count<ALL_PIECES>() > 7) &&
|
||||
abs(eg_value(pos.psq_score())) * 5 > (856 + pos.non_pawn_material() / 64) * (5 + pos.rule50_count())))
|
||||
{
|
||||
int scale = 883
|
||||
+ 32 * pos.count<PAWN>()
|
||||
+ 32 * pos.non_pawn_material() / 1024;
|
||||
v = Evaluation<NO_TRACE>(pos).value(); // classical
|
||||
useClassical = abs(v) >= 297;
|
||||
}
|
||||
|
||||
v = NNUE::evaluate(pos, true) * scale / 1024; // NNUE
|
||||
// If result of a classical evaluation is much lower than threshold fall back to NNUE
|
||||
if (useNNUE && !useClassical)
|
||||
{
|
||||
Value nnue = NNUE::evaluate(pos, true); // NNUE
|
||||
int scale = 1036 + 20 * pos.non_pawn_material() / 1024;
|
||||
Color stm = pos.side_to_move();
|
||||
Value optimism = pos.this_thread()->optimism[stm];
|
||||
Value psq = (stm == WHITE ? 1 : -1) * eg_value(pos.psq_score());
|
||||
int complexity = 35 * abs(nnue - psq) / 256;
|
||||
|
||||
optimism = optimism * (44 + complexity) / 31;
|
||||
v = (nnue + optimism) * scale / 1024 - optimism;
|
||||
|
||||
if (pos.is_chess960())
|
||||
v += fix_FRC(pos);
|
||||
}
|
||||
|
||||
// Damp down the evaluation linearly when shuffling
|
||||
v = v * (100 - pos.rule50_count()) / 100;
|
||||
v = v * (207 - pos.rule50_count()) / 207;
|
||||
|
||||
// Guarantee evaluation does not hit the tablebase range
|
||||
v = std::clamp(v, VALUE_TB_LOSS_IN_MAX_PLY + 1, VALUE_TB_WIN_IN_MAX_PLY - 1);
|
||||
@@ -1129,7 +1142,12 @@ std::string Eval::trace(Position& pos) {
|
||||
|
||||
std::memset(scores, 0, sizeof(scores));
|
||||
|
||||
pos.this_thread()->trend = SCORE_ZERO; // Reset any dynamic contempt
|
||||
// Reset any global variable used in eval
|
||||
pos.this_thread()->depth = 0;
|
||||
pos.this_thread()->trend = SCORE_ZERO;
|
||||
pos.this_thread()->bestValue = VALUE_ZERO;
|
||||
pos.this_thread()->optimism[WHITE] = VALUE_ZERO;
|
||||
pos.this_thread()->optimism[BLACK] = VALUE_ZERO;
|
||||
|
||||
v = Evaluation<TRACE>(pos).value();
|
||||
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Stockfish, a UCI chess playing engine derived from Glaurung 2.1
|
||||
Copyright (C) 2004-2021 The Stockfish developers (see AUTHORS file)
|
||||
Copyright (C) 2004-2022 The Stockfish developers (see AUTHORS file)
|
||||
|
||||
Stockfish is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -39,7 +39,7 @@ namespace Eval {
|
||||
// The default net name MUST follow the format nn-[SHA256 first 12 digits].nnue
|
||||
// for the build process (profile-build and fishtest) to work. Do not change the
|
||||
// name of the macro, as it is used in the Makefile.
|
||||
#define EvalFileDefaultName "nn-13406b1dcbe0.nnue"
|
||||
#define EvalFileDefaultName "nn-6877cd24400e.nnue"
|
||||
|
||||
namespace NNUE {
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Stockfish, a UCI chess playing engine derived from Glaurung 2.1
|
||||
Copyright (C) 2004-2021 The Stockfish developers (see AUTHORS file)
|
||||
Copyright (C) 2004-2022 The Stockfish developers (see AUTHORS file)
|
||||
|
||||
Stockfish is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Stockfish, a UCI chess playing engine derived from Glaurung 2.1
|
||||
Copyright (C) 2004-2021 The Stockfish developers (see AUTHORS file)
|
||||
Copyright (C) 2004-2022 The Stockfish developers (see AUTHORS file)
|
||||
|
||||
Stockfish is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Stockfish, a UCI chess playing engine derived from Glaurung 2.1
|
||||
Copyright (C) 2004-2021 The Stockfish developers (see AUTHORS file)
|
||||
Copyright (C) 2004-2022 The Stockfish developers (see AUTHORS file)
|
||||
|
||||
Stockfish is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
+30
-11
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Stockfish, a UCI chess playing engine derived from Glaurung 2.1
|
||||
Copyright (C) 2004-2021 The Stockfish developers (see AUTHORS file)
|
||||
Copyright (C) 2004-2022 The Stockfish developers (see AUTHORS file)
|
||||
|
||||
Stockfish is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -36,6 +36,8 @@ typedef bool(*fun1_t)(LOGICAL_PROCESSOR_RELATIONSHIP,
|
||||
PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX, PDWORD);
|
||||
typedef bool(*fun2_t)(USHORT, PGROUP_AFFINITY);
|
||||
typedef bool(*fun3_t)(HANDLE, CONST GROUP_AFFINITY*, PGROUP_AFFINITY);
|
||||
typedef bool(*fun4_t)(USHORT, PGROUP_AFFINITY, USHORT, PUSHORT);
|
||||
typedef WORD(*fun5_t)();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -67,7 +69,7 @@ namespace {
|
||||
|
||||
/// Version number. If Version is left empty, then compile date in the format
|
||||
/// DD-MM-YY and show in engine_info.
|
||||
const string Version = "14.1";
|
||||
const string Version = "";
|
||||
|
||||
/// Our fancy logging facility. The trick here is to replace cin.rdbuf() and
|
||||
/// cout.rdbuf() with two Tie objects that tie cin and cout to a file stream. We
|
||||
@@ -495,11 +497,11 @@ void bindThisThread(size_t) {}
|
||||
|
||||
#else
|
||||
|
||||
/// best_group() retrieves logical processor information using Windows specific
|
||||
/// API and returns the best group id for the thread with index idx. Original
|
||||
/// best_node() retrieves logical processor information using Windows specific
|
||||
/// API and returns the best node id for the thread with index idx. Original
|
||||
/// code from Texel by Peter Österlund.
|
||||
|
||||
int best_group(size_t idx) {
|
||||
int best_node(size_t idx) {
|
||||
|
||||
int threads = 0;
|
||||
int nodes = 0;
|
||||
@@ -513,7 +515,8 @@ int best_group(size_t idx) {
|
||||
if (!fun1)
|
||||
return -1;
|
||||
|
||||
// First call to get returnLength. We expect it to fail due to null buffer
|
||||
// First call to GetLogicalProcessorInformationEx() to get returnLength.
|
||||
// We expect the call to fail due to null buffer.
|
||||
if (fun1(RelationAll, nullptr, &returnLength))
|
||||
return -1;
|
||||
|
||||
@@ -521,7 +524,7 @@ int best_group(size_t idx) {
|
||||
SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX *buffer, *ptr;
|
||||
ptr = buffer = (SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX*)malloc(returnLength);
|
||||
|
||||
// Second call, now we expect to succeed
|
||||
// Second call to GetLogicalProcessorInformationEx(), now we expect to succeed
|
||||
if (!fun1(RelationAll, buffer, &returnLength))
|
||||
{
|
||||
free(buffer);
|
||||
@@ -571,22 +574,38 @@ int best_group(size_t idx) {
|
||||
void bindThisThread(size_t idx) {
|
||||
|
||||
// Use only local variables to be thread-safe
|
||||
int group = best_group(idx);
|
||||
int node = best_node(idx);
|
||||
|
||||
if (group == -1)
|
||||
if (node == -1)
|
||||
return;
|
||||
|
||||
// Early exit if the needed API are not available at runtime
|
||||
HMODULE k32 = GetModuleHandle("Kernel32.dll");
|
||||
auto fun2 = (fun2_t)(void(*)())GetProcAddress(k32, "GetNumaNodeProcessorMaskEx");
|
||||
auto fun3 = (fun3_t)(void(*)())GetProcAddress(k32, "SetThreadGroupAffinity");
|
||||
auto fun4 = (fun4_t)(void(*)())GetProcAddress(k32, "GetNumaNodeProcessorMask2");
|
||||
auto fun5 = (fun5_t)(void(*)())GetProcAddress(k32, "GetMaximumProcessorGroupCount");
|
||||
|
||||
if (!fun2 || !fun3)
|
||||
return;
|
||||
|
||||
if (!fun4 || !fun5)
|
||||
{
|
||||
GROUP_AFFINITY affinity;
|
||||
if (fun2(group, &affinity))
|
||||
fun3(GetCurrentThread(), &affinity, nullptr);
|
||||
if (fun2(node, &affinity)) // GetNumaNodeProcessorMaskEx
|
||||
fun3(GetCurrentThread(), &affinity, nullptr); // SetThreadGroupAffinity
|
||||
}
|
||||
else
|
||||
{
|
||||
// If a numa node has more than one processor group, we assume they are
|
||||
// sized equal and we spread threads evenly across the groups.
|
||||
USHORT elements, returnedElements;
|
||||
elements = fun5(); // GetMaximumProcessorGroupCount
|
||||
GROUP_AFFINITY *affinity = (GROUP_AFFINITY*)malloc(elements * sizeof(GROUP_AFFINITY));
|
||||
if (fun4(node, affinity, elements, &returnedElements)) // GetNumaNodeProcessorMask2
|
||||
fun3(GetCurrentThread(), &affinity[idx % returnedElements], nullptr); // SetThreadGroupAffinity
|
||||
free(affinity);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
+34
-6
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Stockfish, a UCI chess playing engine derived from Glaurung 2.1
|
||||
Copyright (C) 2004-2021 The Stockfish developers (see AUTHORS file)
|
||||
Copyright (C) 2004-2022 The Stockfish developers (see AUTHORS file)
|
||||
|
||||
Stockfish is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -90,9 +90,6 @@ static inline const bool IsLittleEndian = (Le.c[0] == 4);
|
||||
class RunningAverage {
|
||||
public:
|
||||
|
||||
// Constructor
|
||||
RunningAverage() {}
|
||||
|
||||
// Reset the running average to rational value p / q
|
||||
void set(int64_t p, int64_t q)
|
||||
{ average = p * PERIOD * RESOLUTION / q; }
|
||||
@@ -102,8 +99,11 @@ class RunningAverage {
|
||||
{ average = RESOLUTION * v + (PERIOD - 1) * average / PERIOD; }
|
||||
|
||||
// Test if average is strictly greater than rational a / b
|
||||
bool is_greater(int64_t a, int64_t b)
|
||||
{ return b * average > a * PERIOD * RESOLUTION ; }
|
||||
bool is_greater(int64_t a, int64_t b) const
|
||||
{ return b * average > a * (PERIOD * RESOLUTION); }
|
||||
|
||||
int64_t value() const
|
||||
{ return average / (PERIOD * RESOLUTION); }
|
||||
|
||||
private :
|
||||
static constexpr int64_t PERIOD = 4096;
|
||||
@@ -138,6 +138,34 @@ private:
|
||||
std::size_t size_ = 0;
|
||||
};
|
||||
|
||||
|
||||
/// sigmoid(t, x0, y0, C, P, Q) implements a sigmoid-like function using only integers,
|
||||
/// with the following properties:
|
||||
///
|
||||
/// - sigmoid is centered in (x0, y0)
|
||||
/// - sigmoid has amplitude [-P/Q , P/Q] instead of [-1 , +1]
|
||||
/// - limit is (y0 - P/Q) when t tends to -infinity
|
||||
/// - limit is (y0 + P/Q) when t tends to +infinity
|
||||
/// - the slope can be adjusted using C > 0, smaller C giving a steeper sigmoid
|
||||
/// - the slope of the sigmoid when t = x0 is P/(Q*C)
|
||||
/// - sigmoid is increasing with t when P > 0 and Q > 0
|
||||
/// - to get a decreasing sigmoid, change sign of P
|
||||
/// - mean value of the sigmoid is y0
|
||||
///
|
||||
/// Use <https://www.desmos.com/calculator/jhh83sqq92> to draw the sigmoid
|
||||
|
||||
inline int64_t sigmoid(int64_t t, int64_t x0,
|
||||
int64_t y0,
|
||||
int64_t C,
|
||||
int64_t P,
|
||||
int64_t Q)
|
||||
{
|
||||
assert(C > 0);
|
||||
assert(Q != 0);
|
||||
return y0 + P * (t-x0) / (Q * (std::abs(t-x0) + C)) ;
|
||||
}
|
||||
|
||||
|
||||
/// xorshift64star Pseudo-Random Number Generator
|
||||
/// This class is based on original code written and dedicated
|
||||
/// to the public domain by Sebastiano Vigna (2014).
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Stockfish, a UCI chess playing engine derived from Glaurung 2.1
|
||||
Copyright (C) 2004-2021 The Stockfish developers (see AUTHORS file)
|
||||
Copyright (C) 2004-2022 The Stockfish developers (see AUTHORS file)
|
||||
|
||||
Stockfish is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Stockfish, a UCI chess playing engine derived from Glaurung 2.1
|
||||
Copyright (C) 2004-2021 The Stockfish developers (see AUTHORS file)
|
||||
Copyright (C) 2004-2022 The Stockfish developers (see AUTHORS file)
|
||||
|
||||
Stockfish is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
+54
-17
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Stockfish, a UCI chess playing engine derived from Glaurung 2.1
|
||||
Copyright (C) 2004-2021 The Stockfish developers (see AUTHORS file)
|
||||
Copyright (C) 2004-2022 The Stockfish developers (see AUTHORS file)
|
||||
|
||||
Stockfish is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
#include <cassert>
|
||||
|
||||
#include "bitboard.h"
|
||||
#include "movepick.h"
|
||||
|
||||
namespace Stockfish {
|
||||
@@ -56,11 +57,14 @@ namespace {
|
||||
/// ordering is at the current node.
|
||||
|
||||
/// MovePicker constructor for the main search
|
||||
MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const ButterflyHistory* mh, const LowPlyHistory* lp,
|
||||
const CapturePieceToHistory* cph, const PieceToHistory** ch, Move cm, const Move* killers, int pl)
|
||||
: pos(p), mainHistory(mh), lowPlyHistory(lp), captureHistory(cph), continuationHistory(ch),
|
||||
ttMove(ttm), refutations{{killers[0], 0}, {killers[1], 0}, {cm, 0}}, depth(d), ply(pl) {
|
||||
|
||||
MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const ButterflyHistory* mh,
|
||||
const CapturePieceToHistory* cph,
|
||||
const PieceToHistory** ch,
|
||||
Move cm,
|
||||
const Move* killers)
|
||||
: pos(p), mainHistory(mh), captureHistory(cph), continuationHistory(ch),
|
||||
ttMove(ttm), refutations{{killers[0], 0}, {killers[1], 0}, {cm, 0}}, depth(d)
|
||||
{
|
||||
assert(d > 0);
|
||||
|
||||
stage = (pos.checkers() ? EVASION_TT : MAIN_TT) +
|
||||
@@ -69,9 +73,11 @@ MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const ButterflyHist
|
||||
|
||||
/// MovePicker constructor for quiescence search
|
||||
MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const ButterflyHistory* mh,
|
||||
const CapturePieceToHistory* cph, const PieceToHistory** ch, Square rs)
|
||||
: pos(p), mainHistory(mh), captureHistory(cph), continuationHistory(ch), ttMove(ttm), recaptureSquare(rs), depth(d) {
|
||||
|
||||
const CapturePieceToHistory* cph,
|
||||
const PieceToHistory** ch,
|
||||
Square rs)
|
||||
: pos(p), mainHistory(mh), captureHistory(cph), continuationHistory(ch), ttMove(ttm), recaptureSquare(rs), depth(d)
|
||||
{
|
||||
assert(d <= 0);
|
||||
|
||||
stage = (pos.checkers() ? EVASION_TT : QSEARCH_TT) +
|
||||
@@ -82,9 +88,9 @@ MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const ButterflyHist
|
||||
|
||||
/// MovePicker constructor for ProbCut: we generate captures with SEE greater
|
||||
/// than or equal to the given threshold.
|
||||
MovePicker::MovePicker(const Position& p, Move ttm, Value th, const CapturePieceToHistory* cph)
|
||||
: pos(p), captureHistory(cph), ttMove(ttm), threshold(th) {
|
||||
|
||||
MovePicker::MovePicker(const Position& p, Move ttm, Value th, Depth d, const CapturePieceToHistory* cph)
|
||||
: pos(p), captureHistory(cph), ttMove(ttm), threshold(th), depth(d)
|
||||
{
|
||||
assert(!pos.checkers());
|
||||
|
||||
stage = PROBCUT_TT + !(ttm && pos.capture(ttm)
|
||||
@@ -100,9 +106,34 @@ void MovePicker::score() {
|
||||
|
||||
static_assert(Type == CAPTURES || Type == QUIETS || Type == EVASIONS, "Wrong type");
|
||||
|
||||
Bitboard threatened, threatenedByPawn, threatenedByMinor, threatenedByRook;
|
||||
if constexpr (Type == QUIETS)
|
||||
{
|
||||
Color us = pos.side_to_move();
|
||||
// squares threatened by pawns
|
||||
threatenedByPawn = pos.attacks_by<PAWN>(~us);
|
||||
// squares threatened by minors or pawns
|
||||
threatenedByMinor = pos.attacks_by<KNIGHT>(~us) | pos.attacks_by<BISHOP>(~us) | threatenedByPawn;
|
||||
// squares threatened by rooks, minors or pawns
|
||||
threatenedByRook = pos.attacks_by<ROOK>(~us) | threatenedByMinor;
|
||||
|
||||
// pieces threatened by pieces of lesser material value
|
||||
threatened = (pos.pieces(us, QUEEN) & threatenedByRook)
|
||||
| (pos.pieces(us, ROOK) & threatenedByMinor)
|
||||
| (pos.pieces(us, KNIGHT, BISHOP) & threatenedByPawn);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Silence unused variable warnings
|
||||
(void) threatened;
|
||||
(void) threatenedByPawn;
|
||||
(void) threatenedByMinor;
|
||||
(void) threatenedByRook;
|
||||
}
|
||||
|
||||
for (auto& m : *this)
|
||||
if constexpr (Type == CAPTURES)
|
||||
m.value = int(PieceValue[MG][pos.piece_on(to_sq(m))]) * 6
|
||||
m.value = 6 * int(PieceValue[MG][pos.piece_on(to_sq(m))])
|
||||
+ (*captureHistory)[pos.moved_piece(m)][to_sq(m)][type_of(pos.piece_on(to_sq(m)))];
|
||||
|
||||
else if constexpr (Type == QUIETS)
|
||||
@@ -111,7 +142,12 @@ void MovePicker::score() {
|
||||
+ (*continuationHistory[1])[pos.moved_piece(m)][to_sq(m)]
|
||||
+ (*continuationHistory[3])[pos.moved_piece(m)][to_sq(m)]
|
||||
+ (*continuationHistory[5])[pos.moved_piece(m)][to_sq(m)]
|
||||
+ (ply < MAX_LPH ? 6 * (*lowPlyHistory)[ply][from_to(m)] : 0);
|
||||
+ (threatened & from_sq(m) ?
|
||||
(type_of(pos.moved_piece(m)) == QUEEN && !(to_sq(m) & threatenedByRook) ? 50000
|
||||
: type_of(pos.moved_piece(m)) == ROOK && !(to_sq(m) & threatenedByMinor) ? 25000
|
||||
: !(to_sq(m) & threatenedByPawn) ? 15000
|
||||
: 0)
|
||||
: 0);
|
||||
|
||||
else // Type == EVASIONS
|
||||
{
|
||||
@@ -165,11 +201,12 @@ top:
|
||||
endMoves = generate<CAPTURES>(pos, cur);
|
||||
|
||||
score<CAPTURES>();
|
||||
partial_insertion_sort(cur, endMoves, -3000 * depth);
|
||||
++stage;
|
||||
goto top;
|
||||
|
||||
case GOOD_CAPTURE:
|
||||
if (select<Best>([&](){
|
||||
if (select<Next>([&](){
|
||||
return pos.see_ge(*cur, Value(-69 * cur->value / 1024)) ?
|
||||
// Move losing capture to endBadCaptures to be tried later
|
||||
true : (*endBadCaptures++ = *cur, false); }))
|
||||
@@ -237,10 +274,10 @@ top:
|
||||
return select<Best>([](){ return true; });
|
||||
|
||||
case PROBCUT:
|
||||
return select<Best>([&](){ return pos.see_ge(*cur, threshold); });
|
||||
return select<Next>([&](){ return pos.see_ge(*cur, threshold); });
|
||||
|
||||
case QCAPTURE:
|
||||
if (select<Best>([&](){ return depth > DEPTH_QS_RECAPTURES
|
||||
if (select<Next>([&](){ return depth > DEPTH_QS_RECAPTURES
|
||||
|| to_sq(*cur) == recaptureSquare; }))
|
||||
return *(cur - 1);
|
||||
|
||||
|
||||
+7
-17
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Stockfish, a UCI chess playing engine derived from Glaurung 2.1
|
||||
Copyright (C) 2004-2021 The Stockfish developers (see AUTHORS file)
|
||||
Copyright (C) 2004-2022 The Stockfish developers (see AUTHORS file)
|
||||
|
||||
Stockfish is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -88,12 +88,6 @@ enum StatsType { NoCaptures, Captures };
|
||||
/// the move's from and to squares, see www.chessprogramming.org/Butterfly_Boards
|
||||
typedef Stats<int16_t, 14365, COLOR_NB, int(SQUARE_NB) * int(SQUARE_NB)> ButterflyHistory;
|
||||
|
||||
/// At higher depths LowPlyHistory records successful quiet moves near the root
|
||||
/// and quiet moves which are/were in the PV (ttPv). LowPlyHistory is populated during
|
||||
/// iterative deepening and at each new search the data is shifted down by 2 plies
|
||||
constexpr int MAX_LPH = 4;
|
||||
typedef Stats<int16_t, 10692, MAX_LPH, int(SQUARE_NB) * int(SQUARE_NB)> LowPlyHistory;
|
||||
|
||||
/// CounterMoveHistory stores counter moves indexed by [piece][to] of the previous
|
||||
/// move, see www.chessprogramming.org/Countermove_Heuristic
|
||||
typedef Stats<Move, NOT_USED, PIECE_NB, SQUARE_NB> CounterMoveHistory;
|
||||
@@ -123,18 +117,16 @@ class MovePicker {
|
||||
public:
|
||||
MovePicker(const MovePicker&) = delete;
|
||||
MovePicker& operator=(const MovePicker&) = delete;
|
||||
MovePicker(const Position&, Move, Value, const CapturePieceToHistory*);
|
||||
MovePicker(const Position&, Move, Depth, const ButterflyHistory*,
|
||||
const CapturePieceToHistory*,
|
||||
const PieceToHistory**,
|
||||
Move,
|
||||
const Move*);
|
||||
MovePicker(const Position&, Move, Depth, const ButterflyHistory*,
|
||||
const CapturePieceToHistory*,
|
||||
const PieceToHistory**,
|
||||
Square);
|
||||
MovePicker(const Position&, Move, Depth, const ButterflyHistory*,
|
||||
const LowPlyHistory*,
|
||||
const CapturePieceToHistory*,
|
||||
const PieceToHistory**,
|
||||
Move,
|
||||
const Move*,
|
||||
int);
|
||||
MovePicker(const Position&, Move, Value, Depth, const CapturePieceToHistory*);
|
||||
Move next_move(bool skipQuiets = false);
|
||||
|
||||
private:
|
||||
@@ -145,7 +137,6 @@ private:
|
||||
|
||||
const Position& pos;
|
||||
const ButterflyHistory* mainHistory;
|
||||
const LowPlyHistory* lowPlyHistory;
|
||||
const CapturePieceToHistory* captureHistory;
|
||||
const PieceToHistory** continuationHistory;
|
||||
Move ttMove;
|
||||
@@ -154,7 +145,6 @@ private:
|
||||
Square recaptureSquare;
|
||||
Value threshold;
|
||||
Depth depth;
|
||||
int ply;
|
||||
ExtMove moves[MAX_MOVES];
|
||||
};
|
||||
|
||||
|
||||
+11
-23
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Stockfish, a UCI chess playing engine derived from Glaurung 2.1
|
||||
Copyright (C) 2004-2021 The Stockfish developers (see AUTHORS file)
|
||||
Copyright (C) 2004-2022 The Stockfish developers (see AUTHORS file)
|
||||
|
||||
Stockfish is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -109,7 +109,7 @@ namespace Stockfish::Eval::NNUE {
|
||||
{
|
||||
write_little_endian<std::uint32_t>(stream, Version);
|
||||
write_little_endian<std::uint32_t>(stream, hashValue);
|
||||
write_little_endian<std::uint32_t>(stream, desc.size());
|
||||
write_little_endian<std::uint32_t>(stream, (std::uint32_t)desc.size());
|
||||
stream.write(&desc[0], desc.size());
|
||||
return !stream.fail();
|
||||
}
|
||||
@@ -143,31 +143,26 @@ namespace Stockfish::Eval::NNUE {
|
||||
// overaligning stack variables with alignas() doesn't work correctly.
|
||||
|
||||
constexpr uint64_t alignment = CacheLineSize;
|
||||
int delta = 7;
|
||||
int delta = 10 - pos.non_pawn_material() / 1515;
|
||||
|
||||
#if defined(ALIGNAS_ON_STACK_VARIABLES_BROKEN)
|
||||
TransformedFeatureType transformedFeaturesUnaligned[
|
||||
FeatureTransformer::BufferSize + alignment / sizeof(TransformedFeatureType)];
|
||||
char bufferUnaligned[Network::BufferSize + alignment];
|
||||
|
||||
auto* transformedFeatures = align_ptr_up<alignment>(&transformedFeaturesUnaligned[0]);
|
||||
auto* buffer = align_ptr_up<alignment>(&bufferUnaligned[0]);
|
||||
#else
|
||||
alignas(alignment)
|
||||
TransformedFeatureType transformedFeatures[FeatureTransformer::BufferSize];
|
||||
alignas(alignment) char buffer[Network::BufferSize];
|
||||
#endif
|
||||
|
||||
ASSERT_ALIGNED(transformedFeatures, alignment);
|
||||
ASSERT_ALIGNED(buffer, alignment);
|
||||
|
||||
const std::size_t bucket = (pos.count<ALL_PIECES>() - 1) / 4;
|
||||
const int bucket = (pos.count<ALL_PIECES>() - 1) / 4;
|
||||
const auto psqt = featureTransformer->transform(pos, transformedFeatures, bucket);
|
||||
const auto positional = network[bucket]->propagate(transformedFeatures, buffer)[0];
|
||||
const auto positional = network[bucket]->propagate(transformedFeatures);
|
||||
|
||||
// Give more value to positional evaluation when material is balanced
|
||||
if ( adjusted
|
||||
&& abs(pos.non_pawn_material(WHITE) - pos.non_pawn_material(BLACK)) <= RookValueMg - BishopValueMg)
|
||||
// Give more value to positional evaluation when adjusted flag is set
|
||||
if (adjusted)
|
||||
return static_cast<Value>(((128 - delta) * psqt + (128 + delta) * positional) / 128 / OutputScale);
|
||||
else
|
||||
return static_cast<Value>((psqt + positional) / OutputScale);
|
||||
@@ -191,27 +186,20 @@ namespace Stockfish::Eval::NNUE {
|
||||
#if defined(ALIGNAS_ON_STACK_VARIABLES_BROKEN)
|
||||
TransformedFeatureType transformedFeaturesUnaligned[
|
||||
FeatureTransformer::BufferSize + alignment / sizeof(TransformedFeatureType)];
|
||||
char bufferUnaligned[Network::BufferSize + alignment];
|
||||
|
||||
auto* transformedFeatures = align_ptr_up<alignment>(&transformedFeaturesUnaligned[0]);
|
||||
auto* buffer = align_ptr_up<alignment>(&bufferUnaligned[0]);
|
||||
#else
|
||||
alignas(alignment)
|
||||
TransformedFeatureType transformedFeatures[FeatureTransformer::BufferSize];
|
||||
alignas(alignment) char buffer[Network::BufferSize];
|
||||
#endif
|
||||
|
||||
ASSERT_ALIGNED(transformedFeatures, alignment);
|
||||
ASSERT_ALIGNED(buffer, alignment);
|
||||
|
||||
NnueEvalTrace t{};
|
||||
t.correctBucket = (pos.count<ALL_PIECES>() - 1) / 4;
|
||||
for (std::size_t bucket = 0; bucket < LayerStacks; ++bucket) {
|
||||
const auto psqt = featureTransformer->transform(pos, transformedFeatures, bucket);
|
||||
const auto output = network[bucket]->propagate(transformedFeatures, buffer);
|
||||
|
||||
int materialist = psqt;
|
||||
int positional = output[0];
|
||||
for (IndexType bucket = 0; bucket < LayerStacks; ++bucket) {
|
||||
const auto materialist = featureTransformer->transform(pos, transformedFeatures, bucket);
|
||||
const auto positional = network[bucket]->propagate(transformedFeatures);
|
||||
|
||||
t.psqt[bucket] = static_cast<Value>( materialist / OutputScale );
|
||||
t.positional[bucket] = static_cast<Value>( positional / OutputScale );
|
||||
@@ -234,7 +222,7 @@ namespace Stockfish::Eval::NNUE {
|
||||
{
|
||||
buffer[1] = '0' + cp / 10000; cp %= 10000;
|
||||
buffer[2] = '0' + cp / 1000; cp %= 1000;
|
||||
buffer[3] = '0' + cp / 100; cp %= 100;
|
||||
buffer[3] = '0' + cp / 100;
|
||||
buffer[4] = ' ';
|
||||
}
|
||||
else if (cp >= 1000)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Stockfish, a UCI chess playing engine derived from Glaurung 2.1
|
||||
Copyright (C) 2004-2021 The Stockfish developers (see AUTHORS file)
|
||||
Copyright (C) 2004-2022 The Stockfish developers (see AUTHORS file)
|
||||
|
||||
Stockfish is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Stockfish, a UCI chess playing engine derived from Glaurung 2.1
|
||||
Copyright (C) 2004-2021 The Stockfish developers (see AUTHORS file)
|
||||
Copyright (C) 2004-2022 The Stockfish developers (see AUTHORS file)
|
||||
|
||||
Stockfish is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Stockfish, a UCI chess playing engine derived from Glaurung 2.1
|
||||
Copyright (C) 2004-2021 The Stockfish developers (see AUTHORS file)
|
||||
Copyright (C) 2004-2022 The Stockfish developers (see AUTHORS file)
|
||||
|
||||
Stockfish is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Stockfish, a UCI chess playing engine derived from Glaurung 2.1
|
||||
Copyright (C) 2004-2021 The Stockfish developers (see AUTHORS file)
|
||||
Copyright (C) 2004-2022 The Stockfish developers (see AUTHORS file)
|
||||
|
||||
Stockfish is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -63,20 +63,17 @@ namespace Stockfish::Eval::NNUE::Layers {
|
||||
{
|
||||
# if defined(USE_SSE2)
|
||||
// At least a multiple of 16, with SSE2.
|
||||
static_assert(PaddedInputDimensions % 16 == 0);
|
||||
constexpr IndexType NumChunks = PaddedInputDimensions / 16;
|
||||
constexpr IndexType NumChunks = ceil_to_multiple<IndexType>(InputDimensions, 16) / 16;
|
||||
const __m128i Zeros = _mm_setzero_si128();
|
||||
const auto inputVector = reinterpret_cast<const __m128i*>(input);
|
||||
|
||||
# elif defined(USE_MMX)
|
||||
static_assert(InputDimensions % 8 == 0);
|
||||
constexpr IndexType NumChunks = InputDimensions / 8;
|
||||
constexpr IndexType NumChunks = ceil_to_multiple<IndexType>(InputDimensions, 8) / 8;
|
||||
const __m64 Zeros = _mm_setzero_si64();
|
||||
const auto inputVector = reinterpret_cast<const __m64*>(input);
|
||||
|
||||
# elif defined(USE_NEON)
|
||||
static_assert(PaddedInputDimensions % 16 == 0);
|
||||
constexpr IndexType NumChunks = PaddedInputDimensions / 16;
|
||||
constexpr IndexType NumChunks = ceil_to_multiple<IndexType>(InputDimensions, 16) / 16;
|
||||
const auto inputVector = reinterpret_cast<const int8x8_t*>(input);
|
||||
# endif
|
||||
|
||||
@@ -151,24 +148,27 @@ namespace Stockfish::Eval::NNUE::Layers {
|
||||
}
|
||||
#endif
|
||||
|
||||
template <typename PreviousLayer, IndexType OutDims, typename Enabled = void>
|
||||
template <IndexType InDims, IndexType OutDims, typename Enabled = void>
|
||||
class AffineTransform;
|
||||
|
||||
// A specialization for large inputs.
|
||||
template <typename PreviousLayer, IndexType OutDims>
|
||||
class AffineTransform<PreviousLayer, OutDims, std::enable_if_t<(PreviousLayer::OutputDimensions >= 2*64-1)>> {
|
||||
template <IndexType InDims, IndexType OutDims>
|
||||
class AffineTransform<InDims, OutDims, std::enable_if_t<(ceil_to_multiple<IndexType>(InDims, MaxSimdWidth) >= 2*64)>> {
|
||||
public:
|
||||
// Input/output type
|
||||
using InputType = typename PreviousLayer::OutputType;
|
||||
using InputType = std::uint8_t;
|
||||
using OutputType = std::int32_t;
|
||||
static_assert(std::is_same<InputType, std::uint8_t>::value, "");
|
||||
|
||||
// Number of input/output dimensions
|
||||
static constexpr IndexType InputDimensions = PreviousLayer::OutputDimensions;
|
||||
static constexpr IndexType InputDimensions = InDims;
|
||||
static constexpr IndexType OutputDimensions = OutDims;
|
||||
|
||||
static constexpr IndexType PaddedInputDimensions =
|
||||
ceil_to_multiple<IndexType>(InputDimensions, MaxSimdWidth);
|
||||
static constexpr IndexType PaddedOutputDimensions =
|
||||
ceil_to_multiple<IndexType>(OutputDimensions, MaxSimdWidth);
|
||||
|
||||
using OutputBuffer = OutputType[PaddedOutputDimensions];
|
||||
|
||||
static_assert(PaddedInputDimensions >= 128, "Something went wrong. This specialization should not have been chosen.");
|
||||
|
||||
@@ -181,6 +181,9 @@ namespace Stockfish::Eval::NNUE::Layers {
|
||||
#elif defined (USE_SSSE3)
|
||||
static constexpr const IndexType InputSimdWidth = 16;
|
||||
static constexpr const IndexType MaxNumOutputRegs = 8;
|
||||
#elif defined (USE_NEON)
|
||||
static constexpr const IndexType InputSimdWidth = 8;
|
||||
static constexpr const IndexType MaxNumOutputRegs = 8;
|
||||
#else
|
||||
// The fallback implementation will not have permuted weights.
|
||||
// We define these to avoid a lot of ifdefs later.
|
||||
@@ -200,20 +203,12 @@ namespace Stockfish::Eval::NNUE::Layers {
|
||||
|
||||
static_assert(OutputDimensions % NumOutputRegs == 0);
|
||||
|
||||
// Size of forward propagation buffer used in this layer
|
||||
static constexpr std::size_t SelfBufferSize =
|
||||
ceil_to_multiple(OutputDimensions * sizeof(OutputType), CacheLineSize);
|
||||
|
||||
// Size of the forward propagation buffer used from the input layer to this layer
|
||||
static constexpr std::size_t BufferSize =
|
||||
PreviousLayer::BufferSize + SelfBufferSize;
|
||||
|
||||
// Hash value embedded in the evaluation file
|
||||
static constexpr std::uint32_t get_hash_value() {
|
||||
static constexpr std::uint32_t get_hash_value(std::uint32_t prevHash) {
|
||||
std::uint32_t hashValue = 0xCC03DAE4u;
|
||||
hashValue += OutputDimensions;
|
||||
hashValue ^= PreviousLayer::get_hash_value() >> 1;
|
||||
hashValue ^= PreviousLayer::get_hash_value() << 31;
|
||||
hashValue ^= prevHash >> 1;
|
||||
hashValue ^= prevHash << 31;
|
||||
return hashValue;
|
||||
}
|
||||
|
||||
@@ -240,11 +235,10 @@ namespace Stockfish::Eval::NNUE::Layers {
|
||||
|
||||
// Read network parameters
|
||||
bool read_parameters(std::istream& stream) {
|
||||
if (!previousLayer.read_parameters(stream)) return false;
|
||||
for (std::size_t i = 0; i < OutputDimensions; ++i)
|
||||
for (IndexType i = 0; i < OutputDimensions; ++i)
|
||||
biases[i] = read_little_endian<BiasType>(stream);
|
||||
|
||||
for (std::size_t i = 0; i < OutputDimensions * PaddedInputDimensions; ++i)
|
||||
for (IndexType i = 0; i < OutputDimensions * PaddedInputDimensions; ++i)
|
||||
weights[get_weight_index(i)] = read_little_endian<WeightType>(stream);
|
||||
|
||||
return !stream.fail();
|
||||
@@ -252,11 +246,10 @@ namespace Stockfish::Eval::NNUE::Layers {
|
||||
|
||||
// Write network parameters
|
||||
bool write_parameters(std::ostream& stream) const {
|
||||
if (!previousLayer.write_parameters(stream)) return false;
|
||||
for (std::size_t i = 0; i < OutputDimensions; ++i)
|
||||
for (IndexType i = 0; i < OutputDimensions; ++i)
|
||||
write_little_endian<BiasType>(stream, biases[i]);
|
||||
|
||||
for (std::size_t i = 0; i < OutputDimensions * PaddedInputDimensions; ++i)
|
||||
for (IndexType i = 0; i < OutputDimensions * PaddedInputDimensions; ++i)
|
||||
write_little_endian<WeightType>(stream, weights[get_weight_index(i)]);
|
||||
|
||||
return !stream.fail();
|
||||
@@ -264,58 +257,66 @@ namespace Stockfish::Eval::NNUE::Layers {
|
||||
|
||||
// Forward propagation
|
||||
const OutputType* propagate(
|
||||
const TransformedFeatureType* transformedFeatures, char* buffer) const {
|
||||
const auto input = previousLayer.propagate(
|
||||
transformedFeatures, buffer + SelfBufferSize);
|
||||
OutputType* output = reinterpret_cast<OutputType*>(buffer);
|
||||
const InputType* input, OutputType* output) const {
|
||||
|
||||
#if defined (USE_AVX512)
|
||||
using vec_t = __m512i;
|
||||
#define vec_setzero _mm512_setzero_si512
|
||||
#define vec_set_32 _mm512_set1_epi32
|
||||
#define vec_add_dpbusd_32 Simd::m512_add_dpbusd_epi32
|
||||
using acc_vec_t = __m512i;
|
||||
using bias_vec_t = __m128i;
|
||||
using weight_vec_t = __m512i;
|
||||
using in_vec_t = __m512i;
|
||||
#define vec_zero _mm512_setzero_si512()
|
||||
#define vec_add_dpbusd_32x2 Simd::m512_add_dpbusd_epi32x2
|
||||
#define vec_hadd Simd::m512_hadd
|
||||
#define vec_haddx4 Simd::m512_haddx4
|
||||
#elif defined (USE_AVX2)
|
||||
using vec_t = __m256i;
|
||||
#define vec_setzero _mm256_setzero_si256
|
||||
#define vec_set_32 _mm256_set1_epi32
|
||||
#define vec_add_dpbusd_32 Simd::m256_add_dpbusd_epi32
|
||||
using acc_vec_t = __m256i;
|
||||
using bias_vec_t = __m128i;
|
||||
using weight_vec_t = __m256i;
|
||||
using in_vec_t = __m256i;
|
||||
#define vec_zero _mm256_setzero_si256()
|
||||
#define vec_add_dpbusd_32x2 Simd::m256_add_dpbusd_epi32x2
|
||||
#define vec_hadd Simd::m256_hadd
|
||||
#define vec_haddx4 Simd::m256_haddx4
|
||||
#elif defined (USE_SSSE3)
|
||||
using vec_t = __m128i;
|
||||
#define vec_setzero _mm_setzero_si128
|
||||
#define vec_set_32 _mm_set1_epi32
|
||||
#define vec_add_dpbusd_32 Simd::m128_add_dpbusd_epi32
|
||||
using acc_vec_t = __m128i;
|
||||
using bias_vec_t = __m128i;
|
||||
using weight_vec_t = __m128i;
|
||||
using in_vec_t = __m128i;
|
||||
#define vec_zero _mm_setzero_si128()
|
||||
#define vec_add_dpbusd_32x2 Simd::m128_add_dpbusd_epi32x2
|
||||
#define vec_hadd Simd::m128_hadd
|
||||
#define vec_haddx4 Simd::m128_haddx4
|
||||
#elif defined (USE_NEON)
|
||||
using acc_vec_t = int32x4_t;
|
||||
using bias_vec_t = int32x4_t;
|
||||
using weight_vec_t = int8x8_t;
|
||||
using in_vec_t = int8x8_t;
|
||||
#define vec_zero {0}
|
||||
#define vec_add_dpbusd_32x2 Simd::neon_m128_add_dpbusd_epi32x2
|
||||
#define vec_hadd Simd::neon_m128_hadd
|
||||
#define vec_haddx4 Simd::neon_m128_haddx4
|
||||
#endif
|
||||
|
||||
#if defined (USE_SSSE3)
|
||||
const vec_t* invec = reinterpret_cast<const vec_t*>(input);
|
||||
|
||||
#if defined (USE_SSSE3) || defined (USE_NEON)
|
||||
const in_vec_t* invec = reinterpret_cast<const in_vec_t*>(input);
|
||||
|
||||
// Perform accumulation to registers for each big block
|
||||
for (IndexType bigBlock = 0; bigBlock < NumBigBlocks; ++bigBlock)
|
||||
{
|
||||
vec_t acc[NumOutputRegs] = { vec_setzero() };
|
||||
acc_vec_t acc[NumOutputRegs] = { vec_zero };
|
||||
|
||||
// Each big block has NumOutputRegs small blocks in each "row", one per register.
|
||||
// We process two small blocks at a time to save on one addition without VNNI.
|
||||
for (IndexType smallBlock = 0; smallBlock < NumSmallBlocksPerOutput; smallBlock += 2)
|
||||
{
|
||||
const vec_t* weightvec =
|
||||
reinterpret_cast<const vec_t*>(
|
||||
const weight_vec_t* weightvec =
|
||||
reinterpret_cast<const weight_vec_t*>(
|
||||
weights
|
||||
+ bigBlock * BigBlockSize
|
||||
+ smallBlock * SmallBlockSize * NumOutputRegs);
|
||||
|
||||
const vec_t in0 = invec[smallBlock + 0];
|
||||
const vec_t in1 = invec[smallBlock + 1];
|
||||
const in_vec_t in0 = invec[smallBlock + 0];
|
||||
const in_vec_t in1 = invec[smallBlock + 1];
|
||||
|
||||
for (IndexType k = 0; k < NumOutputRegs; ++k)
|
||||
vec_add_dpbusd_32x2(acc[k], in0, weightvec[k], in1, weightvec[k + NumOutputRegs]);
|
||||
@@ -324,8 +325,8 @@ namespace Stockfish::Eval::NNUE::Layers {
|
||||
// Horizontally add all accumulators.
|
||||
if constexpr (NumOutputRegs % 4 == 0)
|
||||
{
|
||||
__m128i* outputvec = reinterpret_cast<__m128i*>(output);
|
||||
const __m128i* biasvec = reinterpret_cast<const __m128i*>(biases);
|
||||
bias_vec_t* outputvec = reinterpret_cast<bias_vec_t*>(output);
|
||||
const bias_vec_t* biasvec = reinterpret_cast<const bias_vec_t*>(biases);
|
||||
|
||||
for (IndexType k = 0; k < NumOutputRegs; k += 4)
|
||||
{
|
||||
@@ -343,9 +344,7 @@ namespace Stockfish::Eval::NNUE::Layers {
|
||||
}
|
||||
}
|
||||
|
||||
# undef vec_setzero
|
||||
# undef vec_set_32
|
||||
# undef vec_add_dpbusd_32
|
||||
# undef vec_zero
|
||||
# undef vec_add_dpbusd_32x2
|
||||
# undef vec_hadd
|
||||
# undef vec_haddx4
|
||||
@@ -365,26 +364,28 @@ namespace Stockfish::Eval::NNUE::Layers {
|
||||
using BiasType = OutputType;
|
||||
using WeightType = std::int8_t;
|
||||
|
||||
PreviousLayer previousLayer;
|
||||
|
||||
alignas(CacheLineSize) BiasType biases[OutputDimensions];
|
||||
alignas(CacheLineSize) WeightType weights[OutputDimensions * PaddedInputDimensions];
|
||||
};
|
||||
|
||||
template <typename PreviousLayer, IndexType OutDims>
|
||||
class AffineTransform<PreviousLayer, OutDims, std::enable_if_t<(PreviousLayer::OutputDimensions < 2*64-1)>> {
|
||||
template <IndexType InDims, IndexType OutDims>
|
||||
class AffineTransform<InDims, OutDims, std::enable_if_t<(ceil_to_multiple<IndexType>(InDims, MaxSimdWidth) < 2*64)>> {
|
||||
public:
|
||||
// Input/output type
|
||||
using InputType = typename PreviousLayer::OutputType;
|
||||
// Input/output type
|
||||
using InputType = std::uint8_t;
|
||||
using OutputType = std::int32_t;
|
||||
static_assert(std::is_same<InputType, std::uint8_t>::value, "");
|
||||
|
||||
// Number of input/output dimensions
|
||||
static constexpr IndexType InputDimensions =
|
||||
PreviousLayer::OutputDimensions;
|
||||
static constexpr IndexType InputDimensions = InDims;
|
||||
static constexpr IndexType OutputDimensions = OutDims;
|
||||
|
||||
static constexpr IndexType PaddedInputDimensions =
|
||||
ceil_to_multiple<IndexType>(InputDimensions, MaxSimdWidth);
|
||||
static constexpr IndexType PaddedOutputDimensions =
|
||||
ceil_to_multiple<IndexType>(OutputDimensions, MaxSimdWidth);
|
||||
|
||||
using OutputBuffer = OutputType[PaddedOutputDimensions];
|
||||
|
||||
static_assert(PaddedInputDimensions < 128, "Something went wrong. This specialization should not have been chosen.");
|
||||
|
||||
@@ -393,20 +394,12 @@ namespace Stockfish::Eval::NNUE::Layers {
|
||||
static constexpr const IndexType InputSimdWidth = SimdWidth;
|
||||
#endif
|
||||
|
||||
// Size of forward propagation buffer used in this layer
|
||||
static constexpr std::size_t SelfBufferSize =
|
||||
ceil_to_multiple(OutputDimensions * sizeof(OutputType), CacheLineSize);
|
||||
|
||||
// Size of the forward propagation buffer used from the input layer to this layer
|
||||
static constexpr std::size_t BufferSize =
|
||||
PreviousLayer::BufferSize + SelfBufferSize;
|
||||
|
||||
// Hash value embedded in the evaluation file
|
||||
static constexpr std::uint32_t get_hash_value() {
|
||||
static constexpr std::uint32_t get_hash_value(std::uint32_t prevHash) {
|
||||
std::uint32_t hashValue = 0xCC03DAE4u;
|
||||
hashValue += OutputDimensions;
|
||||
hashValue ^= PreviousLayer::get_hash_value() >> 1;
|
||||
hashValue ^= PreviousLayer::get_hash_value() << 31;
|
||||
hashValue ^= prevHash >> 1;
|
||||
hashValue ^= prevHash << 31;
|
||||
return hashValue;
|
||||
}
|
||||
|
||||
@@ -429,10 +422,9 @@ namespace Stockfish::Eval::NNUE::Layers {
|
||||
|
||||
// Read network parameters
|
||||
bool read_parameters(std::istream& stream) {
|
||||
if (!previousLayer.read_parameters(stream)) return false;
|
||||
for (std::size_t i = 0; i < OutputDimensions; ++i)
|
||||
for (IndexType i = 0; i < OutputDimensions; ++i)
|
||||
biases[i] = read_little_endian<BiasType>(stream);
|
||||
for (std::size_t i = 0; i < OutputDimensions * PaddedInputDimensions; ++i)
|
||||
for (IndexType i = 0; i < OutputDimensions * PaddedInputDimensions; ++i)
|
||||
weights[get_weight_index(i)] = read_little_endian<WeightType>(stream);
|
||||
|
||||
return !stream.fail();
|
||||
@@ -440,21 +432,17 @@ namespace Stockfish::Eval::NNUE::Layers {
|
||||
|
||||
// Write network parameters
|
||||
bool write_parameters(std::ostream& stream) const {
|
||||
if (!previousLayer.write_parameters(stream)) return false;
|
||||
for (std::size_t i = 0; i < OutputDimensions; ++i)
|
||||
for (IndexType i = 0; i < OutputDimensions; ++i)
|
||||
write_little_endian<BiasType>(stream, biases[i]);
|
||||
|
||||
for (std::size_t i = 0; i < OutputDimensions * PaddedInputDimensions; ++i)
|
||||
for (IndexType i = 0; i < OutputDimensions * PaddedInputDimensions; ++i)
|
||||
write_little_endian<WeightType>(stream, weights[get_weight_index(i)]);
|
||||
|
||||
return !stream.fail();
|
||||
}
|
||||
// Forward propagation
|
||||
const OutputType* propagate(
|
||||
const TransformedFeatureType* transformedFeatures, char* buffer) const {
|
||||
const auto input = previousLayer.propagate(
|
||||
transformedFeatures, buffer + SelfBufferSize);
|
||||
const auto output = reinterpret_cast<OutputType*>(buffer);
|
||||
const InputType* input, OutputType* output) const {
|
||||
|
||||
#if defined (USE_AVX2)
|
||||
using vec_t = __m256i;
|
||||
@@ -479,12 +467,11 @@ namespace Stockfish::Eval::NNUE::Layers {
|
||||
#if defined (USE_SSSE3)
|
||||
const auto inputVector = reinterpret_cast<const vec_t*>(input);
|
||||
|
||||
static_assert(InputDimensions % 8 == 0);
|
||||
static_assert(OutputDimensions % OutputSimdWidth == 0 || OutputDimensions == 1);
|
||||
|
||||
if constexpr (OutputDimensions % OutputSimdWidth == 0)
|
||||
{
|
||||
constexpr IndexType NumChunks = InputDimensions / 4;
|
||||
constexpr IndexType NumChunks = ceil_to_multiple<IndexType>(InputDimensions, 8) / 4;
|
||||
constexpr IndexType NumRegs = OutputDimensions / OutputSimdWidth;
|
||||
|
||||
const auto input32 = reinterpret_cast<const std::int32_t*>(input);
|
||||
@@ -543,8 +530,6 @@ namespace Stockfish::Eval::NNUE::Layers {
|
||||
using BiasType = OutputType;
|
||||
using WeightType = std::int8_t;
|
||||
|
||||
PreviousLayer previousLayer;
|
||||
|
||||
alignas(CacheLineSize) BiasType biases[OutputDimensions];
|
||||
alignas(CacheLineSize) WeightType weights[OutputDimensions * PaddedInputDimensions];
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Stockfish, a UCI chess playing engine derived from Glaurung 2.1
|
||||
Copyright (C) 2004-2021 The Stockfish developers (see AUTHORS file)
|
||||
Copyright (C) 2004-2022 The Stockfish developers (see AUTHORS file)
|
||||
|
||||
Stockfish is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -26,51 +26,41 @@
|
||||
namespace Stockfish::Eval::NNUE::Layers {
|
||||
|
||||
// Clipped ReLU
|
||||
template <typename PreviousLayer>
|
||||
template <IndexType InDims>
|
||||
class ClippedReLU {
|
||||
public:
|
||||
// Input/output type
|
||||
using InputType = typename PreviousLayer::OutputType;
|
||||
using InputType = std::int32_t;
|
||||
using OutputType = std::uint8_t;
|
||||
static_assert(std::is_same<InputType, std::int32_t>::value, "");
|
||||
|
||||
// Number of input/output dimensions
|
||||
static constexpr IndexType InputDimensions = PreviousLayer::OutputDimensions;
|
||||
static constexpr IndexType InputDimensions = InDims;
|
||||
static constexpr IndexType OutputDimensions = InputDimensions;
|
||||
static constexpr IndexType PaddedOutputDimensions =
|
||||
ceil_to_multiple<IndexType>(OutputDimensions, 32);
|
||||
|
||||
// Size of forward propagation buffer used in this layer
|
||||
static constexpr std::size_t SelfBufferSize =
|
||||
ceil_to_multiple(OutputDimensions * sizeof(OutputType), CacheLineSize);
|
||||
|
||||
// Size of the forward propagation buffer used from the input layer to this layer
|
||||
static constexpr std::size_t BufferSize =
|
||||
PreviousLayer::BufferSize + SelfBufferSize;
|
||||
using OutputBuffer = OutputType[PaddedOutputDimensions];
|
||||
|
||||
// Hash value embedded in the evaluation file
|
||||
static constexpr std::uint32_t get_hash_value() {
|
||||
static constexpr std::uint32_t get_hash_value(std::uint32_t prevHash) {
|
||||
std::uint32_t hashValue = 0x538D24C7u;
|
||||
hashValue += PreviousLayer::get_hash_value();
|
||||
hashValue += prevHash;
|
||||
return hashValue;
|
||||
}
|
||||
|
||||
// Read network parameters
|
||||
bool read_parameters(std::istream& stream) {
|
||||
return previousLayer.read_parameters(stream);
|
||||
bool read_parameters(std::istream&) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Write network parameters
|
||||
bool write_parameters(std::ostream& stream) const {
|
||||
return previousLayer.write_parameters(stream);
|
||||
bool write_parameters(std::ostream&) const {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Forward propagation
|
||||
const OutputType* propagate(
|
||||
const TransformedFeatureType* transformedFeatures, char* buffer) const {
|
||||
const auto input = previousLayer.propagate(
|
||||
transformedFeatures, buffer + SelfBufferSize);
|
||||
const auto output = reinterpret_cast<OutputType*>(buffer);
|
||||
const InputType* input, OutputType* output) const {
|
||||
|
||||
#if defined(USE_AVX2)
|
||||
if constexpr (InputDimensions % SimdWidth == 0) {
|
||||
@@ -181,19 +171,8 @@ namespace Stockfish::Eval::NNUE::Layers {
|
||||
std::max(0, std::min(127, input[i] >> WeightScaleBits)));
|
||||
}
|
||||
|
||||
// Affine transform layers expect that there is at least
|
||||
// ceil_to_multiple(OutputDimensions, 32) initialized values.
|
||||
// We cannot do this in the affine transform because it requires
|
||||
// preallocating space here.
|
||||
for (IndexType i = OutputDimensions; i < PaddedOutputDimensions; ++i) {
|
||||
output[i] = 0;
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
private:
|
||||
PreviousLayer previousLayer;
|
||||
};
|
||||
|
||||
} // namespace Stockfish::Eval::NNUE::Layers
|
||||
|
||||
@@ -1,73 +0,0 @@
|
||||
/*
|
||||
Stockfish, a UCI chess playing engine derived from Glaurung 2.1
|
||||
Copyright (C) 2004-2021 The Stockfish developers (see AUTHORS file)
|
||||
|
||||
Stockfish is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Stockfish is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// NNUE evaluation function layer InputSlice definition
|
||||
|
||||
#ifndef NNUE_LAYERS_INPUT_SLICE_H_INCLUDED
|
||||
#define NNUE_LAYERS_INPUT_SLICE_H_INCLUDED
|
||||
|
||||
#include "../nnue_common.h"
|
||||
|
||||
namespace Stockfish::Eval::NNUE::Layers {
|
||||
|
||||
// Input layer
|
||||
template <IndexType OutDims, IndexType Offset = 0>
|
||||
class InputSlice {
|
||||
public:
|
||||
// Need to maintain alignment
|
||||
static_assert(Offset % MaxSimdWidth == 0, "");
|
||||
|
||||
// Output type
|
||||
using OutputType = TransformedFeatureType;
|
||||
|
||||
// Output dimensionality
|
||||
static constexpr IndexType OutputDimensions = OutDims;
|
||||
|
||||
// Size of forward propagation buffer used from the input layer to this layer
|
||||
static constexpr std::size_t BufferSize = 0;
|
||||
|
||||
// Hash value embedded in the evaluation file
|
||||
static constexpr std::uint32_t get_hash_value() {
|
||||
std::uint32_t hashValue = 0xEC42E90Du;
|
||||
hashValue ^= OutputDimensions ^ (Offset << 10);
|
||||
return hashValue;
|
||||
}
|
||||
|
||||
// Read network parameters
|
||||
bool read_parameters(std::istream& /*stream*/) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Write network parameters
|
||||
bool write_parameters(std::ostream& /*stream*/) const {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Forward propagation
|
||||
const OutputType* propagate(
|
||||
const TransformedFeatureType* transformedFeatures,
|
||||
char* /*buffer*/) const {
|
||||
return transformedFeatures + Offset;
|
||||
}
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
} // namespace Stockfish::Eval::NNUE::Layers
|
||||
|
||||
#endif // #ifndef NNUE_LAYERS_INPUT_SLICE_H_INCLUDED
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Stockfish, a UCI chess playing engine derived from Glaurung 2.1
|
||||
Copyright (C) 2004-2021 The Stockfish developers (see AUTHORS file)
|
||||
Copyright (C) 2004-2022 The Stockfish developers (see AUTHORS file)
|
||||
|
||||
Stockfish is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Stockfish, a UCI chess playing engine derived from Glaurung 2.1
|
||||
Copyright (C) 2004-2021 The Stockfish developers (see AUTHORS file)
|
||||
Copyright (C) 2004-2022 The Stockfish developers (see AUTHORS file)
|
||||
|
||||
Stockfish is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -21,39 +21,112 @@
|
||||
#ifndef NNUE_ARCHITECTURE_H_INCLUDED
|
||||
#define NNUE_ARCHITECTURE_H_INCLUDED
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "nnue_common.h"
|
||||
|
||||
#include "features/half_ka_v2_hm.h"
|
||||
|
||||
#include "layers/input_slice.h"
|
||||
#include "layers/affine_transform.h"
|
||||
#include "layers/clipped_relu.h"
|
||||
|
||||
#include "../misc.h"
|
||||
|
||||
namespace Stockfish::Eval::NNUE {
|
||||
|
||||
// Input features used in evaluation function
|
||||
using FeatureSet = Features::HalfKAv2_hm;
|
||||
// Input features used in evaluation function
|
||||
using FeatureSet = Features::HalfKAv2_hm;
|
||||
|
||||
// Number of input feature dimensions after conversion
|
||||
constexpr IndexType TransformedFeatureDimensions = 1024;
|
||||
constexpr IndexType PSQTBuckets = 8;
|
||||
constexpr IndexType LayerStacks = 8;
|
||||
// Number of input feature dimensions after conversion
|
||||
constexpr IndexType TransformedFeatureDimensions = 1024;
|
||||
constexpr IndexType PSQTBuckets = 8;
|
||||
constexpr IndexType LayerStacks = 8;
|
||||
|
||||
namespace Layers {
|
||||
struct Network
|
||||
{
|
||||
static constexpr int FC_0_OUTPUTS = 15;
|
||||
static constexpr int FC_1_OUTPUTS = 32;
|
||||
|
||||
// Define network structure
|
||||
using InputLayer = InputSlice<TransformedFeatureDimensions * 2>;
|
||||
using HiddenLayer1 = ClippedReLU<AffineTransform<InputLayer, 8>>;
|
||||
using HiddenLayer2 = ClippedReLU<AffineTransform<HiddenLayer1, 32>>;
|
||||
using OutputLayer = AffineTransform<HiddenLayer2, 1>;
|
||||
Layers::AffineTransform<TransformedFeatureDimensions, FC_0_OUTPUTS + 1> fc_0;
|
||||
Layers::ClippedReLU<FC_0_OUTPUTS + 1> ac_0;
|
||||
Layers::AffineTransform<FC_0_OUTPUTS, FC_1_OUTPUTS> fc_1;
|
||||
Layers::ClippedReLU<FC_1_OUTPUTS> ac_1;
|
||||
Layers::AffineTransform<FC_1_OUTPUTS, 1> fc_2;
|
||||
|
||||
} // namespace Layers
|
||||
// Hash value embedded in the evaluation file
|
||||
static constexpr std::uint32_t get_hash_value() {
|
||||
// input slice hash
|
||||
std::uint32_t hashValue = 0xEC42E90Du;
|
||||
hashValue ^= TransformedFeatureDimensions * 2;
|
||||
|
||||
using Network = Layers::OutputLayer;
|
||||
hashValue = decltype(fc_0)::get_hash_value(hashValue);
|
||||
hashValue = decltype(ac_0)::get_hash_value(hashValue);
|
||||
hashValue = decltype(fc_1)::get_hash_value(hashValue);
|
||||
hashValue = decltype(ac_1)::get_hash_value(hashValue);
|
||||
hashValue = decltype(fc_2)::get_hash_value(hashValue);
|
||||
|
||||
static_assert(TransformedFeatureDimensions % MaxSimdWidth == 0, "");
|
||||
static_assert(Network::OutputDimensions == 1, "");
|
||||
static_assert(std::is_same<Network::OutputType, std::int32_t>::value, "");
|
||||
return hashValue;
|
||||
}
|
||||
|
||||
// Read network parameters
|
||||
bool read_parameters(std::istream& stream) {
|
||||
if (!fc_0.read_parameters(stream)) return false;
|
||||
if (!ac_0.read_parameters(stream)) return false;
|
||||
if (!fc_1.read_parameters(stream)) return false;
|
||||
if (!ac_1.read_parameters(stream)) return false;
|
||||
if (!fc_2.read_parameters(stream)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Read network parameters
|
||||
bool write_parameters(std::ostream& stream) const {
|
||||
if (!fc_0.write_parameters(stream)) return false;
|
||||
if (!ac_0.write_parameters(stream)) return false;
|
||||
if (!fc_1.write_parameters(stream)) return false;
|
||||
if (!ac_1.write_parameters(stream)) return false;
|
||||
if (!fc_2.write_parameters(stream)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
std::int32_t propagate(const TransformedFeatureType* transformedFeatures)
|
||||
{
|
||||
struct alignas(CacheLineSize) Buffer
|
||||
{
|
||||
alignas(CacheLineSize) decltype(fc_0)::OutputBuffer fc_0_out;
|
||||
alignas(CacheLineSize) decltype(ac_0)::OutputBuffer ac_0_out;
|
||||
alignas(CacheLineSize) decltype(fc_1)::OutputBuffer fc_1_out;
|
||||
alignas(CacheLineSize) decltype(ac_1)::OutputBuffer ac_1_out;
|
||||
alignas(CacheLineSize) decltype(fc_2)::OutputBuffer fc_2_out;
|
||||
|
||||
Buffer()
|
||||
{
|
||||
std::memset(this, 0, sizeof(*this));
|
||||
}
|
||||
};
|
||||
|
||||
#if defined(__clang__) && (__APPLE__)
|
||||
// workaround for a bug reported with xcode 12
|
||||
static thread_local auto tlsBuffer = std::make_unique<Buffer>();
|
||||
// Access TLS only once, cache result.
|
||||
Buffer& buffer = *tlsBuffer;
|
||||
#else
|
||||
alignas(CacheLineSize) static thread_local Buffer buffer;
|
||||
#endif
|
||||
|
||||
fc_0.propagate(transformedFeatures, buffer.fc_0_out);
|
||||
ac_0.propagate(buffer.fc_0_out, buffer.ac_0_out);
|
||||
fc_1.propagate(buffer.ac_0_out, buffer.fc_1_out);
|
||||
ac_1.propagate(buffer.fc_1_out, buffer.ac_1_out);
|
||||
fc_2.propagate(buffer.ac_1_out, buffer.fc_2_out);
|
||||
|
||||
// buffer.fc_0_out[FC_0_OUTPUTS] is such that 1.0 is equal to 127*(1<<WeightScaleBits) in quantized form
|
||||
// but we want 1.0 to be equal to 600*OutputScale
|
||||
std::int32_t fwdOut = int(buffer.fc_0_out[FC_0_OUTPUTS]) * (600*OutputScale) / (127*(1<<WeightScaleBits));
|
||||
std::int32_t outputValue = buffer.fc_2_out[0] + fwdOut;
|
||||
|
||||
return outputValue;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace Stockfish::Eval::NNUE
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Stockfish, a UCI chess playing engine derived from Glaurung 2.1
|
||||
Copyright (C) 2004-2021 The Stockfish developers (see AUTHORS file)
|
||||
Copyright (C) 2004-2022 The Stockfish developers (see AUTHORS file)
|
||||
|
||||
Stockfish is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -109,7 +109,7 @@ namespace Stockfish::Eval::NNUE {
|
||||
|
||||
// write_little_endian() is our utility to write an integer (signed or unsigned, any size)
|
||||
// to a stream in little-endian order. We swap the byte order before the write if
|
||||
// necessary to always write in little endian order, independantly of the byte
|
||||
// necessary to always write in little endian order, independently of the byte
|
||||
// ordering of the compiling machine.
|
||||
template <typename IntType>
|
||||
inline void write_little_endian(std::ostream& stream, IntType value) {
|
||||
@@ -127,11 +127,11 @@ namespace Stockfish::Eval::NNUE {
|
||||
{
|
||||
for (; i + 1 < sizeof(IntType); ++i)
|
||||
{
|
||||
u[i] = v;
|
||||
u[i] = (std::uint8_t)v;
|
||||
v >>= 8;
|
||||
}
|
||||
}
|
||||
u[i] = v;
|
||||
u[i] = (std::uint8_t)v;
|
||||
|
||||
stream.write(reinterpret_cast<char*>(u), sizeof(IntType));
|
||||
}
|
||||
|
||||
+102
-128
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Stockfish, a UCI chess playing engine derived from Glaurung 2.1
|
||||
Copyright (C) 2004-2021 The Stockfish developers (see AUTHORS file)
|
||||
Copyright (C) 2004-2022 The Stockfish developers (see AUTHORS file)
|
||||
|
||||
Stockfish is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -47,12 +47,22 @@ namespace Stockfish::Eval::NNUE {
|
||||
#define vec_store(a,b) _mm512_store_si512(a,b)
|
||||
#define vec_add_16(a,b) _mm512_add_epi16(a,b)
|
||||
#define vec_sub_16(a,b) _mm512_sub_epi16(a,b)
|
||||
#define vec_mul_16(a,b) _mm512_mullo_epi16(a,b)
|
||||
#define vec_zero() _mm512_setzero_epi32()
|
||||
#define vec_set_16(a) _mm512_set1_epi16(a)
|
||||
#define vec_max_16(a,b) _mm512_max_epi16(a,b)
|
||||
#define vec_min_16(a,b) _mm512_min_epi16(a,b)
|
||||
inline vec_t vec_msb_pack_16(vec_t a, vec_t b){
|
||||
vec_t compacted = _mm512_packs_epi16(_mm512_srli_epi16(a,7),_mm512_srli_epi16(b,7));
|
||||
return _mm512_permutexvar_epi64(_mm512_setr_epi64(0, 2, 4, 6, 1, 3, 5, 7), compacted);
|
||||
}
|
||||
#define vec_load_psqt(a) _mm256_load_si256(a)
|
||||
#define vec_store_psqt(a,b) _mm256_store_si256(a,b)
|
||||
#define vec_add_psqt_32(a,b) _mm256_add_epi32(a,b)
|
||||
#define vec_sub_psqt_32(a,b) _mm256_sub_epi32(a,b)
|
||||
#define vec_zero_psqt() _mm256_setzero_si256()
|
||||
#define NumRegistersSIMD 32
|
||||
#define MaxChunkSize 64
|
||||
|
||||
#elif USE_AVX2
|
||||
typedef __m256i vec_t;
|
||||
@@ -61,12 +71,22 @@ namespace Stockfish::Eval::NNUE {
|
||||
#define vec_store(a,b) _mm256_store_si256(a,b)
|
||||
#define vec_add_16(a,b) _mm256_add_epi16(a,b)
|
||||
#define vec_sub_16(a,b) _mm256_sub_epi16(a,b)
|
||||
#define vec_mul_16(a,b) _mm256_mullo_epi16(a,b)
|
||||
#define vec_zero() _mm256_setzero_si256()
|
||||
#define vec_set_16(a) _mm256_set1_epi16(a)
|
||||
#define vec_max_16(a,b) _mm256_max_epi16(a,b)
|
||||
#define vec_min_16(a,b) _mm256_min_epi16(a,b)
|
||||
inline vec_t vec_msb_pack_16(vec_t a, vec_t b){
|
||||
vec_t compacted = _mm256_packs_epi16(_mm256_srli_epi16(a,7), _mm256_srli_epi16(b,7));
|
||||
return _mm256_permute4x64_epi64(compacted, 0b11011000);
|
||||
}
|
||||
#define vec_load_psqt(a) _mm256_load_si256(a)
|
||||
#define vec_store_psqt(a,b) _mm256_store_si256(a,b)
|
||||
#define vec_add_psqt_32(a,b) _mm256_add_epi32(a,b)
|
||||
#define vec_sub_psqt_32(a,b) _mm256_sub_epi32(a,b)
|
||||
#define vec_zero_psqt() _mm256_setzero_si256()
|
||||
#define NumRegistersSIMD 16
|
||||
#define MaxChunkSize 32
|
||||
|
||||
#elif USE_SSE2
|
||||
typedef __m128i vec_t;
|
||||
@@ -75,12 +95,19 @@ namespace Stockfish::Eval::NNUE {
|
||||
#define vec_store(a,b) *(a)=(b)
|
||||
#define vec_add_16(a,b) _mm_add_epi16(a,b)
|
||||
#define vec_sub_16(a,b) _mm_sub_epi16(a,b)
|
||||
#define vec_mul_16(a,b) _mm_mullo_epi16(a,b)
|
||||
#define vec_zero() _mm_setzero_si128()
|
||||
#define vec_set_16(a) _mm_set1_epi16(a)
|
||||
#define vec_max_16(a,b) _mm_max_epi16(a,b)
|
||||
#define vec_min_16(a,b) _mm_min_epi16(a,b)
|
||||
#define vec_msb_pack_16(a,b) _mm_packs_epi16(_mm_srli_epi16(a,7),_mm_srli_epi16(b,7))
|
||||
#define vec_load_psqt(a) (*(a))
|
||||
#define vec_store_psqt(a,b) *(a)=(b)
|
||||
#define vec_add_psqt_32(a,b) _mm_add_epi32(a,b)
|
||||
#define vec_sub_psqt_32(a,b) _mm_sub_epi32(a,b)
|
||||
#define vec_zero_psqt() _mm_setzero_si128()
|
||||
#define NumRegistersSIMD (Is64Bit ? 16 : 8)
|
||||
#define MaxChunkSize 16
|
||||
|
||||
#elif USE_MMX
|
||||
typedef __m64 vec_t;
|
||||
@@ -89,12 +116,26 @@ namespace Stockfish::Eval::NNUE {
|
||||
#define vec_store(a,b) *(a)=(b)
|
||||
#define vec_add_16(a,b) _mm_add_pi16(a,b)
|
||||
#define vec_sub_16(a,b) _mm_sub_pi16(a,b)
|
||||
#define vec_mul_16(a,b) _mm_mullo_pi16(a,b)
|
||||
#define vec_zero() _mm_setzero_si64()
|
||||
#define vec_set_16(a) _mm_set1_pi16(a)
|
||||
inline vec_t vec_max_16(vec_t a,vec_t b){
|
||||
vec_t comparison = _mm_cmpgt_pi16(a,b);
|
||||
return _mm_or_si64(_mm_and_si64(comparison, a), _mm_andnot_si64(comparison, b));
|
||||
}
|
||||
inline vec_t vec_min_16(vec_t a,vec_t b){
|
||||
vec_t comparison = _mm_cmpgt_pi16(a,b);
|
||||
return _mm_or_si64(_mm_and_si64(comparison, b), _mm_andnot_si64(comparison, a));
|
||||
}
|
||||
#define vec_msb_pack_16(a,b) _mm_packs_pi16(_mm_srli_pi16(a,7),_mm_srli_pi16(b,7))
|
||||
#define vec_load_psqt(a) (*(a))
|
||||
#define vec_store_psqt(a,b) *(a)=(b)
|
||||
#define vec_add_psqt_32(a,b) _mm_add_pi32(a,b)
|
||||
#define vec_sub_psqt_32(a,b) _mm_sub_pi32(a,b)
|
||||
#define vec_zero_psqt() _mm_setzero_si64()
|
||||
#define vec_cleanup() _mm_empty()
|
||||
#define NumRegistersSIMD 8
|
||||
#define MaxChunkSize 8
|
||||
|
||||
#elif USE_NEON
|
||||
typedef int16x8_t vec_t;
|
||||
@@ -103,12 +144,24 @@ namespace Stockfish::Eval::NNUE {
|
||||
#define vec_store(a,b) *(a)=(b)
|
||||
#define vec_add_16(a,b) vaddq_s16(a,b)
|
||||
#define vec_sub_16(a,b) vsubq_s16(a,b)
|
||||
#define vec_mul_16(a,b) vmulq_s16(a,b)
|
||||
#define vec_zero() vec_t{0}
|
||||
#define vec_set_16(a) vdupq_n_s16(a)
|
||||
#define vec_max_16(a,b) vmaxq_s16(a,b)
|
||||
#define vec_min_16(a,b) vminq_s16(a,b)
|
||||
inline vec_t vec_msb_pack_16(vec_t a, vec_t b){
|
||||
const int8x8_t shifta = vshrn_n_s16(a, 7);
|
||||
const int8x8_t shiftb = vshrn_n_s16(b, 7);
|
||||
const int8x16_t compacted = vcombine_s8(shifta,shiftb);
|
||||
return *reinterpret_cast<const vec_t*> (&compacted);
|
||||
}
|
||||
#define vec_load_psqt(a) (*(a))
|
||||
#define vec_store_psqt(a,b) *(a)=(b)
|
||||
#define vec_add_psqt_32(a,b) vaddq_s32(a,b)
|
||||
#define vec_sub_psqt_32(a,b) vsubq_s32(a,b)
|
||||
#define vec_zero_psqt() psqt_vec_t{0}
|
||||
#define NumRegistersSIMD 16
|
||||
#define MaxChunkSize 16
|
||||
|
||||
#else
|
||||
#undef VECTOR
|
||||
@@ -123,8 +176,10 @@ namespace Stockfish::Eval::NNUE {
|
||||
// We use __m* types as template arguments, which causes GCC to emit warnings
|
||||
// about losing some attribute information. This is irrelevant to us as we
|
||||
// only take their size, so the following pragma are harmless.
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wignored-attributes"
|
||||
#endif
|
||||
|
||||
template <typename SIMDRegisterType,
|
||||
typename LaneType,
|
||||
@@ -156,9 +211,9 @@ namespace Stockfish::Eval::NNUE {
|
||||
|
||||
static constexpr int NumRegs = BestRegisterCount<vec_t, WeightType, TransformedFeatureDimensions, NumRegistersSIMD>();
|
||||
static constexpr int NumPsqtRegs = BestRegisterCount<psqt_vec_t, PSQTWeightType, PSQTBuckets, NumRegistersSIMD>();
|
||||
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
@@ -183,7 +238,7 @@ namespace Stockfish::Eval::NNUE {
|
||||
|
||||
// Number of input/output dimensions
|
||||
static constexpr IndexType InputDimensions = FeatureSet::Dimensions;
|
||||
static constexpr IndexType OutputDimensions = HalfDimensions * 2;
|
||||
static constexpr IndexType OutputDimensions = HalfDimensions;
|
||||
|
||||
// Size of forward propagation buffer
|
||||
static constexpr std::size_t BufferSize =
|
||||
@@ -191,7 +246,7 @@ namespace Stockfish::Eval::NNUE {
|
||||
|
||||
// Hash value embedded in the evaluation file
|
||||
static constexpr std::uint32_t get_hash_value() {
|
||||
return FeatureSet::HashValue ^ OutputDimensions;
|
||||
return FeatureSet::HashValue ^ (OutputDimensions * 2);
|
||||
}
|
||||
|
||||
// Read network parameters
|
||||
@@ -229,136 +284,55 @@ namespace Stockfish::Eval::NNUE {
|
||||
) / 2;
|
||||
|
||||
|
||||
#if defined(USE_AVX512)
|
||||
|
||||
constexpr IndexType NumChunks = HalfDimensions / (SimdWidth * 2);
|
||||
static_assert(HalfDimensions % (SimdWidth * 2) == 0);
|
||||
const __m512i Control = _mm512_setr_epi64(0, 2, 4, 6, 1, 3, 5, 7);
|
||||
const __m512i Zero = _mm512_setzero_si512();
|
||||
|
||||
for (IndexType p = 0; p < 2; ++p)
|
||||
{
|
||||
const IndexType offset = HalfDimensions * p;
|
||||
auto out = reinterpret_cast<__m512i*>(&output[offset]);
|
||||
for (IndexType j = 0; j < NumChunks; ++j)
|
||||
{
|
||||
__m512i sum0 = _mm512_load_si512(&reinterpret_cast<const __m512i*>
|
||||
(accumulation[perspectives[p]])[j * 2 + 0]);
|
||||
__m512i sum1 = _mm512_load_si512(&reinterpret_cast<const __m512i*>
|
||||
(accumulation[perspectives[p]])[j * 2 + 1]);
|
||||
const IndexType offset = (HalfDimensions / 2) * p;
|
||||
|
||||
_mm512_store_si512(&out[j], _mm512_permutexvar_epi64(Control,
|
||||
_mm512_max_epi8(_mm512_packs_epi16(sum0, sum1), Zero)));
|
||||
#if defined(VECTOR)
|
||||
|
||||
constexpr IndexType OutputChunkSize = MaxChunkSize;
|
||||
static_assert((HalfDimensions / 2) % OutputChunkSize == 0);
|
||||
constexpr IndexType NumOutputChunks = HalfDimensions / 2 / OutputChunkSize;
|
||||
|
||||
vec_t Zero = vec_zero();
|
||||
vec_t One = vec_set_16(127);
|
||||
|
||||
const vec_t* in0 = reinterpret_cast<const vec_t*>(&(accumulation[perspectives[p]][0]));
|
||||
const vec_t* in1 = reinterpret_cast<const vec_t*>(&(accumulation[perspectives[p]][HalfDimensions / 2]));
|
||||
vec_t* out = reinterpret_cast< vec_t*>(output + offset);
|
||||
|
||||
for (IndexType j = 0; j < NumOutputChunks; j += 1)
|
||||
{
|
||||
const vec_t sum0a = vec_max_16(vec_min_16(in0[j * 2 + 0], One), Zero);
|
||||
const vec_t sum0b = vec_max_16(vec_min_16(in0[j * 2 + 1], One), Zero);
|
||||
const vec_t sum1a = vec_max_16(vec_min_16(in1[j * 2 + 0], One), Zero);
|
||||
const vec_t sum1b = vec_max_16(vec_min_16(in1[j * 2 + 1], One), Zero);
|
||||
|
||||
const vec_t pa = vec_mul_16(sum0a, sum1a);
|
||||
const vec_t pb = vec_mul_16(sum0b, sum1b);
|
||||
|
||||
out[j] = vec_msb_pack_16(pa, pb);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
for (IndexType j = 0; j < HalfDimensions / 2; ++j) {
|
||||
BiasType sum0 = accumulation[static_cast<int>(perspectives[p])][j + 0];
|
||||
BiasType sum1 = accumulation[static_cast<int>(perspectives[p])][j + HalfDimensions / 2];
|
||||
sum0 = std::max<int>(0, std::min<int>(127, sum0));
|
||||
sum1 = std::max<int>(0, std::min<int>(127, sum1));
|
||||
output[offset + j] = static_cast<OutputType>(sum0 * sum1 / 128);
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(vec_cleanup)
|
||||
vec_cleanup();
|
||||
#endif
|
||||
|
||||
return psqt;
|
||||
|
||||
#elif defined(USE_AVX2)
|
||||
|
||||
constexpr IndexType NumChunks = HalfDimensions / SimdWidth;
|
||||
constexpr int Control = 0b11011000;
|
||||
const __m256i Zero = _mm256_setzero_si256();
|
||||
|
||||
for (IndexType p = 0; p < 2; ++p)
|
||||
{
|
||||
const IndexType offset = HalfDimensions * p;
|
||||
auto out = reinterpret_cast<__m256i*>(&output[offset]);
|
||||
for (IndexType j = 0; j < NumChunks; ++j)
|
||||
{
|
||||
__m256i sum0 = _mm256_load_si256(&reinterpret_cast<const __m256i*>
|
||||
(accumulation[perspectives[p]])[j * 2 + 0]);
|
||||
__m256i sum1 = _mm256_load_si256(&reinterpret_cast<const __m256i*>
|
||||
(accumulation[perspectives[p]])[j * 2 + 1]);
|
||||
|
||||
_mm256_store_si256(&out[j], _mm256_permute4x64_epi64(
|
||||
_mm256_max_epi8(_mm256_packs_epi16(sum0, sum1), Zero), Control));
|
||||
}
|
||||
}
|
||||
return psqt;
|
||||
|
||||
#elif defined(USE_SSE2)
|
||||
|
||||
#ifdef USE_SSE41
|
||||
constexpr IndexType NumChunks = HalfDimensions / SimdWidth;
|
||||
const __m128i Zero = _mm_setzero_si128();
|
||||
#else
|
||||
constexpr IndexType NumChunks = HalfDimensions / SimdWidth;
|
||||
const __m128i k0x80s = _mm_set1_epi8(-128);
|
||||
#endif
|
||||
|
||||
for (IndexType p = 0; p < 2; ++p)
|
||||
{
|
||||
const IndexType offset = HalfDimensions * p;
|
||||
auto out = reinterpret_cast<__m128i*>(&output[offset]);
|
||||
for (IndexType j = 0; j < NumChunks; ++j)
|
||||
{
|
||||
__m128i sum0 = _mm_load_si128(&reinterpret_cast<const __m128i*>
|
||||
(accumulation[perspectives[p]])[j * 2 + 0]);
|
||||
__m128i sum1 = _mm_load_si128(&reinterpret_cast<const __m128i*>
|
||||
(accumulation[perspectives[p]])[j * 2 + 1]);
|
||||
const __m128i packedbytes = _mm_packs_epi16(sum0, sum1);
|
||||
|
||||
#ifdef USE_SSE41
|
||||
_mm_store_si128(&out[j], _mm_max_epi8(packedbytes, Zero));
|
||||
#else
|
||||
_mm_store_si128(&out[j], _mm_subs_epi8(_mm_adds_epi8(packedbytes, k0x80s), k0x80s));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
return psqt;
|
||||
|
||||
#elif defined(USE_MMX)
|
||||
|
||||
constexpr IndexType NumChunks = HalfDimensions / SimdWidth;
|
||||
const __m64 k0x80s = _mm_set1_pi8(-128);
|
||||
|
||||
for (IndexType p = 0; p < 2; ++p)
|
||||
{
|
||||
const IndexType offset = HalfDimensions * p;
|
||||
auto out = reinterpret_cast<__m64*>(&output[offset]);
|
||||
for (IndexType j = 0; j < NumChunks; ++j)
|
||||
{
|
||||
__m64 sum0 = *(&reinterpret_cast<const __m64*>(accumulation[perspectives[p]])[j * 2 + 0]);
|
||||
__m64 sum1 = *(&reinterpret_cast<const __m64*>(accumulation[perspectives[p]])[j * 2 + 1]);
|
||||
const __m64 packedbytes = _mm_packs_pi16(sum0, sum1);
|
||||
out[j] = _mm_subs_pi8(_mm_adds_pi8(packedbytes, k0x80s), k0x80s);
|
||||
}
|
||||
}
|
||||
_mm_empty();
|
||||
return psqt;
|
||||
|
||||
#elif defined(USE_NEON)
|
||||
|
||||
constexpr IndexType NumChunks = HalfDimensions / (SimdWidth / 2);
|
||||
const int8x8_t Zero = {0};
|
||||
|
||||
for (IndexType p = 0; p < 2; ++p)
|
||||
{
|
||||
const IndexType offset = HalfDimensions * p;
|
||||
const auto out = reinterpret_cast<int8x8_t*>(&output[offset]);
|
||||
for (IndexType j = 0; j < NumChunks; ++j)
|
||||
{
|
||||
int16x8_t sum = reinterpret_cast<const int16x8_t*>(accumulation[perspectives[p]])[j];
|
||||
out[j] = vmax_s8(vqmovn_s16(sum), Zero);
|
||||
}
|
||||
}
|
||||
return psqt;
|
||||
|
||||
#else
|
||||
|
||||
for (IndexType p = 0; p < 2; ++p)
|
||||
{
|
||||
const IndexType offset = HalfDimensions * p;
|
||||
for (IndexType j = 0; j < HalfDimensions; ++j)
|
||||
{
|
||||
BiasType sum = accumulation[perspectives[p]][j];
|
||||
output[offset + j] = static_cast<OutputType>(std::max<int>(0, std::min<int>(127, sum)));
|
||||
}
|
||||
}
|
||||
return psqt;
|
||||
|
||||
#endif
|
||||
|
||||
} // end of function transform()
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Stockfish, a UCI chess playing engine derived from Glaurung 2.1
|
||||
Copyright (C) 2004-2021 The Stockfish developers (see AUTHORS file)
|
||||
Copyright (C) 2004-2022 The Stockfish developers (see AUTHORS file)
|
||||
|
||||
Stockfish is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Stockfish, a UCI chess playing engine derived from Glaurung 2.1
|
||||
Copyright (C) 2004-2021 The Stockfish developers (see AUTHORS file)
|
||||
Copyright (C) 2004-2022 The Stockfish developers (see AUTHORS file)
|
||||
|
||||
Stockfish is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Stockfish, a UCI chess playing engine derived from Glaurung 2.1
|
||||
Copyright (C) 2004-2021 The Stockfish developers (see AUTHORS file)
|
||||
Copyright (C) 2004-2022 The Stockfish developers (see AUTHORS file)
|
||||
|
||||
Stockfish is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
+18
-7
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Stockfish, a UCI chess playing engine derived from Glaurung 2.1
|
||||
Copyright (C) 2004-2021 The Stockfish developers (see AUTHORS file)
|
||||
Copyright (C) 2004-2022 The Stockfish developers (see AUTHORS file)
|
||||
|
||||
Stockfish is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -120,12 +120,12 @@ public:
|
||||
Bitboard attackers_to(Square s) const;
|
||||
Bitboard attackers_to(Square s, Bitboard occupied) const;
|
||||
Bitboard slider_blockers(Bitboard sliders, Square s, Bitboard& pinners) const;
|
||||
template<PieceType Pt> Bitboard attacks_by(Color c) const;
|
||||
|
||||
// Properties of moves
|
||||
bool legal(Move m) const;
|
||||
bool pseudo_legal(const Move m) const;
|
||||
bool capture(Move m) const;
|
||||
bool capture_or_promotion(Move m) const;
|
||||
bool gives_check(Move m) const;
|
||||
Piece moved_piece(Move m) const;
|
||||
Piece captured_piece() const;
|
||||
@@ -285,6 +285,22 @@ inline Bitboard Position::attackers_to(Square s) const {
|
||||
return attackers_to(s, pieces());
|
||||
}
|
||||
|
||||
template<PieceType Pt>
|
||||
inline Bitboard Position::attacks_by(Color c) const {
|
||||
|
||||
if constexpr (Pt == PAWN)
|
||||
return c == WHITE ? pawn_attacks_bb<WHITE>(pieces(WHITE, PAWN))
|
||||
: pawn_attacks_bb<BLACK>(pieces(BLACK, PAWN));
|
||||
else
|
||||
{
|
||||
Bitboard threats = 0;
|
||||
Bitboard attackers = pieces(c, Pt);
|
||||
while (attackers)
|
||||
threats |= attacks_bb<Pt>(pop_lsb(attackers), pieces());
|
||||
return threats;
|
||||
}
|
||||
}
|
||||
|
||||
inline Bitboard Position::checkers() const {
|
||||
return st->checkersBB;
|
||||
}
|
||||
@@ -352,11 +368,6 @@ inline bool Position::is_chess960() const {
|
||||
return chess960;
|
||||
}
|
||||
|
||||
inline bool Position::capture_or_promotion(Move m) const {
|
||||
assert(is_ok(m));
|
||||
return type_of(m) != NORMAL ? type_of(m) != CASTLING : !empty(to_sq(m));
|
||||
}
|
||||
|
||||
inline bool Position::capture(Move m) const {
|
||||
assert(is_ok(m));
|
||||
// Castling is encoded as "king captures rook"
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Stockfish, a UCI chess playing engine derived from Glaurung 2.1
|
||||
Copyright (C) 2004-2021 The Stockfish developers (see AUTHORS file)
|
||||
Copyright (C) 2004-2022 The Stockfish developers (see AUTHORS file)
|
||||
|
||||
Stockfish is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Stockfish, a UCI chess playing engine derived from Glaurung 2.1
|
||||
Copyright (C) 2004-2021 The Stockfish developers (see AUTHORS file)
|
||||
Copyright (C) 2004-2022 The Stockfish developers (see AUTHORS file)
|
||||
|
||||
Stockfish is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
+234
-247
File diff suppressed because it is too large
Load Diff
+2
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Stockfish, a UCI chess playing engine derived from Glaurung 2.1
|
||||
Copyright (C) 2004-2021 The Stockfish developers (see AUTHORS file)
|
||||
Copyright (C) 2004-2022 The Stockfish developers (see AUTHORS file)
|
||||
|
||||
Stockfish is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -74,6 +74,7 @@ struct RootMove {
|
||||
|
||||
Value score = -VALUE_INFINITE;
|
||||
Value previousScore = -VALUE_INFINITE;
|
||||
Value averageScore = -VALUE_INFINITE;
|
||||
int selDepth = 0;
|
||||
int tbRank = 0;
|
||||
Value tbScore;
|
||||
|
||||
+50
-4
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Stockfish, a UCI chess playing engine derived from Glaurung 2.1
|
||||
Copyright (C) 2004-2021 The Stockfish developers (see AUTHORS file)
|
||||
Copyright (C) 2004-2022 The Stockfish developers (see AUTHORS file)
|
||||
|
||||
Stockfish is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -46,6 +46,13 @@
|
||||
#define USE_INLINE_ASM
|
||||
#endif
|
||||
|
||||
// Use either the AVX512 or AVX-VNNI version of the VNNI instructions.
|
||||
#if defined(USE_AVXVNNI)
|
||||
#define VNNI_PREFIX "%{vex%} "
|
||||
#else
|
||||
#define VNNI_PREFIX ""
|
||||
#endif
|
||||
|
||||
namespace Stockfish::Simd {
|
||||
|
||||
#if defined (USE_AVX512)
|
||||
@@ -208,7 +215,7 @@ namespace Stockfish::Simd {
|
||||
# if defined (USE_VNNI)
|
||||
# if defined (USE_INLINE_ASM)
|
||||
asm(
|
||||
"vpdpbusd %[b], %[a], %[acc]\n\t"
|
||||
VNNI_PREFIX "vpdpbusd %[b], %[a], %[acc]\n\t"
|
||||
: [acc]"+v"(acc)
|
||||
: [a]"v"(a), [b]"vm"(b)
|
||||
);
|
||||
@@ -240,8 +247,8 @@ namespace Stockfish::Simd {
|
||||
# if defined (USE_VNNI)
|
||||
# if defined (USE_INLINE_ASM)
|
||||
asm(
|
||||
"vpdpbusd %[b0], %[a0], %[acc]\n\t"
|
||||
"vpdpbusd %[b1], %[a1], %[acc]\n\t"
|
||||
VNNI_PREFIX "vpdpbusd %[b0], %[a0], %[acc]\n\t"
|
||||
VNNI_PREFIX "vpdpbusd %[b1], %[a1], %[acc]\n\t"
|
||||
: [acc]"+v"(acc)
|
||||
: [a0]"v"(a0), [b0]"vm"(b0), [a1]"v"(a1), [b1]"vm"(b1)
|
||||
);
|
||||
@@ -336,6 +343,45 @@ namespace Stockfish::Simd {
|
||||
|
||||
#endif
|
||||
|
||||
#if defined (USE_NEON)
|
||||
|
||||
[[maybe_unused]] static int neon_m128_reduce_add_epi32(int32x4_t s) {
|
||||
# if USE_NEON >= 8
|
||||
return vaddvq_s32(s);
|
||||
# else
|
||||
return s[0] + s[1] + s[2] + s[3];
|
||||
# endif
|
||||
}
|
||||
|
||||
[[maybe_unused]] static int neon_m128_hadd(int32x4_t sum, int bias) {
|
||||
return neon_m128_reduce_add_epi32(sum) + bias;
|
||||
}
|
||||
|
||||
[[maybe_unused]] static int32x4_t neon_m128_haddx4(
|
||||
int32x4_t sum0, int32x4_t sum1, int32x4_t sum2, int32x4_t sum3,
|
||||
int32x4_t bias) {
|
||||
|
||||
int32x4_t hsums {
|
||||
neon_m128_reduce_add_epi32(sum0),
|
||||
neon_m128_reduce_add_epi32(sum1),
|
||||
neon_m128_reduce_add_epi32(sum2),
|
||||
neon_m128_reduce_add_epi32(sum3)
|
||||
};
|
||||
return vaddq_s32(hsums, bias);
|
||||
}
|
||||
|
||||
[[maybe_unused]] static void neon_m128_add_dpbusd_epi32x2(
|
||||
int32x4_t& acc,
|
||||
int8x8_t a0, int8x8_t b0,
|
||||
int8x8_t a1, int8x8_t b1) {
|
||||
|
||||
int16x8_t product = vmull_s8(a0, b0);
|
||||
product = vmlal_s8(product, a1, b1);
|
||||
acc = vpadalq_s16(acc, product);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#endif // STOCKFISH_SIMD_H_INCLUDED
|
||||
|
||||
+11
-11
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Stockfish, a UCI chess playing engine derived from Glaurung 2.1
|
||||
Copyright (C) 2004-2021 The Stockfish developers (see AUTHORS file)
|
||||
Copyright (C) 2004-2022 The Stockfish developers (see AUTHORS file)
|
||||
|
||||
Stockfish is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -770,7 +770,7 @@ Ret do_probe_table(const Position& pos, T* entry, WDLScore wdl, ProbeState* resu
|
||||
goto encode_remaining; // With pawns we have finished special treatments
|
||||
}
|
||||
|
||||
// In positions withouth pawns, we further flip the squares to ensure leading
|
||||
// In positions without pawns, we further flip the squares to ensure leading
|
||||
// piece is below RANK_5.
|
||||
if (rank_of(squares[0]) > RANK_4)
|
||||
for (int i = 0; i < size; ++i)
|
||||
@@ -813,7 +813,7 @@ Ret do_probe_table(const Position& pos, T* entry, WDLScore wdl, ProbeState* resu
|
||||
// Rs "together" in 62 * 61 / 2 ways (we divide by 2 because rooks can be
|
||||
// swapped and still get the same position.)
|
||||
//
|
||||
// In case we have at least 3 unique pieces (inlcuded kings) we encode them
|
||||
// In case we have at least 3 unique pieces (included kings) we encode them
|
||||
// together.
|
||||
if (entry->hasUniquePieces) {
|
||||
|
||||
@@ -828,7 +828,7 @@ Ret do_probe_table(const Position& pos, T* entry, WDLScore wdl, ProbeState* resu
|
||||
+ (squares[1] - adjust1)) * 62
|
||||
+ squares[2] - adjust2;
|
||||
|
||||
// First piece is on a1-h8 diagonal, second below: map this occurence to
|
||||
// First piece is on a1-h8 diagonal, second below: map this occurrence to
|
||||
// 6 to differentiate from the above case, rank_of() maps a1-d4 diagonal
|
||||
// to 0...3 and finally MapB1H1H7[] maps the b1-h1-h7 triangle to 0..27.
|
||||
else if (off_A1H8(squares[1]))
|
||||
@@ -858,7 +858,7 @@ encode_remaining:
|
||||
idx *= d->groupIdx[0];
|
||||
Square* groupSq = squares + d->groupLen[0];
|
||||
|
||||
// Encode remainig pawns then pieces according to square, in ascending order
|
||||
// Encode remaining pawns then pieces according to square, in ascending order
|
||||
bool remainingPawns = entry->hasPawns && entry->pawnCount[1];
|
||||
|
||||
while (d->groupLen[++next])
|
||||
@@ -886,7 +886,7 @@ encode_remaining:
|
||||
|
||||
// Group together pieces that will be encoded together. The general rule is that
|
||||
// a group contains pieces of same type and color. The exception is the leading
|
||||
// group that, in case of positions withouth pawns, can be formed by 3 different
|
||||
// group that, in case of positions without pawns, can be formed by 3 different
|
||||
// pieces (default) or by the king pair when there is not a unique piece apart
|
||||
// from the kings. When there are pawns, pawns are always first in pieces[].
|
||||
//
|
||||
@@ -918,7 +918,7 @@ void set_groups(T& e, PairsData* d, int order[], File f) {
|
||||
//
|
||||
// This ensures unique encoding for the whole position. The order of the
|
||||
// groups is a per-table parameter and could not follow the canonical leading
|
||||
// pawns/pieces -> remainig pawns -> remaining pieces. In particular the
|
||||
// pawns/pieces -> remaining pawns -> remaining pieces. In particular the
|
||||
// first group is at order[0] position and the remaining pawns, when present,
|
||||
// are at order[1] position.
|
||||
bool pp = e.hasPawns && e.pawnCount[1]; // Pawns on both sides
|
||||
@@ -938,7 +938,7 @@ void set_groups(T& e, PairsData* d, int order[], File f) {
|
||||
d->groupIdx[1] = idx;
|
||||
idx *= Binomial[d->groupLen[1]][48 - d->groupLen[0]];
|
||||
}
|
||||
else // Remainig pieces
|
||||
else // Remaining pieces
|
||||
{
|
||||
d->groupIdx[next] = idx;
|
||||
idx *= Binomial[d->groupLen[next]][freeSquares];
|
||||
@@ -948,7 +948,7 @@ void set_groups(T& e, PairsData* d, int order[], File f) {
|
||||
d->groupIdx[n] = idx;
|
||||
}
|
||||
|
||||
// In Recursive Pairing each symbol represents a pair of childern symbols. So
|
||||
// In Recursive Pairing each symbol represents a pair of children symbols. So
|
||||
// read d->btree[] symbols data and expand each one in his left and right child
|
||||
// symbol until reaching the leafs that represent the symbol value.
|
||||
uint8_t set_symlen(PairsData* d, Sym s, std::vector<bool>& visited) {
|
||||
@@ -1318,7 +1318,7 @@ void Tablebases::init(const std::string& paths) {
|
||||
for (auto p : bothOnDiagonal)
|
||||
MapKK[p.first][p.second] = code++;
|
||||
|
||||
// Binomial[] stores the Binomial Coefficents using Pascal rule. There
|
||||
// Binomial[] stores the Binomial Coefficients using Pascal rule. There
|
||||
// are Binomial[k][n] ways to choose k elements from a set of n elements.
|
||||
Binomial[0][0] = 1;
|
||||
|
||||
@@ -1338,7 +1338,7 @@ void Tablebases::init(const std::string& paths) {
|
||||
for (int leadPawnsCnt = 1; leadPawnsCnt <= 5; ++leadPawnsCnt)
|
||||
for (File f = FILE_A; f <= FILE_D; ++f)
|
||||
{
|
||||
// Restart the index at every file because TB table is splitted
|
||||
// Restart the index at every file because TB table is split
|
||||
// by file, so we can reuse the same index for different files.
|
||||
int idx = 0;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Stockfish, a UCI chess playing engine derived from Glaurung 2.1
|
||||
Copyright (C) 2004-2021 The Stockfish developers (see AUTHORS file)
|
||||
Copyright (C) 2004-2022 The Stockfish developers (see AUTHORS file)
|
||||
|
||||
Stockfish is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -38,7 +38,7 @@ enum WDLScore {
|
||||
// Possible states after a probing operation
|
||||
enum ProbeState {
|
||||
FAIL = 0, // Probe failed (missing file table)
|
||||
OK = 1, // Probe succesful
|
||||
OK = 1, // Probe successful
|
||||
CHANGE_STM = -1, // DTZ should check the other side
|
||||
ZEROING_BEST_MOVE = 2 // Best move zeroes DTZ (capture or pawn move)
|
||||
};
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Stockfish, a UCI chess playing engine derived from Glaurung 2.1
|
||||
Copyright (C) 2004-2021 The Stockfish developers (see AUTHORS file)
|
||||
Copyright (C) 2004-2022 The Stockfish developers (see AUTHORS file)
|
||||
|
||||
Stockfish is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -59,7 +59,6 @@ void Thread::clear() {
|
||||
|
||||
counterMoves.fill(MOVE_NONE);
|
||||
mainHistory.fill(0);
|
||||
lowPlyHistory.fill(0);
|
||||
captureHistory.fill(0);
|
||||
|
||||
for (bool inCheck : { false, true })
|
||||
@@ -67,7 +66,7 @@ void Thread::clear() {
|
||||
{
|
||||
for (auto& to : continuationHistory[inCheck][c])
|
||||
for (auto& h : to)
|
||||
h->fill(0);
|
||||
h->fill(-71);
|
||||
continuationHistory[inCheck][c][NO_PIECE][0]->fill(Search::CounterMovePruneThreshold - 1);
|
||||
}
|
||||
}
|
||||
@@ -165,6 +164,7 @@ void ThreadPool::clear() {
|
||||
|
||||
main()->callsCnt = 0;
|
||||
main()->bestPreviousScore = VALUE_INFINITE;
|
||||
main()->bestPreviousAverageScore = VALUE_INFINITE;
|
||||
main()->previousTimeReduction = 1.0;
|
||||
}
|
||||
|
||||
|
||||
+6
-7
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Stockfish, a UCI chess playing engine derived from Glaurung 2.1
|
||||
Copyright (C) 2004-2021 The Stockfish developers (see AUTHORS file)
|
||||
Copyright (C) 2004-2022 The Stockfish developers (see AUTHORS file)
|
||||
|
||||
Stockfish is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -61,21 +61,19 @@ public:
|
||||
Pawns::Table pawnsTable;
|
||||
Material::Table materialTable;
|
||||
size_t pvIdx, pvLast;
|
||||
RunningAverage doubleExtensionAverage[COLOR_NB];
|
||||
uint64_t nodesLastExplosive;
|
||||
uint64_t nodesLastNormal;
|
||||
RunningAverage complexityAverage;
|
||||
std::atomic<uint64_t> nodes, tbHits, TTsaves, bestMoveChanges;
|
||||
int selDepth, nmpMinPly;
|
||||
Color nmpColor;
|
||||
ExplosionState state;
|
||||
Value bestValue, optimism[COLOR_NB];
|
||||
|
||||
Position rootPos;
|
||||
StateInfo rootState;
|
||||
Search::RootMoves rootMoves;
|
||||
Depth rootDepth, completedDepth;
|
||||
Depth rootDepth, completedDepth, depth;
|
||||
Value rootDelta;
|
||||
CounterMoveHistory counterMoves;
|
||||
ButterflyHistory mainHistory;
|
||||
LowPlyHistory lowPlyHistory;
|
||||
CapturePieceToHistory captureHistory;
|
||||
ContinuationHistory continuationHistory[2][2];
|
||||
Score trend;
|
||||
@@ -99,6 +97,7 @@ struct MainThread : public Thread {
|
||||
|
||||
double previousTimeReduction;
|
||||
Value bestPreviousScore;
|
||||
Value bestPreviousAverageScore;
|
||||
Value iterValue[4];
|
||||
int callsCnt;
|
||||
bool stopOnPonderhit;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Stockfish, a UCI chess playing engine derived from Glaurung 2.1
|
||||
Copyright (C) 2004-2021 The Stockfish developers (see AUTHORS file)
|
||||
Copyright (C) 2004-2022 The Stockfish developers (see AUTHORS file)
|
||||
|
||||
Stockfish is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Stockfish, a UCI chess playing engine derived from Glaurung 2.1
|
||||
Copyright (C) 2004-2021 The Stockfish developers (see AUTHORS file)
|
||||
Copyright (C) 2004-2022 The Stockfish developers (see AUTHORS file)
|
||||
|
||||
Stockfish is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Stockfish, a UCI chess playing engine derived from Glaurung 2.1
|
||||
Copyright (C) 2004-2021 The Stockfish developers (see AUTHORS file)
|
||||
Copyright (C) 2004-2022 The Stockfish developers (see AUTHORS file)
|
||||
|
||||
Stockfish is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Stockfish, a UCI chess playing engine derived from Glaurung 2.1
|
||||
Copyright (C) 2004-2021 The Stockfish developers (see AUTHORS file)
|
||||
Copyright (C) 2004-2022 The Stockfish developers (see AUTHORS file)
|
||||
|
||||
Stockfish is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -40,9 +40,9 @@ void TTEntry::save(Key k, Value v, bool pv, Bound b, Depth d, Move m, Value ev)
|
||||
move16 = (uint16_t)m;
|
||||
|
||||
// Overwrite less valuable entries (cheapest checks first)
|
||||
if (b == BOUND_EXACT
|
||||
if ( b == BOUND_EXACT
|
||||
|| (uint16_t)k != key16
|
||||
|| d - DEPTH_OFFSET > depth8 - 4)
|
||||
|| d - DEPTH_OFFSET + 2 * pv > depth8 - 4)
|
||||
{
|
||||
assert(d > DEPTH_OFFSET);
|
||||
assert(d < 256 + DEPTH_OFFSET);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Stockfish, a UCI chess playing engine derived from Glaurung 2.1
|
||||
Copyright (C) 2004-2021 The Stockfish developers (see AUTHORS file)
|
||||
Copyright (C) 2004-2022 The Stockfish developers (see AUTHORS file)
|
||||
|
||||
Stockfish is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Stockfish, a UCI chess playing engine derived from Glaurung 2.1
|
||||
Copyright (C) 2004-2021 The Stockfish developers (see AUTHORS file)
|
||||
Copyright (C) 2004-2022 The Stockfish developers (see AUTHORS file)
|
||||
|
||||
Stockfish is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Stockfish, a UCI chess playing engine derived from Glaurung 2.1
|
||||
Copyright (C) 2004-2021 The Stockfish developers (see AUTHORS file)
|
||||
Copyright (C) 2004-2022 The Stockfish developers (see AUTHORS file)
|
||||
|
||||
Stockfish is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -84,7 +84,7 @@ class Tune {
|
||||
|
||||
static Tune& instance() { static Tune t; return t; } // Singleton
|
||||
|
||||
// Use polymorphism to accomodate Entry of different types in the same vector
|
||||
// Use polymorphism to accommodate Entry of different types in the same vector
|
||||
struct EntryBase {
|
||||
virtual ~EntryBase() = default;
|
||||
virtual void init_option() = 0;
|
||||
|
||||
+1
-10
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Stockfish, a UCI chess playing engine derived from Glaurung 2.1
|
||||
Copyright (C) 2004-2021 The Stockfish developers (see AUTHORS file)
|
||||
Copyright (C) 2004-2022 The Stockfish developers (see AUTHORS file)
|
||||
|
||||
Stockfish is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -173,11 +173,6 @@ enum Bound {
|
||||
BOUND_EXACT = BOUND_UPPER | BOUND_LOWER
|
||||
};
|
||||
|
||||
enum ExplosionState {
|
||||
EXPLOSION_NONE,
|
||||
MUST_CALM_DOWN
|
||||
};
|
||||
|
||||
enum Value : int {
|
||||
VALUE_ZERO = 0,
|
||||
VALUE_DRAW = 0,
|
||||
@@ -470,10 +465,6 @@ constexpr Move make_move(Square from, Square to) {
|
||||
return Move((from << 6) + to);
|
||||
}
|
||||
|
||||
constexpr Move reverse_move(Move m) {
|
||||
return make_move(to_sq(m), from_sq(m));
|
||||
}
|
||||
|
||||
template<MoveType T>
|
||||
constexpr Move make(Square from, Square to, PieceType pt = KNIGHT) {
|
||||
return Move(T + ((pt - KNIGHT) << 12) + (from << 6) + to);
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Stockfish, a UCI chess playing engine derived from Glaurung 2.1
|
||||
Copyright (C) 2004-2021 The Stockfish developers (see AUTHORS file)
|
||||
Copyright (C) 2004-2022 The Stockfish developers (see AUTHORS file)
|
||||
|
||||
Stockfish is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Stockfish, a UCI chess playing engine derived from Glaurung 2.1
|
||||
Copyright (C) 2004-2021 The Stockfish developers (see AUTHORS file)
|
||||
Copyright (C) 2004-2022 The Stockfish developers (see AUTHORS file)
|
||||
|
||||
Stockfish is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Stockfish, a UCI chess playing engine derived from Glaurung 2.1
|
||||
Copyright (C) 2004-2021 The Stockfish developers (see AUTHORS file)
|
||||
Copyright (C) 2004-2022 The Stockfish developers (see AUTHORS file)
|
||||
|
||||
Stockfish is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -43,7 +43,7 @@ cat << EOF > repeat.exp
|
||||
expect eof
|
||||
EOF
|
||||
|
||||
# to increase the likelyhood of finding a non-reproducible case,
|
||||
# to increase the likelihood of finding a non-reproducible case,
|
||||
# the allowed number of nodes are varied systematically
|
||||
for i in `seq 1 20`
|
||||
do
|
||||
|
||||
Reference in New Issue
Block a user