diff --git a/.github/workflows/stockfish.yml b/.github/workflows/stockfish.yml index b007ec78..07ecfc07 100644 --- a/.github/workflows/stockfish.yml +++ b/.github/workflows/stockfish.yml @@ -10,341 +10,12 @@ on: - master - tools jobs: - Stockfish: - name: ${{ matrix.config.name }} - runs-on: ${{ matrix.config.os }} - env: - COMPILER: ${{ matrix.config.compiler }} - COMP: ${{ matrix.config.comp }} - CXXFLAGS: "-Werror" - 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, - compiler: g++, - comp: gcc, - run_expensive_tests: true, - run_32bit_tests: true, - run_64bit_tests: true, - shell: 'bash {0}' - } - - { - name: "Ubuntu 20.04 Clang", - os: ubuntu-20.04, - compiler: clang++, - comp: clang, - 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: false, - shell: 'bash {0}' - } - - { - name: "Ubuntu 20.04 NDK armv7", - os: ubuntu-20.04, - compiler: armv7a-linux-androideabi21-clang++, - comp: ndk, - run_armv7_tests: false, - shell: 'bash {0}' - } - - { - name: "MacOS 10.15 Apple Clang", - os: macos-10.15, - compiler: clang++, - comp: clang, - run_64bit_tests: true, - shell: 'bash {0}' - } - - { - name: "MacOS 10.15 GCC 10", - os: macos-10.15, - compiler: g++-10, - comp: gcc, - run_64bit_tests: true, - shell: 'bash {0}' - } - - { - name: "Windows 2022 Mingw-w64 GCC x86_64", - os: windows-2022, - compiler: g++, - comp: mingw, - run_64bit_tests: true, - msys_sys: 'mingw64', - msys_env: 'x86_64-gcc', - shell: 'msys2 {0}' - } - - { - name: "Windows 2022 Mingw-w64 GCC i686", - os: windows-2022, - compiler: g++, - comp: mingw, - run_32bit_tests: true, - msys_sys: 'mingw32', - 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}' - } - - defaults: - run: - working-directory: src - shell: ${{ matrix.config.shell }} - steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - - name: Download required linux packages - if: runner.os == 'Linux' - run: | - sudo apt update - 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}} make git expect - - - name: Download the used network from the fishtest framework - run: | - make net - - - name: Extract the bench number from the commit history - run: | - git log HEAD | grep "\b[Bb]ench[ :]\+[0-9]\{7\}" | head -n 1 | sed "s/[^0-9]*\([0-9]*\).*/\1/g" > git_sig - [ -s git_sig ] && echo "benchref=$(cat git_sig)" >> $GITHUB_ENV && echo "Reference bench:" $(cat git_sig) || echo "No bench found" - - - name: Check compiler - run: | - export PATH=$PATH:$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin - $COMPILER -v - - - name: Test help target - run: | - make help - - # x86-32 tests - - - name: Test debug x86-32 build - if: ${{ matrix.config.run_32bit_tests }} - run: | - export CXXFLAGS="-Werror -D_GLIBCXX_DEBUG" - make clean - make -j2 ARCH=x86-32 optimize=no debug=yes build - ../tests/signature.sh $benchref - - - name: Test x86-32 build - if: ${{ matrix.config.run_32bit_tests }} - run: | - make clean - make -j2 ARCH=x86-32 build - ../tests/signature.sh $benchref - - - name: Test x86-32-sse41-popcnt build - if: ${{ matrix.config.run_32bit_tests }} - run: | - make clean - make -j2 ARCH=x86-32-sse41-popcnt build - ../tests/signature.sh $benchref - - - name: Test x86-32-sse2 build - if: ${{ matrix.config.run_32bit_tests }} - run: | - make clean - make -j2 ARCH=x86-32-sse2 build - ../tests/signature.sh $benchref - - - name: Test general-32 build - if: ${{ matrix.config.run_32bit_tests }} - run: | - make clean - make -j2 ARCH=general-32 build - ../tests/signature.sh $benchref - - # x86-64 tests - - - name: Test debug x86-64-modern build - if: ${{ matrix.config.run_64bit_tests }} - run: | - export CXXFLAGS="-Werror -D_GLIBCXX_DEBUG" - make clean - make -j2 ARCH=x86-64-modern optimize=no debug=yes build - ../tests/signature.sh $benchref - - - name: Test x86-64-modern build - if: ${{ matrix.config.run_64bit_tests }} - run: | - make clean - make -j2 ARCH=x86-64-modern build - ../tests/signature.sh $benchref - - - name: Test x86-64-ssse3 build - if: ${{ matrix.config.run_64bit_tests }} - run: | - make clean - make -j2 ARCH=x86-64-ssse3 build - ../tests/signature.sh $benchref - - - name: Test x86-64-sse3-popcnt build - if: ${{ matrix.config.run_64bit_tests }} - run: | - make clean - make -j2 ARCH=x86-64-sse3-popcnt build - ../tests/signature.sh $benchref - - - name: Test x86-64 build - if: ${{ matrix.config.run_64bit_tests }} - run: | - make clean - make -j2 ARCH=x86-64 build - ../tests/signature.sh $benchref - - - name: Test general-64 build - if: matrix.config.run_64bit_tests - run: | - make clean - make -j2 ARCH=general-64 build - ../tests/signature.sh $benchref - - # x86-64 with newer extensions tests - - - name: Compile x86-64-avx2 build - if: ${{ matrix.config.run_64bit_tests }} - run: | - make clean - make -j2 ARCH=x86-64-avx2 build - - - name: Compile x86-64-bmi2 build - if: ${{ matrix.config.run_64bit_tests }} - run: | - make clean - make -j2 ARCH=x86-64-bmi2 build - - - name: Compile x86-64-avx512 build - if: ${{ matrix.config.run_64bit_tests }} - run: | - make clean - make -j2 ARCH=x86-64-avx512 build - - - name: Compile x86-64-vnni512 build - if: ${{ matrix.config.run_64bit_tests }} - run: | - make clean - make -j2 ARCH=x86-64-vnni512 build - - - name: Compile x86-64-vnni256 build - if: ${{ matrix.config.run_64bit_tests }} - run: | - make clean - make -j2 ARCH=x86-64-vnni256 build - - # armv8 tests - - - name: Test armv8 build - if: ${{ matrix.config.run_armv8_tests }} - run: | - ANDROID_ROOT=/usr/local/lib/android - ANDROID_SDK_ROOT=${ANDROID_ROOT}/sdk - SDKMANAGER=${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager - echo "y" | $SDKMANAGER "ndk;21.4.7075529" - ANDROID_NDK_ROOT=${ANDROID_SDK_ROOT}/ndk-bundle - ln -sfn $ANDROID_SDK_ROOT/ndk/21.4.7075529 $ANDROID_NDK_ROOT - 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: | - ANDROID_ROOT=/usr/local/lib/android - ANDROID_SDK_ROOT=${ANDROID_ROOT}/sdk - SDKMANAGER=${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager - echo "y" | $SDKMANAGER "ndk;21.4.7075529" - ANDROID_NDK_ROOT=${ANDROID_SDK_ROOT}/ndk-bundle - ln -sfn $ANDROID_SDK_ROOT/ndk/21.4.7075529 $ANDROID_NDK_ROOT - 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: | - ANDROID_ROOT=/usr/local/lib/android - ANDROID_SDK_ROOT=${ANDROID_ROOT}/sdk - SDKMANAGER=${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager - echo "y" | $SDKMANAGER "ndk;21.4.7075529" - ANDROID_NDK_ROOT=${ANDROID_SDK_ROOT}/ndk-bundle - ln -sfn $ANDROID_SDK_ROOT/ndk/21.4.7075529 $ANDROID_NDK_ROOT - 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 - if: ${{ matrix.config.run_64bit_tests }} - run: | - make clean - make -j2 ARCH=x86-64-modern build - ../tests/perft.sh - ../tests/reprosearch.sh - - # Sanitizers - - - name: Run under valgrind - if: ${{ matrix.config.run_expensive_tests }} - run: | - export CXXFLAGS="-O1 -fno-inline" - make clean - make -j2 ARCH=x86-64-modern debug=yes optimize=no build > /dev/null - ../tests/instrumented.sh --valgrind - ../tests/instrumented.sh --valgrind-thread - - - name: Run with UB sanitizer - if: ${{ matrix.config.run_expensive_tests }} - run: | - export CXXFLAGS="-O1 -fno-inline" - make clean - make -j2 ARCH=x86-64-modern sanitize=undefined optimize=no debug=yes build > /dev/null - ../tests/instrumented.sh --sanitizer-undefined - - - name: Run with thread sanitizer - if: ${{ matrix.config.run_expensive_tests }} - run: | - export CXXFLAGS="-O1 -fno-inline" - make clean - make -j2 ARCH=x86-64-modern sanitize=thread optimize=no debug=yes build > /dev/null - ../tests/instrumented.sh --sanitizer-thread + Sanitizers: + uses: ./.github/workflows/stockfish_sanitizers.yml + Tests: + uses: ./.github/workflows/stockfish_test.yml + Compiles: + uses: ./.github/workflows/stockfish_compile_test.yml + Binaries: + if: github.ref == 'refs/heads/master' + uses: ./.github/workflows/stockfish_binaries.yml diff --git a/.github/workflows/stockfish_binaries.yml b/.github/workflows/stockfish_binaries.yml new file mode 100644 index 00000000..0b205ded --- /dev/null +++ b/.github/workflows/stockfish_binaries.yml @@ -0,0 +1,110 @@ +name: Stockfish +on: + workflow_call: +jobs: + Stockfish: + name: ${{ matrix.config.name }} ${{ matrix.binaries }} + runs-on: ${{ matrix.config.os }} + env: + COMPILER: ${{ matrix.config.compiler }} + COMP: ${{ matrix.config.comp }} + EXT: ${{ matrix.config.ext }} + OS: ${{ matrix.config.os }} + BINARY: ${{ matrix.binaries }} + strategy: + matrix: + config: + - { + name: "Ubuntu 20.04 GCC", + os: ubuntu-20.04, + compiler: g++, + comp: gcc, + shell: 'bash {0}' + } + - { + name: "MacOS 12 Apple Clang", + os: macos-12, + compiler: clang++, + comp: clang, + shell: 'bash {0}' + } + - { + name: "Windows 2022 Mingw-w64 GCC x86_64", + os: windows-2022, + compiler: g++, + comp: mingw, + msys_sys: 'mingw64', + msys_env: 'x86_64-gcc', + shell: 'msys2 {0}', + ext: .exe + } + binaries: + - x86-64 + - x86-64-modern + - x86-64-avx2 + exclude: + - binaries: x86-64-avx2 + config: {os: macos-12} + defaults: + run: + working-directory: src + shell: ${{ matrix.config.shell }} + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Download required linux packages + if: runner.os == 'Linux' + run: | + sudo apt update + + - 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}} make git expect + + - name: Download the used network from the fishtest framework + run: | + make net + + - name: Check compiler + run: | + export PATH=$PATH:$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin + $COMPILER -v + + - name: Test help target + run: | + make help + + # Compile profile guided builds + + - name: Compile ${{ matrix.binaries }} build + run: | + make clean + make -j2 profile-build ARCH=$BINARY COMP=$COMP + strip ./stockfish$EXT + mv ./stockfish$EXT ../stockfish-$OS-$BINARY$EXT + + - name: Remove non src files + run: rm -f *.o .depend *.nnue + + - name: Create tar archive. + run: | + cd .. + mkdir stockfish + cp -r src stockfish/ + cp stockfish-$OS-$BINARY$EXT stockfish/ + cp "Top CPU Contributors.txt" stockfish/ + cp Copying.txt stockfish/ + cp AUTHORS stockfish/ + tar -cvf stockfish-$OS-$BINARY.tar stockfish + + - name: Upload binaries + uses: actions/upload-artifact@v3 + with: + name: stockfish-${{ matrix.config.os }}-${{ matrix.binaries }} + path: | + stockfish-${{ matrix.config.os }}-${{ matrix.binaries }}.tar diff --git a/.github/workflows/stockfish_compile_test.yml b/.github/workflows/stockfish_compile_test.yml new file mode 100644 index 00000000..63136737 --- /dev/null +++ b/.github/workflows/stockfish_compile_test.yml @@ -0,0 +1,115 @@ +name: Stockfish +on: + workflow_call: +jobs: + Stockfish: + name: ${{ matrix.config.name }} + runs-on: ${{ matrix.config.os }} + env: + COMPILER: ${{ matrix.config.compiler }} + COMP: ${{ matrix.config.comp }} + strategy: + matrix: + config: + - { + name: "Ubuntu 20.04 GCC", + os: ubuntu-20.04, + compiler: g++, + comp: gcc, + shell: 'bash {0}' + } + - { + name: "Ubuntu 20.04 Clang", + os: ubuntu-20.04, + compiler: clang++, + comp: clang, + shell: 'bash {0}' + } + - { + name: "MacOS 12 Apple Clang", + os: macos-12, + compiler: clang++, + comp: clang, + shell: 'bash {0}' + } + - { + name: "MacOS 12 GCC 11", + os: macos-12, + compiler: g++-11, + comp: gcc, + shell: 'bash {0}' + } + - { + name: "Windows 2022 Mingw-w64 GCC x86_64", + os: windows-2022, + compiler: g++, + comp: mingw, + msys_sys: 'mingw64', + msys_env: 'x86_64-gcc', + shell: 'msys2 {0}' + } + - { + name: "Windows 2022 Mingw-w64 Clang x86_64", + os: windows-2022, + compiler: clang++, + comp: clang, + msys_sys: 'clang64', + msys_env: 'clang-x86_64-clang', + shell: 'msys2 {0}' + } + + defaults: + run: + working-directory: src + shell: ${{ matrix.config.shell }} + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - 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}} make git expect + + - name: Download the used network from the fishtest framework + run: | + make net + + - name: Check compiler + run: | + export PATH=$PATH:$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin + $COMPILER -v + + - name: Test help target + run: | + make help + + # x86-64 with newer extensions tests + + - name: Compile x86-64-avx2 build + run: | + make clean + make -j2 ARCH=x86-64-avx2 build + + - name: Compile x86-64-bmi2 build + run: | + make clean + make -j2 ARCH=x86-64-bmi2 build + + - name: Compile x86-64-avx512 build + run: | + make clean + make -j2 ARCH=x86-64-avx512 build + + - name: Compile x86-64-vnni512 build + run: | + make clean + make -j2 ARCH=x86-64-vnni512 build + + - name: Compile x86-64-vnni256 build + run: | + make clean + make -j2 ARCH=x86-64-vnni256 build \ No newline at end of file diff --git a/.github/workflows/stockfish_sanitizers.yml b/.github/workflows/stockfish_sanitizers.yml new file mode 100644 index 00000000..61eaf0c9 --- /dev/null +++ b/.github/workflows/stockfish_sanitizers.yml @@ -0,0 +1,77 @@ +name: Stockfish +on: + workflow_call: +jobs: + Stockfish: + name: ${{ matrix.sanitizers.name }} + runs-on: ${{ matrix.config.os }} + env: + COMPILER: ${{ matrix.config.compiler }} + COMP: ${{ matrix.config.comp }} + CXXFLAGS: "-Werror" + strategy: + matrix: + config: + - { + name: "Ubuntu 20.04 GCC", + os: ubuntu-20.04, + compiler: g++, + comp: gcc, + shell: 'bash {0}' + } + sanitizers: + - { + name: Run with thread sanitizer, + make_option: sanitize=thread, + instrumented_option: sanitizer-thread + } + - { + name: Run with UB sanitizer, + make_option: sanitize=undefined, + instrumented_option: sanitizer-undefined + } + - { + name: Run under valgrind, + make_option: "", + instrumented_option: valgrind + } + - { + name: Run under valgrind-thread, + make_option: "", + instrumented_option: valgrind-thread + } + defaults: + run: + working-directory: src + shell: ${{ matrix.config.shell }} + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Download required linux packages + run: | + sudo apt update + sudo apt install expect valgrind g++-multilib qemu-user + + - name: Download the used network from the fishtest framework + run: | + make net + + - name: Check compiler + run: | + export PATH=$PATH:$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin + $COMPILER -v + + - name: Test help target + run: | + make help + + # Sanitizers + + - name: ${{ matrix.sanitizers.name }} + run: | + export CXXFLAGS="-O1 -fno-inline" + make clean + make -j2 ARCH=x86-64-modern ${{ matrix.sanitizers.make_option }} debug=yes optimize=no build > /dev/null + ../tests/instrumented.sh --${{ matrix.sanitizers.instrumented_option }} \ No newline at end of file diff --git a/.github/workflows/stockfish_test.yml b/.github/workflows/stockfish_test.yml new file mode 100644 index 00000000..46b4e26f --- /dev/null +++ b/.github/workflows/stockfish_test.yml @@ -0,0 +1,284 @@ +name: Stockfish +on: + workflow_call: +jobs: + Stockfish: + name: ${{ matrix.config.name }} + runs-on: ${{ matrix.config.os }} + env: + COMPILER: ${{ matrix.config.compiler }} + COMP: ${{ matrix.config.comp }} + CXXFLAGS: "-Werror" + strategy: + matrix: + config: + - { + name: "Ubuntu 20.04 GCC", + os: ubuntu-20.04, + compiler: g++, + comp: gcc, + run_32bit_tests: true, + run_64bit_tests: true, + shell: 'bash {0}' + } + - { + name: "Ubuntu 20.04 Clang", + os: ubuntu-20.04, + compiler: clang++, + comp: clang, + 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: false, + shell: 'bash {0}' + } + - { + name: "Ubuntu 20.04 NDK armv7", + os: ubuntu-20.04, + compiler: armv7a-linux-androideabi21-clang++, + comp: ndk, + run_armv7_tests: false, + shell: 'bash {0}' + } + - { + name: "MacOS 12 Apple Clang", + os: macos-12, + compiler: clang++, + comp: clang, + run_64bit_tests: true, + shell: 'bash {0}' + } + - { + name: "MacOS 12 GCC 11", + os: macos-12, + compiler: g++-11, + comp: gcc, + run_64bit_tests: true, + shell: 'bash {0}' + } + - { + name: "Windows 2022 Mingw-w64 GCC x86_64", + os: windows-2022, + compiler: g++, + comp: mingw, + run_64bit_tests: true, + msys_sys: 'mingw64', + msys_env: 'x86_64-gcc', + shell: 'msys2 {0}' + } + - { + name: "Windows 2022 Mingw-w64 GCC i686", + os: windows-2022, + compiler: g++, + comp: mingw, + run_32bit_tests: true, + msys_sys: 'mingw32', + 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}' + } + exclude: + - config: + { + name: "Ubuntu 20.04 NDK armv7" + } + - config: + { + name: "Ubuntu 20.04 NDK armv8" + } + defaults: + run: + working-directory: src + shell: ${{ matrix.config.shell }} + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Download required linux packages + if: runner.os == 'Linux' + run: | + sudo apt update + 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}} make git expect + + - name: Download the used network from the fishtest framework + run: | + make net + + - name: Extract the bench number from the commit history + run: | + git log HEAD | grep "\b[Bb]ench[ :]\+[0-9]\{7\}" | head -n 1 | sed "s/[^0-9]*\([0-9]*\).*/\1/g" > git_sig + [ -s git_sig ] && echo "benchref=$(cat git_sig)" >> $GITHUB_ENV && echo "Reference bench:" $(cat git_sig) || echo "No bench found" + + - name: Check compiler + run: | + export PATH=$PATH:$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin + $COMPILER -v + + - name: Test help target + run: | + make help + + # x86-32 tests + + - name: Test debug x86-32 build + if: ${{ matrix.config.run_32bit_tests }} + run: | + export CXXFLAGS="-Werror -D_GLIBCXX_DEBUG" + make clean + make -j2 ARCH=x86-32 optimize=no debug=yes build + ../tests/signature.sh $benchref + + - name: Test x86-32 build + if: ${{ matrix.config.run_32bit_tests }} + run: | + make clean + make -j2 ARCH=x86-32 build + ../tests/signature.sh $benchref + + - name: Test x86-32-sse41-popcnt build + if: ${{ matrix.config.run_32bit_tests }} + run: | + make clean + make -j2 ARCH=x86-32-sse41-popcnt build + ../tests/signature.sh $benchref + + - name: Test x86-32-sse2 build + if: ${{ matrix.config.run_32bit_tests }} + run: | + make clean + make -j2 ARCH=x86-32-sse2 build + ../tests/signature.sh $benchref + + - name: Test general-32 build + if: ${{ matrix.config.run_32bit_tests }} + run: | + make clean + make -j2 ARCH=general-32 build + ../tests/signature.sh $benchref + + # x86-64 tests + + - name: Test debug x86-64-modern build + if: ${{ matrix.config.run_64bit_tests }} + run: | + export CXXFLAGS="-Werror -D_GLIBCXX_DEBUG" + make clean + make -j2 ARCH=x86-64-modern optimize=no debug=yes build + ../tests/signature.sh $benchref + + - name: Test x86-64-modern build + if: ${{ matrix.config.run_64bit_tests }} + run: | + make clean + make -j2 ARCH=x86-64-modern build + ../tests/signature.sh $benchref + + - name: Test x86-64-ssse3 build + if: ${{ matrix.config.run_64bit_tests }} + run: | + make clean + make -j2 ARCH=x86-64-ssse3 build + ../tests/signature.sh $benchref + + - name: Test x86-64-sse3-popcnt build + if: ${{ matrix.config.run_64bit_tests }} + run: | + make clean + make -j2 ARCH=x86-64-sse3-popcnt build + ../tests/signature.sh $benchref + + - name: Test x86-64 build + if: ${{ matrix.config.run_64bit_tests }} + run: | + make clean + make -j2 ARCH=x86-64 build + ../tests/signature.sh $benchref + + - name: Test general-64 build + if: matrix.config.run_64bit_tests + run: | + make clean + make -j2 ARCH=general-64 build + ../tests/signature.sh $benchref + + # armv8 tests + + - name: Test armv8 build + if: ${{ matrix.config.run_armv8_tests }} + run: | + ANDROID_ROOT=/usr/local/lib/android + ANDROID_SDK_ROOT=${ANDROID_ROOT}/sdk + SDKMANAGER=${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager + echo "y" | $SDKMANAGER "ndk;21.4.7075529" + ANDROID_NDK_ROOT=${ANDROID_SDK_ROOT}/ndk-bundle + ln -sfn $ANDROID_SDK_ROOT/ndk/21.4.7075529 $ANDROID_NDK_ROOT + 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: | + ANDROID_ROOT=/usr/local/lib/android + ANDROID_SDK_ROOT=${ANDROID_ROOT}/sdk + SDKMANAGER=${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager + echo "y" | $SDKMANAGER "ndk;21.4.7075529" + ANDROID_NDK_ROOT=${ANDROID_SDK_ROOT}/ndk-bundle + ln -sfn $ANDROID_SDK_ROOT/ndk/21.4.7075529 $ANDROID_NDK_ROOT + 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: | + ANDROID_ROOT=/usr/local/lib/android + ANDROID_SDK_ROOT=${ANDROID_ROOT}/sdk + SDKMANAGER=${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager + echo "y" | $SDKMANAGER "ndk;21.4.7075529" + ANDROID_NDK_ROOT=${ANDROID_SDK_ROOT}/ndk-bundle + ln -sfn $ANDROID_SDK_ROOT/ndk/21.4.7075529 $ANDROID_NDK_ROOT + 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 + if: ${{ matrix.config.run_64bit_tests }} + run: | + make clean + make -j2 ARCH=x86-64-modern build + ../tests/perft.sh + ../tests/reprosearch.sh \ No newline at end of file diff --git a/AUTHORS b/AUTHORS index 173669d4..432d9b90 100644 --- a/AUTHORS +++ b/AUTHORS @@ -91,7 +91,7 @@ Hongzhi Cheng Ivan Ivec (IIvec) Jacques B. (Timshel) Jan Ondruš (hxim) -Jared Kish (Kurtbusch) +Jared Kish (Kurtbusch, kurt22i) Jarrod Torriero (DU-jdto) Jean Gauthier (OuaisBla) Jean-Francois Romang (jromang) diff --git a/Top CPU Contributors.txt b/Top CPU Contributors.txt index 23a5d7f9..30c963d7 100644 --- a/Top CPU Contributors.txt +++ b/Top CPU Contributors.txt @@ -1,245 +1,260 @@ -Contributors to Fishtest with >10,000 CPU hours, as of 2022-07-31. +Contributors to Fishtest with >10,000 CPU hours, as of 2022-11-19. Thank you! Username CPU Hours Games played ------------------------------------------------------------------ -noobpwnftw 33202707 2423743815 -technologov 5064327 270208248 -mlang 2963357 198937430 -dew 1677196 99717674 -grandphish2 1231326 74551309 -okrout 1102747 98977462 -TueRens 925904 57404676 -pemo 911980 35581261 -tvijlbrief 795993 51894442 -JojoM 774270 47311084 +noobpwnftw 36475307 2748033975 +technologov 14570711 760073590 +mlang 3026000 200065824 +dew 1689222 100034318 +grandphish2 1442171 86798057 +okrout 1439985 133471766 +pemo 1405374 44189811 +linrock 1299003 28382783 +TueRens 1163420 71159522 +JojoM 897158 55177114 +tvijlbrief 796125 51897690 mibere 703840 46867607 -linrock 697283 18804969 -gvreuls 564284 36392236 -cw 515739 34775505 -fastgm 500949 30101898 -oz 439015 31794460 -CSU_Dynasty 438017 29369136 +gvreuls 635982 40652394 +oz 590763 41201352 +sebastronomy 581517 23307132 +cw 517915 34865769 +fastgm 504266 30264740 +CSU_Dynasty 479901 31846710 +ctoks 433503 28180725 crunchy 427035 27344275 -ctoks 422671 27812261 -bcross 363335 25108521 -leszek 360149 22674005 -velislav 333325 21444360 +leszek 416883 27493447 +bcross 409982 28062127 +velislav 345954 22232274 Fisherman 327231 21829379 -Dantist 292327 17951982 -mgrabiak 247220 16137378 -nordlandia 226543 14601042 -robal 224740 14314972 -glinscott 217799 13780820 -ncfish1 207751 13909639 -drabel 203884 13922680 -mhoram 200022 12533963 +Dantist 296386 18031762 +mgrabiak 288928 18869896 +rpngn 259965 16281463 +robal 237653 15148350 +ncfish1 231764 15275003 +nordlandia 226923 14624832 +glinscott 208125 13277240 +drabel 204167 13930674 +mhoram 202894 12601997 bking_US 198894 11876016 -rpngn 191764 12236583 +thirdlife 198844 5453268 Thanar 179852 12365359 vdv 175544 9904472 +armo9494 168201 11136452 spams 157128 10319326 -marrco 150300 9402229 +marrco 151599 9551115 sqrt2 147963 9724586 -vdbergh 137480 8958795 +vdbergh 137690 8971569 CoffeeOne 137100 5024116 malala 136182 8002293 +DesolatedDodo 135276 8657464 xoto 133759 9159372 -davar 128645 8367253 -DesolatedDodo 124877 8056482 +davar 129023 8376525 dsmith 122059 7570238 amicic 119661 7938029 Data 113305 8220352 BrunoBanani 112960 7436849 -CypressChess 108321 7759588 +CypressChess 108331 7759788 +skiminki 106518 7062598 MaZePallas 102823 6633619 -skiminki 102168 6778440 sterni1971 100532 5880772 sunu 100167 7040199 +zeryl 99331 6221261 ElbertoOne 99028 7023771 -zeryl 96984 6162287 +DMBK 97572 6950312 +Calis007 96779 5611552 +cuistot 93111 5536500 brabos 92118 6186135 -cuistot 91738 5447070 +Wolfgang 91769 5720158 psk 89957 5984901 -racerschmacer 85712 6119648 +racerschmacer 85805 6122790 +jcAEie 85527 5630616 Vizvezdenec 83761 5344740 -sschnee 83003 4840890 +sschnee 83557 4853690 0x3C33 82614 5271253 -armo9494 82501 5806056 BRAVONE 81239 5054681 +Dubslow 78461 5042980 nssy 76497 5259388 -thirdlife 76478 1544524 -Calis007 76457 4281018 -jromang 75885 5230523 +jromang 76106 5236025 teddybaer 75125 5407666 +yurikvelo 73933 5031096 +tolkki963 73885 4721430 Pking_cda 73776 5293873 -Wolfgang 72750 4538670 -sebastronomy 70784 1329428 +Bobo1239 71675 4860987 solarlight 70517 5028306 dv8silencer 70287 3883992 -Bobo1239 68515 4652287 -yurikvelo 67651 4578970 +Gelma 69304 3980932 manap 66273 4121774 +megaman7de 65419 4120200 +markkulix 65331 4114860 +bigpen0r 64932 4683883 tinker 64333 4268790 qurashee 61208 3429862 +AGI 58325 4258646 robnjr 57262 4053117 -megaman7de 57023 3525850 Freja 56938 3733019 -MaxKlaxxMiner 56279 3410158 +MaxKlaxxMiner 56879 3423958 ttruscott 56010 3680085 rkl 55132 4164467 renouve 53811 3501516 -tolkki963 53294 3354682 -DMBK 52963 3933332 +Spprtr 52736 3410019 finfish 51360 3370515 eva42 51272 3599691 -Spprtr 51139 3299983 -eastorwest 51058 3451555 +eastorwest 51117 3454811 rap 49985 3219146 +unixwizard 49734 2536230 pb00067 49727 3298270 -bigpen0r 47667 3336927 ronaldjerum 47654 3240695 biffhero 46564 3111352 +GPUex 45861 2926502 Fifis 45843 3088497 +oryx 45578 3493978 VoyagerOne 45476 3452465 +Wencey 44943 2654490 speedycpu 43842 3003273 jbwiebe 43305 2805433 Antihistamine 41788 2761312 mhunt 41735 2691355 +olafm 41277 3284344 homyur 39893 2850481 gri 39871 2515779 -oryx 39602 3024830 +MarcusTullius 38303 2251097 +Garf 37741 2999686 +kdave 37424 2557406 SC 37299 2731694 -Garf 37213 2986270 -Dubslow 36714 2409254 csnodgrass 36207 2688994 jmdana 36157 2210661 -markkulix 35994 2226860 strelock 34716 2074055 EthanOConnor 33370 2090311 slakovv 32915 2021889 -gopeto 31078 2033362 +gopeto 31669 2060958 manapbk 30987 1810399 Prcuvu 30377 2170122 anst 30301 2190091 jkiiski 30136 1904470 +spcc 30135 1903728 hyperbolic.tom 29840 2017394 +xwziegtm 29763 2347412 chuckstablers 29659 2093438 Pyafue 29650 1902349 -MarcusTullius 28611 1646671 -spcc 28241 1821198 -belzedar94 27935 1789106 +belzedar94 28846 1811530 OuaisBla 27636 1578800 chriswk 26902 1868317 achambord 26582 1767323 Patrick_G 26276 1801617 yorkman 26193 1992080 +Ulysses 25289 1674274 SFTUser 25182 1675689 nabildanial 24942 1519409 Sharaf_DG 24765 1786697 -rodneyc 24375 1416258 -Ulysses 24017 1626140 +rodneyc 24376 1416402 agg177 23890 1395014 +Ente 23747 1674582 +Karpovbot 23629 1313186 JanErik 23408 1703875 -Ente 23403 1660988 -kdave 23392 1630462 Isidor 23388 1680691 -Norabor 23339 1602636 -cisco2015 22897 1762669 -Wencey 22573 1121406 +Norabor 23371 1603244 +cisco2015 22934 1763773 Zirie 22542 1472937 team-oh 22272 1636708 +Roady 22220 1465606 MazeOfGalious 21978 1629593 -sg4032 21947 1643265 +sg4032 21947 1643353 ianh2105 21725 1632562 xor12 21628 1680365 dex 21612 1467203 nesoneg 21494 1463031 -Roady 21323 1433822 +user213718 21454 1404128 +AndreasKrug 21227 1577833 sphinx 21211 1384728 -user213718 21196 1397710 jjoshua2 21001 1423089 horst.prack 20878 1465656 +jsys14 20729 1221010 0xB00B1ES 20590 1208666 j3corre 20405 941444 Adrian.Schmidt123 20316 1281436 -jcAEie 20221 1504162 +bonsi 20022 1300682 wei 19973 1745989 +dapper 19754 1167758 +Zake9298 19745 1458416 +fishtester 19617 1257388 rstoesser 19569 1293588 eudhan 19274 1283717 -fishtester 19145 1242668 vulcan 18871 1729392 +Jopo12321 18803 1036284 jundery 18445 1115855 -iisiraider 18247 1101015 ville 17883 1384026 +5t0ckf15hTr4in3r 17809 1105858 chris 17698 1487385 +dju 17697 994333 purplefishies 17595 1092533 -dju 17353 978595 -AndreasKrug 17191 1317997 +iisiraider 17275 1049015 DragonLord 17014 1162790 -Jopo12321 16966 944924 -GPUex 16744 1077826 -xwziegtm 16608 1276372 +Karby 16457 1010138 +Goatminola 16278 1145026 IgorLeMasson 16064 1147232 +Gaster319 16056 1109070 +redstone59 15953 1161664 +scuzzi 15757 968735 ako027ako 15671 1173203 -jsys14 15474 917092 Nikolay.IT 15154 1068349 Andrew Grant 15114 895539 -scuzzi 15112 960373 +Naven94 15054 834762 OssumOpossum 14857 1007129 -Karby 14808 867120 +qoo_charly_cai 14490 847865 enedene 14476 905279 -bpfliegel 14298 884523 +szupaw 14252 929130 +bpfliegel 14233 882523 mpx86 14019 759568 jpulman 13982 870599 -Naven94 13879 811552 -Karpovbot 13808 734276 crocogoat 13803 1117422 -joster 13794 950160 Nesa92 13786 1114691 +joster 13710 946160 mbeier 13650 1044928 Hjax 13535 915487 Dark_wizzie 13422 1007152 Rudolphous 13244 883140 Machariel 13010 863104 +infinigon 12991 943216 +pirt 12925 985437 +Skiff84 12923 649994 mabichito 12903 749391 thijsk 12886 722107 AdrianSA 12860 804972 -infinigon 12807 937332 Flopzee 12698 894821 -pirt 12551 965597 fatmurphy 12547 853210 +woutboat 12419 836696 SapphireBrand 12416 969604 +Oakwen 12406 840961 +deflectooor 12386 579392 modolief 12386 896470 Farseer 12249 694108 pgontarz 12151 848794 stocky 11954 699440 mschmidt 11941 803401 -Oakwen 11925 818865 -MooTheCow 11851 772628 -deflectooor 11642 565132 -dbernier 11609 818636 -Skiff84 11604 602786 +MooTheCow 11871 773654 +Jackfish 11867 773550 +dbernier 11705 821780 +whelanh 11557 245188 Maxim 11543 836024 +Nullvalue 11534 731410 +icewulf 11528 650470 +FormazChar 11523 861599 infinity 11470 727027 -FormazChar 11430 856559 -aga 11409 695071 -Jackfish 11403 750526 +aga 11412 695127 torbjo 11395 729145 Thomas A. Anderson 11372 732094 savage84 11358 670860 +ali-al-zhrani 11272 781310 d64 11263 789184 -qoo_charly_cai 11127 671959 +Bourbaki 11108 709144 snicolet 11106 869170 -ali-al-zhrani 11098 768494 -whelanh 11067 235676 +Alb11747 10855 696920 basepi 10637 744851 Cubox 10621 826448 -Alb11747 10558 689794 +Karmatron 10616 674818 michaelrpg 10509 739239 OIVAS7572 10420 995586 -Garruk 10343 704723 +Garruk 10348 704905 dzjp 10343 732529 ols 10259 570669 -lbraesch 10252 647825 -Karmatron 10195 661432 diff --git a/src/Makefile b/src/Makefile index c6e4fcff..530ea83f 100644 --- a/src/Makefile +++ b/src/Makefile @@ -684,6 +684,18 @@ ifeq ($(pext),yes) endif endif +### 3.7.1 Try to include git commit sha for versioning +GIT_SHA = $(shell git rev-parse --short HEAD 2>/dev/null) +ifneq ($(GIT_SHA), ) + CXXFLAGS += -DGIT_SHA=\"$(GIT_SHA)\" +endif + +### 3.7.2 Try to include git commit date for versioning +GIT_DATE = $(shell git show -s --date=format:'%Y%m%d' --format=%cd HEAD 2>/dev/null) +ifneq ($(GIT_DATE), ) + CXXFLAGS += -DGIT_DATE=\"$(GIT_DATE)\" +endif + ### 3.8 Link Time Optimization ### This is a mix of compile and link time options because the lto link phase ### needs access to the optimization flags. @@ -811,7 +823,7 @@ endif .PHONY: help build profile-build strip install clean net objclean profileclean \ config-sanity icc-profile-use icc-profile-make gcc-profile-use gcc-profile-make \ - clang-profile-use clang-profile-make + clang-profile-use clang-profile-make FORCE build: net config-sanity $(MAKE) ARCH=$(ARCH) COMP=$(COMP) all @@ -960,6 +972,10 @@ config-sanity: net $(EXE): $(OBJS) +$(CXX) -o $@ $(OBJS) $(LDFLAGS) +# Force recompilation to ensure version info is up-to-date +misc.o: FORCE +FORCE: + clang-profile-make: $(MAKE) ARCH=$(ARCH) COMP=$(COMP) \ EXTRACXXFLAGS='-fprofile-instr-generate ' \ diff --git a/src/evaluate.cpp b/src/evaluate.cpp index 3add0abb..ec53796f 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -163,7 +163,7 @@ namespace Trace { Score scores[TERM_NB][COLOR_NB]; - double to_cp(Value v) { return double(v) / PawnValueEg; } + double to_cp(Value v) { return double(v) / UCI::NormalizeToPawnValue; } void add(int idx, Color c, Score s) { scores[idx][c] = s; @@ -985,7 +985,7 @@ namespace { // Initialize score by reading the incrementally updated scores included in // the position object (material + piece square tables) and the material // imbalance. Score is computed internally from the white point of view. - Score score = pos.psq_score() + me->imbalance() + pos.this_thread()->trend; + Score score = pos.psq_score() + me->imbalance(); // Probe the pawn hash table pe = Pawns::probe(pos); @@ -1119,7 +1119,6 @@ std::string Eval::trace(Position& pos) { std::memset(scores, 0, sizeof(scores)); // Reset any global variable used in eval - 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; diff --git a/src/misc.cpp b/src/misc.cpp index d19cd840..2d86969f 100644 --- a/src/misc.cpp +++ b/src/misc.cpp @@ -67,9 +67,8 @@ namespace Stockfish { 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 = ""; +/// Version number or dev. +const string version = "15.1"; /// 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 @@ -138,23 +137,41 @@ public: } // namespace -/// engine_info() returns the full name of the current Stockfish version. This -/// will be either "Stockfish DD-MM-YY" (where DD-MM-YY is the date when -/// the program was compiled) or "Stockfish ", depending on whether -/// Version is empty. +/// engine_info() returns the full name of the current Stockfish version. +/// For local dev compiles we try to append the commit sha and commit date +/// from git if that fails only the local compilation date is set and "nogit" is specified: +/// Stockfish dev-YYYYMMDD-SHA +/// or +/// Stockfish dev-YYYYMMDD-nogit +/// +/// For releases (non dev builds) we only include the version number: +/// Stockfish version string engine_info(bool to_uci) { + stringstream ss; + ss << "Stockfish " << version << setfill('0'); - const string months("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec"); - string month, day, year; - stringstream ss, date(__DATE__); // From compiler, format is "Sep 21 2008" - - ss << "Stockfish " << Version << setfill('0'); - - if (Version.empty()) + if (version == "dev") { + ss << "-"; + #ifdef GIT_DATE + ss << GIT_DATE; + #else + const string months("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec"); + string month, day, year; + stringstream date(__DATE__); // From compiler, format is "Sep 21 2008" + date >> month >> day >> year; - ss << setw(2) << day << setw(2) << (1 + months.find(month) / 4) << year.substr(2); + ss << year << setw(2) << setfill('0') << (1 + months.find(month) / 4) << setw(2) << setfill('0') << day; + #endif + + ss << "-"; + + #ifdef GIT_SHA + ss << GIT_SHA; + #else + ss << "nogit"; + #endif } ss << (to_uci ? "\nid author ": " by ") diff --git a/src/movepick.cpp b/src/movepick.cpp index 587c6d79..188d6bd8 100644 --- a/src/movepick.cpp +++ b/src/movepick.cpp @@ -88,8 +88,8 @@ 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, Depth d, const CapturePieceToHistory* cph) - : pos(p), captureHistory(cph), ttMove(ttm), threshold(th), depth(d) +MovePicker::MovePicker(const Position& p, Move ttm, Value th, const CapturePieceToHistory* cph) + : pos(p), captureHistory(cph), ttMove(ttm), threshold(th) { assert(!pos.checkers()); @@ -191,7 +191,7 @@ top: endMoves = generate(pos, cur); score(); - partial_insertion_sort(cur, endMoves, -3000 * depth); + partial_insertion_sort(cur, endMoves, std::numeric_limits::min()); ++stage; goto top; diff --git a/src/movepick.h b/src/movepick.h index 55fcc644..e4c4a5bf 100644 --- a/src/movepick.h +++ b/src/movepick.h @@ -128,7 +128,7 @@ public: const CapturePieceToHistory*, const PieceToHistory**, Square); - MovePicker(const Position&, Move, Value, Depth, const CapturePieceToHistory*); + MovePicker(const Position&, Move, Value, const CapturePieceToHistory*); Move next_move(bool skipQuiets = false); Bitboard threatenedPieces; diff --git a/src/nnue/evaluate_nnue.cpp b/src/nnue/evaluate_nnue.cpp index ba2ed367..4715fed0 100644 --- a/src/nnue/evaluate_nnue.cpp +++ b/src/nnue/evaluate_nnue.cpp @@ -220,7 +220,7 @@ namespace Stockfish::Eval::NNUE { buffer[0] = (v < 0 ? '-' : v > 0 ? '+' : ' '); - int cp = std::abs(100 * v / PawnValueEg); + int cp = std::abs(100 * v / UCI::NormalizeToPawnValue); if (cp >= 10000) { buffer[1] = '0' + cp / 10000; cp %= 10000; @@ -251,7 +251,7 @@ namespace Stockfish::Eval::NNUE { buffer[0] = (v < 0 ? '-' : v > 0 ? '+' : ' '); - double cp = 1.0 * std::abs(int(v)) / PawnValueEg; + double cp = 1.0 * std::abs(int(v)) / UCI::NormalizeToPawnValue; sprintf(&buffer[1], "%6.2f", cp); } diff --git a/src/position.cpp b/src/position.cpp index 62e6e238..5befcaf2 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -129,7 +129,7 @@ void Position::init() { // Prepare the cuckoo tables std::memset(cuckoo, 0, sizeof(cuckoo)); std::memset(cuckooMove, 0, sizeof(cuckooMove)); - int count = 0; + [[maybe_unused]] int count = 0; for (Piece pc : Pieces) for (Square s1 = SQ_A1; s1 <= SQ_H8; ++s1) for (Square s2 = Square(s1 + 1); s2 <= SQ_H8; ++s2) diff --git a/src/search.cpp b/src/search.cpp index d8f1bc6d..1365e471 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -247,7 +247,7 @@ void MainThread::search() { th->previousDepth = bestThread->completedDepth; // Prepare PVLine and ponder move - std::string PVLine = UCI::pv(bestThread->rootPos, bestThread->completedDepth, -VALUE_INFINITE, VALUE_INFINITE); + std::string PVLine = UCI::pv(bestThread->rootPos, bestThread->completedDepth); bestPreviousScore = bestThread->rootMoves[0].score; bestPreviousAverageScore = bestThread->rootMoves[0].averageScore; @@ -339,7 +339,6 @@ void Thread::search() { complexityAverage.set(155, 1); - trend = SCORE_ZERO; optimism[us] = optimism[~us] = VALUE_ZERO; int searchAgainCounter = 0; @@ -387,11 +386,7 @@ void Thread::search() { alpha = std::max(prev - delta,-VALUE_INFINITE); beta = std::min(prev + delta, VALUE_INFINITE); - // Adjust trend and optimism based on root move's previousScore - int tr = 116 * prev / (std::abs(prev) + 89); - trend = (us == WHITE ? make_score(tr, tr / 2) - : -make_score(tr, tr / 2)); - + // Adjust optimism based on root move's previousScore int opt = 118 * prev / (std::abs(prev) + 169); optimism[ us] = Value(opt); optimism[~us] = -optimism[us]; @@ -430,7 +425,7 @@ void Thread::search() { && (bestValue <= alpha || bestValue >= beta) && Time.elapsed() > 3000) { - sync_cout << UCI::pv(rootPos, rootDepth, alpha, beta) << sync_endl; + sync_cout << UCI::pv(rootPos, rootDepth) << sync_endl; Cluster::cluster_info(rootDepth); } @@ -464,7 +459,7 @@ void Thread::search() { if ( Cluster::is_root() && mainThread && (Threads.stop || pvIdx + 1 == multiPV || Time.elapsed() > 3000)) { - sync_cout << UCI::pv(rootPos, rootDepth, alpha, beta) << sync_endl; + sync_cout << UCI::pv(rootPos, rootDepth) << sync_endl; Cluster::cluster_info(rootDepth); } } @@ -901,7 +896,7 @@ namespace { { assert(probCutBeta < VALUE_INFINITE); - MovePicker mp(pos, ttMove, probCutBeta - ss->staticEval, depth - 3, &captureHistory); + MovePicker mp(pos, ttMove, probCutBeta - ss->staticEval, &captureHistory); while ((move = mp.next_move()) != MOVE_NONE) if (move != excludedMove && pos.legal(move)) @@ -1203,13 +1198,13 @@ moves_loop: // When in check, search starts here if (singularQuietLMR) r--; - // Dicrease reduction if we move a threatened piece (~1 Elo) + // Decrease reduction if we move a threatened piece (~1 Elo) if ( depth > 9 && (mp.threatenedPieces & from_sq(move))) r--; // Increase reduction if next ply has a lot of fail high - if ((ss+1)->cutoffCnt > 3 && !PvNode) + if ((ss+1)->cutoffCnt > 3) r++; ss->statScore = 2 * thisThread->mainHistory[us][from_to(move)] @@ -1219,7 +1214,7 @@ moves_loop: // When in check, search starts here - 4433; // Decrease/increase reduction for moves with a good/bad history (~30 Elo) - r -= ss->statScore / 13628; + r -= ss->statScore / (13628 + 4000 * (depth > 7 && depth < 19)); // In general we want to cap the LMR depth search at newDepth, but when // reduction is negative, we allow this move a limited search extension @@ -1231,8 +1226,15 @@ moves_loop: // When in check, search starts here // Do full depth search when reduced LMR search fails high if (value > alpha && d < newDepth) { + // Adjust full depth search based on LMR results - if result + // was good enough search deeper, if it was bad enough search shallower const bool doDeeperSearch = value > (alpha + 64 + 11 * (newDepth - d)); - value = -search(pos, ss+1, -(alpha+1), -alpha, newDepth + doDeeperSearch, !cutNode); + const bool doShallowerSearch = value < bestValue + newDepth; + + newDepth += doDeeperSearch - doShallowerSearch; + + if (newDepth > d) + value = -search(pos, ss+1, -(alpha+1), -alpha, newDepth, !cutNode); int bonus = value > alpha ? stat_bonus(newDepth) : -stat_bonus(newDepth); @@ -1286,6 +1288,8 @@ moves_loop: // When in check, search starts here { rm.score = value; rm.selDepth = thisThread->selDepth; + rm.scoreLowerbound = value >= beta; + rm.scoreUpperbound = value <= alpha; rm.pv.resize(1); assert((ss+1)->pv); @@ -1339,8 +1343,6 @@ moves_loop: // When in check, search starts here } } } - else - ss->cutoffCnt = 0; // If the move is worse than some previously searched move, remember it to update its stats later @@ -1596,12 +1598,11 @@ moves_loop: // When in check, search starts here && (*contHist[1])[pos.moved_piece(move)][to_sq(move)] < 0) continue; - // movecount pruning for quiet check evasions + // We prune after 2nd quiet check evasion where being 'in check' is implicitly checked through the counter + // and being a 'quiet' apart from being a tt move is assumed after an increment because captures are pushed ahead. if ( bestValue > VALUE_TB_LOSS_IN_MAX_PLY - && quietCheckEvasions > 1 - && !capture - && ss->inCheck) - continue; + && quietCheckEvasions > 1) + break; quietCheckEvasions += !capture && ss->inCheck; @@ -1869,7 +1870,7 @@ void MainThread::check_time() { /// UCI::pv() formats PV information according to the UCI protocol. UCI requires /// that all (if any) unsearched PV lines are sent using a previous search score. -string UCI::pv(const Position& pos, Depth depth, Value alpha, Value beta) { +string UCI::pv(const Position& pos, Depth depth) { std::stringstream ss; TimePoint elapsed = Time.elapsed() + 1; @@ -1907,8 +1908,8 @@ string UCI::pv(const Position& pos, Depth depth, Value alpha, Value beta) { if (Options["UCI_ShowWDL"]) ss << UCI::wdl(v, pos.game_ply()); - if (!tb && i == pvIdx) - ss << (v >= beta ? " lowerbound" : v <= alpha ? " upperbound" : ""); + if (i == pvIdx && !tb && updated) // tablebase- and previous-scores are exact + ss << (rootMoves[i].scoreLowerbound ? " lowerbound" : (rootMoves[i].scoreUpperbound ? " upperbound" : "")); ss << " nodes " << nodesSearched << " nps " << nodesSearched * 1000 / elapsed diff --git a/src/search.h b/src/search.h index f3221c43..3c4a0be3 100644 --- a/src/search.h +++ b/src/search.h @@ -72,6 +72,8 @@ struct RootMove { Value score = -VALUE_INFINITE; Value previousScore = -VALUE_INFINITE; Value averageScore = -VALUE_INFINITE; + bool scoreLowerbound = false; + bool scoreUpperbound = false; int selDepth = 0; int tbRank = 0; Value tbScore; diff --git a/src/thread.cpp b/src/thread.cpp index fcfaeca8..5d981360 100644 --- a/src/thread.cpp +++ b/src/thread.cpp @@ -226,11 +226,14 @@ Thread* ThreadPool::get_best_thread() const { minScore = std::min(minScore, th->rootMoves[0].score); // Vote according to score and depth, and select the best thread - for (Thread* th : *this) - { - votes[th->rootMoves[0].pv[0]] += - (th->rootMoves[0].score - minScore + 14) * int(th->completedDepth); + auto thread_value = [minScore](Thread* th) { + return (th->rootMoves[0].score - minScore + 14) * int(th->completedDepth); + }; + for (Thread* th : *this) + votes[th->rootMoves[0].pv[0]] += thread_value(th); + + for (Thread* th : *this) if (abs(bestThread->rootMoves[0].score) >= VALUE_TB_WIN_IN_MAX_PLY) { // Make sure we pick the shortest mate / TB conversion or stave off mate the longest @@ -241,9 +244,8 @@ Thread* ThreadPool::get_best_thread() const { || ( th->rootMoves[0].score > VALUE_TB_LOSS_IN_MAX_PLY && ( votes[th->rootMoves[0].pv[0]] > votes[bestThread->rootMoves[0].pv[0]] || ( votes[th->rootMoves[0].pv[0]] == votes[bestThread->rootMoves[0].pv[0]] - && th->rootMoves[0].pv.size() > bestThread->rootMoves[0].pv.size())))) + && thread_value(th) > thread_value(bestThread))))) bestThread = th; - } return bestThread; } diff --git a/src/thread.h b/src/thread.h index e49f63e3..aed82591 100644 --- a/src/thread.h +++ b/src/thread.h @@ -76,7 +76,6 @@ public: ButterflyHistory mainHistory; CapturePieceToHistory captureHistory; ContinuationHistory continuationHistory[2][2]; - Score trend; #ifdef USE_MPI struct { std::mutex mutex; diff --git a/src/uci.cpp b/src/uci.cpp index 51909a74..690214ad 100644 --- a/src/uci.cpp +++ b/src/uci.cpp @@ -211,13 +211,17 @@ namespace { // The coefficients of a third-order polynomial fit is based on the fishtest data // for two parameters that need to transform eval to the argument of a logistic // function. - double as[] = { 0.50379905, -4.12755858, 18.95487051, 152.00733652}; - double bs[] = {-1.71790378, 10.71543602, -17.05515898, 41.15680404}; + constexpr double as[] = { -0.58270499, 2.68512549, 15.24638015, 344.49745382}; + constexpr double bs[] = { -2.65734562, 15.96509799, -20.69040836, 73.61029937 }; + + // Enforce that NormalizeToPawnValue corresponds to a 50% win rate at ply 64 + static_assert(UCI::NormalizeToPawnValue == int(as[0] + as[1] + as[2] + as[3])); + double a = (((as[0] * m + as[1]) * m + as[2]) * m) + as[3]; double b = (((bs[0] * m + bs[1]) * m + bs[2]) * m) + bs[3]; // Transform the eval to centipawns with limited range - double x = std::clamp(double(100 * v) / PawnValueEg, -2000.0, 2000.0); + double x = std::clamp(double(v), -4000.0, 4000.0); // Return the win rate in per mille units rounded to the nearest value return int(0.5 + 1000 / (1 + std::exp((a - x) / b))); @@ -320,7 +324,7 @@ string UCI::value(Value v) { stringstream ss; if (abs(v) < VALUE_MATE_IN_MAX_PLY) - ss << "cp " << v * 100 / PawnValueEg; + ss << "cp " << v * 100 / NormalizeToPawnValue; else ss << "mate " << (v > 0 ? VALUE_MATE - v + 1 : -VALUE_MATE - v) / 2; diff --git a/src/uci.h b/src/uci.h index 76a893f9..3b5a6764 100644 --- a/src/uci.h +++ b/src/uci.h @@ -30,6 +30,13 @@ class Position; namespace UCI { +// Normalizes the internal value as reported by evaluate or search +// to the UCI centipawn result used in output. This value is derived from +// the win_rate_model() such that Stockfish outputs an advantage of +// "100 centipawns" for a position if the engine has a 50% probability to win +// from this position in selfplay at fishtest LTC time control. +const int NormalizeToPawnValue = 361; + class Option; /// Define a custom comparator, because the UCI options should be case-insensitive @@ -72,7 +79,7 @@ void loop(int argc, char* argv[]); std::string value(Value v); std::string square(Square s); std::string move(Move m, bool chess960); -std::string pv(const Position& pos, Depth depth, Value alpha, Value beta); +std::string pv(const Position& pos, Depth depth); std::string wdl(Value v, int ply); Move to_move(const Position& pos, std::string& str);