mirror of
https://github.com/sockspls/badfish
synced 2025-04-29 08:13:08 +00:00
Add a standardized benchmark command speedtest
.
`speedtest [threads] [hash_MiB] [time_s]`. `threads` default to system concurrency. `hash_MiB` defaults to `threads*128`. `time_s` defaults to 150. Intended to be used with default parameters, as a stable hardware benchmark. Example: ``` C:\dev\stockfish-master\src>stockfish.exe speedtest Stockfish dev-20240928-nogit by the Stockfish developers (see AUTHORS file) info string Using 16 threads Warmup position 3/3 Position 258/258 =========================== Version : Stockfish dev-20240928-nogit Compiled by : g++ (GNUC) 13.2.0 on MinGW64 Compilation architecture : x86-64-vnni256 Compilation settings : 64bit VNNI BMI2 AVX2 SSE41 SSSE3 SSE2 POPCNT Compiler __VERSION__ macro : 13.2.0 Large pages : yes User invocation : speedtest Filled invocation : speedtest 16 2048 150 Available processors : 0-15 Thread count : 16 Thread binding : none TT size [MiB] : 2048 Hash max, avg [per mille] : single search : 40, 21 single game : 631, 428 Total nodes searched : 2099917842 Total search time [s] : 153.937 Nodes/second : 13641410 ``` ------------------------------- Small unrelated tweaks: - Network verification output is now handled as a callback. - TT hashfull queries allow specifying maximum entry age. closes https://github.com/official-stockfish/Stockfish/pull/5354 No functional change
This commit is contained in:
parent
aff1f67997
commit
3ac75cd27d
15 changed files with 663 additions and 52 deletions
|
@ -17,6 +17,7 @@
|
|||
*/
|
||||
|
||||
#include "benchmark.h"
|
||||
#include "numa.h"
|
||||
|
||||
#include <cstdlib>
|
||||
#include <fstream>
|
||||
|
@ -91,6 +92,282 @@ const std::vector<std::string> Defaults = {
|
|||
};
|
||||
// clang-format on
|
||||
|
||||
// clang-format off
|
||||
// human-randomly picked 5 games with <60 moves from
|
||||
// https://tests.stockfishchess.org/tests/view/665c71f9fd45fb0f907c21e0
|
||||
// only moves for one side
|
||||
const std::vector<std::vector<std::string>> BenchmarkPositions = {
|
||||
{
|
||||
"rnbq1k1r/ppp1bppp/4pn2/8/2B5/2NP1N2/PPP2PPP/R1BQR1K1 b - - 2 8",
|
||||
"rnbq1k1r/pp2bppp/4pn2/2p5/2B2B2/2NP1N2/PPP2PPP/R2QR1K1 b - - 1 9",
|
||||
"r1bq1k1r/pp2bppp/2n1pn2/2p5/2B1NB2/3P1N2/PPP2PPP/R2QR1K1 b - - 3 10",
|
||||
"r1bq1k1r/pp2bppp/2n1p3/2p5/2B1PB2/5N2/PPP2PPP/R2QR1K1 b - - 0 11",
|
||||
"r1b2k1r/pp2bppp/2n1p3/2p5/2B1PB2/5N2/PPP2PPP/3RR1K1 b - - 0 12",
|
||||
"r1b1k2r/pp2bppp/2n1p3/2p5/2B1PB2/2P2N2/PP3PPP/3RR1K1 b - - 0 13",
|
||||
"r1b1k2r/1p2bppp/p1n1p3/2p5/4PB2/2P2N2/PP2BPPP/3RR1K1 b - - 1 14",
|
||||
"r1b1k2r/4bppp/p1n1p3/1pp5/P3PB2/2P2N2/1P2BPPP/3RR1K1 b - - 0 15",
|
||||
"r1b1k2r/4bppp/p1n1p3/1P6/2p1PB2/2P2N2/1P2BPPP/3RR1K1 b - - 0 16",
|
||||
"r1b1k2r/4bppp/2n1p3/1p6/2p1PB2/1PP2N2/4BPPP/3RR1K1 b - - 0 17",
|
||||
"r3k2r/3bbppp/2n1p3/1p6/2P1PB2/2P2N2/4BPPP/3RR1K1 b - - 0 18",
|
||||
"r3k2r/3bbppp/2n1p3/8/1pP1P3/2P2N2/3BBPPP/3RR1K1 b - - 1 19",
|
||||
"1r2k2r/3bbppp/2n1p3/8/1pPNP3/2P5/3BBPPP/3RR1K1 b - - 3 20",
|
||||
"1r2k2r/3bbppp/2n1p3/8/2PNP3/2B5/4BPPP/3RR1K1 b - - 0 21",
|
||||
"1r2k2r/3bb1pp/2n1pp2/1N6/2P1P3/2B5/4BPPP/3RR1K1 b - - 1 22",
|
||||
"1r2k2r/3b2pp/2n1pp2/1N6/1BP1P3/8/4BPPP/3RR1K1 b - - 0 23",
|
||||
"1r2k2r/3b2pp/4pp2/1N6/1nP1P3/8/3RBPPP/4R1K1 b - - 1 24",
|
||||
"1r5r/3bk1pp/4pp2/1N6/1nP1PP2/8/3RB1PP/4R1K1 b - - 0 25",
|
||||
"1r5r/3bk1pp/2n1pp2/1N6/2P1PP2/8/3RBKPP/4R3 b - - 2 26",
|
||||
"1r5r/3bk1pp/2n2p2/1N2p3/2P1PP2/6P1/3RBK1P/4R3 b - - 0 27",
|
||||
"1r1r4/3bk1pp/2n2p2/1N2p3/2P1PP2/6P1/3RBK1P/R7 b - - 2 28",
|
||||
"1r1r4/N3k1pp/2n1bp2/4p3/2P1PP2/6P1/3RBK1P/R7 b - - 4 29",
|
||||
"1r1r4/3bk1pp/2N2p2/4p3/2P1PP2/6P1/3RBK1P/R7 b - - 0 30",
|
||||
"1r1R4/4k1pp/2b2p2/4p3/2P1PP2/6P1/4BK1P/R7 b - - 0 31",
|
||||
"3r4/4k1pp/2b2p2/4P3/2P1P3/6P1/4BK1P/R7 b - - 0 32",
|
||||
"3r4/R3k1pp/2b5/4p3/2P1P3/6P1/4BK1P/8 b - - 1 33",
|
||||
"8/3rk1pp/2b5/R3p3/2P1P3/6P1/4BK1P/8 b - - 3 34",
|
||||
"8/3r2pp/2bk4/R1P1p3/4P3/6P1/4BK1P/8 b - - 0 35",
|
||||
"8/2kr2pp/2b5/R1P1p3/4P3/4K1P1/4B2P/8 b - - 2 36",
|
||||
"1k6/3r2pp/2b5/RBP1p3/4P3/4K1P1/7P/8 b - - 4 37",
|
||||
"8/1k1r2pp/2b5/R1P1p3/4P3/3BK1P1/7P/8 b - - 6 38",
|
||||
"1k6/3r2pp/2b5/2P1p3/4P3/3BK1P1/7P/R7 b - - 8 39",
|
||||
"1k6/r5pp/2b5/2P1p3/4P3/3BK1P1/7P/5R2 b - - 10 40",
|
||||
"1k3R2/6pp/2b5/2P1p3/4P3/r2BK1P1/7P/8 b - - 12 41",
|
||||
"5R2/2k3pp/2b5/2P1p3/4P3/r2B2P1/3K3P/8 b - - 14 42",
|
||||
"5R2/2k3pp/2b5/2P1p3/4P3/3BK1P1/r6P/8 b - - 16 43",
|
||||
"5R2/2k3pp/2b5/2P1p3/4P3/r2B2P1/4K2P/8 b - - 18 44",
|
||||
"5R2/2k3pp/2b5/2P1p3/4P3/3B1KP1/r6P/8 b - - 20 45",
|
||||
"8/2k2Rpp/2b5/2P1p3/4P3/r2B1KP1/7P/8 b - - 22 46",
|
||||
"3k4/5Rpp/2b5/2P1p3/4P3/r2B2P1/4K2P/8 b - - 24 47",
|
||||
"3k4/5Rpp/2b5/2P1p3/4P3/3B1KP1/r6P/8 b - - 26 48",
|
||||
"3k4/5Rpp/2b5/2P1p3/4P3/r2B2P1/4K2P/8 b - - 28 49",
|
||||
"3k4/5Rpp/2b5/2P1p3/4P3/3BK1P1/r6P/8 b - - 30 50",
|
||||
"3k4/5Rpp/2b5/2P1p3/4P3/r2B2P1/3K3P/8 b - - 32 51",
|
||||
"3k4/5Rpp/2b5/2P1p3/4P3/2KB2P1/r6P/8 b - - 34 52",
|
||||
"3k4/5Rpp/2b5/2P1p3/4P3/r2B2P1/2K4P/8 b - - 36 53",
|
||||
"3k4/5Rpp/2b5/2P1p3/4P3/1K1B2P1/r6P/8 b - - 38 54",
|
||||
"3k4/6Rp/2b5/2P1p3/4P3/1K1B2P1/7r/8 b - - 0 55",
|
||||
"3k4/8/2b3Rp/2P1p3/4P3/1K1B2P1/7r/8 b - - 1 56",
|
||||
"8/2k3R1/2b4p/2P1p3/4P3/1K1B2P1/7r/8 b - - 3 57",
|
||||
"3k4/8/2b3Rp/2P1p3/4P3/1K1B2P1/7r/8 b - - 5 58",
|
||||
"8/2k5/2b3Rp/2P1p3/1K2P3/3B2P1/7r/8 b - - 7 59",
|
||||
"8/2k5/2b3Rp/2P1p3/4P3/2KB2P1/3r4/8 b - - 9 60",
|
||||
"8/2k5/2b3Rp/2P1p3/1K2P3/3B2P1/6r1/8 b - - 11 61",
|
||||
"8/2k5/2b3Rp/2P1p3/4P3/2KB2P1/3r4/8 b - - 13 62",
|
||||
"8/2k5/2b3Rp/2P1p3/2K1P3/3B2P1/6r1/8 b - - 15 63",
|
||||
"4b3/2k3R1/7p/2P1p3/2K1P3/3B2P1/6r1/8 b - - 17 64",
|
||||
},
|
||||
{
|
||||
"r1bqkbnr/npp1pppp/p7/3P4/4pB2/2N5/PPP2PPP/R2QKBNR w KQkq - 1 6",
|
||||
"r1bqkb1r/npp1pppp/p4n2/3P4/4pB2/2N5/PPP1QPPP/R3KBNR w KQkq - 3 7",
|
||||
"r2qkb1r/npp1pppp/p4n2/3P1b2/4pB2/2N5/PPP1QPPP/2KR1BNR w kq - 5 8",
|
||||
"r2qkb1r/1pp1pppp/p4n2/1n1P1b2/4pB2/2N4P/PPP1QPP1/2KR1BNR w kq - 1 9",
|
||||
"r2qkb1r/1pp1pppp/5n2/1p1P1b2/4pB2/7P/PPP1QPP1/2KR1BNR w kq - 0 10",
|
||||
"r2qkb1r/1ppbpppp/5n2/1Q1P4/4pB2/7P/PPP2PP1/2KR1BNR w kq - 1 11",
|
||||
"3qkb1r/1Qpbpppp/5n2/3P4/4pB2/7P/rPP2PP1/2KR1BNR w k - 0 12",
|
||||
"q3kb1r/1Qpbpppp/5n2/3P4/4pB2/7P/rPP2PP1/1K1R1BNR w k - 2 13",
|
||||
"r3kb1r/2pbpppp/5n2/3P4/4pB2/7P/1PP2PP1/1K1R1BNR w k - 0 14",
|
||||
"r3kb1r/2Bb1ppp/4pn2/3P4/4p3/7P/1PP2PP1/1K1R1BNR w k - 0 15",
|
||||
"r3kb1r/2Bb2pp/4pn2/8/4p3/7P/1PP2PP1/1K1R1BNR w k - 0 16",
|
||||
"r3k2r/2Bb2pp/4pn2/2b5/4p3/7P/1PP1NPP1/1K1R1B1R w k - 2 17",
|
||||
"r6r/2Bbk1pp/4pn2/2b5/3Np3/7P/1PP2PP1/1K1R1B1R w - - 4 18",
|
||||
"r6r/b2bk1pp/4pn2/4B3/3Np3/7P/1PP2PP1/1K1R1B1R w - - 6 19",
|
||||
"r1r5/b2bk1pp/4pn2/4B3/2BNp3/7P/1PP2PP1/1K1R3R w - - 8 20",
|
||||
"r7/b2bk1pp/4pn2/2r1B3/2BNp3/1P5P/2P2PP1/1K1R3R w - - 1 21",
|
||||
"rb6/3bk1pp/4pn2/2r1B3/2BNpP2/1P5P/2P3P1/1K1R3R w - - 1 22",
|
||||
"1r6/3bk1pp/4pn2/2r5/2BNpP2/1P5P/2P3P1/1K1R3R w - - 0 23",
|
||||
"1r6/3bk1p1/4pn1p/2r5/2BNpP2/1P5P/2P3P1/2KR3R w - - 0 24",
|
||||
"8/3bk1p1/1r2pn1p/2r5/2BNpP1P/1P6/2P3P1/2KR3R w - - 1 25",
|
||||
"8/3bk3/1r2pnpp/2r5/2BNpP1P/1P6/2P3P1/2K1R2R w - - 0 26",
|
||||
"2b5/4k3/1r2pnpp/2r5/2BNpP1P/1P4P1/2P5/2K1R2R w - - 1 27",
|
||||
"8/1b2k3/1r2pnpp/2r5/2BNpP1P/1P4P1/2P5/2K1R1R1 w - - 3 28",
|
||||
"8/1b1nk3/1r2p1pp/2r5/2BNpPPP/1P6/2P5/2K1R1R1 w - - 1 29",
|
||||
"8/1b2k3/1r2p1pp/2r1nP2/2BNp1PP/1P6/2P5/2K1R1R1 w - - 1 30",
|
||||
"8/1b2k3/1r2p1p1/2r1nPp1/2BNp2P/1P6/2P5/2K1R1R1 w - - 0 31",
|
||||
"8/1b2k3/1r2p1n1/2r3p1/2BNp2P/1P6/2P5/2K1R1R1 w - - 0 32",
|
||||
"8/1b2k3/1r2p1n1/6r1/2BNp2P/1P6/2P5/2K1R3 w - - 0 33",
|
||||
"8/1b2k3/1r2p3/4n1P1/2BNp3/1P6/2P5/2K1R3 w - - 1 34",
|
||||
"8/1b2k3/1r2p3/4n1P1/2BN4/1P2p3/2P5/2K4R w - - 0 35",
|
||||
"8/1b2k3/1r2p2R/6P1/2nN4/1P2p3/2P5/2K5 w - - 0 36",
|
||||
"8/1b2k3/3rp2R/6P1/2PN4/4p3/2P5/2K5 w - - 1 37",
|
||||
"8/4k3/3rp2R/6P1/2PN4/2P1p3/6b1/2K5 w - - 1 38",
|
||||
"8/4k3/r3p2R/2P3P1/3N4/2P1p3/6b1/2K5 w - - 1 39",
|
||||
"8/3k4/r3p2R/2P2NP1/8/2P1p3/6b1/2K5 w - - 3 40",
|
||||
"8/3k4/4p2R/2P3P1/8/2P1N3/6b1/r1K5 w - - 1 41",
|
||||
"8/3k4/4p2R/2P3P1/8/2P1N3/3K2b1/6r1 w - - 3 42",
|
||||
"8/3k4/4p2R/2P3P1/8/2PKNb2/8/6r1 w - - 5 43",
|
||||
"8/4k3/4p1R1/2P3P1/8/2PKNb2/8/6r1 w - - 7 44",
|
||||
"8/4k3/4p1R1/2P3P1/3K4/2P1N3/8/6rb w - - 9 45",
|
||||
"8/3k4/4p1R1/2P1K1P1/8/2P1N3/8/6rb w - - 11 46",
|
||||
"8/3k4/4p1R1/2P3P1/5K2/2P1N3/8/4r2b w - - 13 47",
|
||||
"8/3k4/2b1p2R/2P3P1/5K2/2P1N3/8/4r3 w - - 15 48",
|
||||
"8/3k4/2b1p3/2P3P1/5K2/2P1N2R/8/6r1 w - - 17 49",
|
||||
"2k5/7R/2b1p3/2P3P1/5K2/2P1N3/8/6r1 w - - 19 50",
|
||||
"2k5/7R/4p3/2P3P1/b1P2K2/4N3/8/6r1 w - - 1 51",
|
||||
"2k5/3bR3/4p3/2P3P1/2P2K2/4N3/8/6r1 w - - 3 52",
|
||||
"3k4/3b2R1/4p3/2P3P1/2P2K2/4N3/8/6r1 w - - 5 53",
|
||||
"3kb3/6R1/4p1P1/2P5/2P2K2/4N3/8/6r1 w - - 1 54",
|
||||
"3kb3/6R1/4p1P1/2P5/2P2KN1/8/8/2r5 w - - 3 55",
|
||||
"3kb3/6R1/4p1P1/2P1N3/2P2K2/8/8/5r2 w - - 5 56",
|
||||
"3kb3/6R1/4p1P1/2P1N3/2P5/4K3/8/4r3 w - - 7 57",
|
||||
},
|
||||
{
|
||||
"rnbq1rk1/ppp1npb1/4p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P1/3p2R1/8/3RK3 b - - 3 39",
|
||||
"5rk1/6b1/6p1/p1p1P1B1/2Pr1PP1/3R4/8/3RK3 b - - 0 40",
|
||||
"5rk1/3R2b1/6p1/p1p1P1B1/2r2PP1/8/8/3RK3 b - - 1 41",
|
||||
"5rk1/3R2b1/6p1/p1p1P1B1/4rPP1/8/3K4/3R4 b - - 3 42",
|
||||
"1r4k1/3R2b1/6p1/p1p1P1B1/4rPP1/2K5/8/3R4 b - - 5 43",
|
||||
"1r4k1/3R2b1/6p1/p1p1P1B1/2K2PP1/4r3/8/3R4 b - - 7 44",
|
||||
"1r3bk1/8/3R2p1/p1p1P1B1/2K2PP1/4r3/8/3R4 b - - 9 45",
|
||||
"1r3bk1/8/6R1/2p1P1B1/p1K2PP1/4r3/8/3R4 b - - 0 46",
|
||||
"1r3b2/5k2/R7/2p1P1B1/p1K2PP1/4r3/8/3R4 b - - 2 47",
|
||||
"5b2/1r3k2/R7/2p1P1B1/p1K2PP1/4r3/8/7R b - - 4 48",
|
||||
"5b2/5k2/R7/2pKP1B1/pr3PP1/4r3/8/7R b - - 6 49",
|
||||
"5b2/5k2/R1K5/2p1P1B1/p2r1PP1/4r3/8/7R b - - 8 50",
|
||||
"8/R4kb1/2K5/2p1P1B1/p2r1PP1/4r3/8/7R b - - 10 51",
|
||||
"8/R5b1/2K3k1/2p1PPB1/p2r2P1/4r3/8/7R b - - 0 52",
|
||||
"8/6R1/2K5/2p1PPk1/p2r2P1/4r3/8/7R b - - 0 53",
|
||||
"8/6R1/2K5/2p1PP2/p2r1kP1/4r3/8/5R2 b - - 2 54",
|
||||
"8/6R1/2K2P2/2p1P3/p2r2P1/4r1k1/8/5R2 b - - 0 55",
|
||||
"8/5PR1/2K5/2p1P3/p2r2P1/4r3/6k1/5R2 b - - 0 56",
|
||||
},
|
||||
{
|
||||
"rn1qkb1r/p1pbpppp/5n2/8/2pP4/2N5/1PQ1PPPP/R1B1KBNR w KQkq - 0 7",
|
||||
"r2qkb1r/p1p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NN1/R4QPP/2R4K b - - 2 25",
|
||||
"2rr2k1/1p3ppp/p2P1p2/2Q5/5P2/P1bb1NN1/R5PP/2R4K b - - 0 26",
|
||||
"3r2k1/1p3ppp/p2P1p2/2r5/5P2/P1bb1N2/R3N1PP/2R4K b - - 1 27",
|
||||
"3r2k1/1p3ppp/p2P1p2/2r5/5P2/P1b2N2/4R1PP/2R4K b - - 0 28",
|
||||
"3r2k1/1p3ppp/p2P1p2/2r5/1b3P2/P4N2/4R1PP/3R3K b - - 2 29",
|
||||
"3r2k1/1p2Rppp/p2P1p2/b1r5/5P2/P4N2/6PP/3R3K b - - 4 30",
|
||||
"3r2k1/1R3ppp/p1rP1p2/b7/5P2/P4N2/6PP/3R3K b - - 0 31",
|
||||
"3r2k1/1R3ppp/p2R1p2/b7/5P2/P4N2/6PP/7K b - - 0 32",
|
||||
"6k1/1R3ppp/p2r1p2/b7/5P2/P4NP1/7P/7K b - - 0 33",
|
||||
"6k1/1R3p1p/p2r1pp1/b7/5P1P/P4NP1/8/7K b - - 0 34",
|
||||
"6k1/3R1p1p/pr3pp1/b7/5P1P/P4NP1/8/7K b - - 2 35",
|
||||
"6k1/5p2/pr3pp1/b2R3p/5P1P/P4NP1/8/7K b - - 1 36",
|
||||
"6k1/5p2/pr3pp1/7p/5P1P/P1bR1NP1/8/7K b - - 3 37",
|
||||
"6k1/5p2/p1r2pp1/7p/5P1P/P1bR1NP1/6K1/8 b - - 5 38",
|
||||
"6k1/5p2/p1r2pp1/b2R3p/5P1P/P4NP1/6K1/8 b - - 7 39",
|
||||
"6k1/5p2/p4pp1/b2R3p/5P1P/P4NPK/2r5/8 b - - 9 40",
|
||||
"6k1/2b2p2/p4pp1/7p/5P1P/P2R1NPK/2r5/8 b - - 11 41",
|
||||
"6k1/2b2p2/5pp1/p6p/3N1P1P/P2R2PK/2r5/8 b - - 1 42",
|
||||
"6k1/2b2p2/5pp1/p6p/3N1P1P/P1R3PK/r7/8 b - - 3 43",
|
||||
"6k1/5p2/1b3pp1/p6p/5P1P/P1R3PK/r1N5/8 b - - 5 44",
|
||||
"8/5pk1/1bR2pp1/p6p/5P1P/P5PK/r1N5/8 b - - 7 45",
|
||||
"3b4/5pk1/2R2pp1/p4P1p/7P/P5PK/r1N5/8 b - - 0 46",
|
||||
"8/4bpk1/2R2pp1/p4P1p/6PP/P6K/r1N5/8 b - - 0 47",
|
||||
"8/5pk1/2R2pP1/p6p/6PP/b6K/r1N5/8 b - - 0 48",
|
||||
"8/6k1/2R2pp1/p6P/7P/b6K/r1N5/8 b - - 0 49",
|
||||
"8/6k1/2R2p2/p6p/7P/b5K1/r1N5/8 b - - 1 50",
|
||||
"8/8/2R2pk1/p6p/7P/b4K2/r1N5/8 b - - 3 51",
|
||||
"8/8/2R2pk1/p6p/7P/4NK2/rb6/8 b - - 5 52",
|
||||
"2R5/8/5pk1/7p/p6P/4NK2/rb6/8 b - - 1 53",
|
||||
"6R1/8/5pk1/7p/p6P/4NK2/1b6/r7 b - - 3 54",
|
||||
"R7/5k2/5p2/7p/p6P/4NK2/1b6/r7 b - - 5 55",
|
||||
"R7/5k2/5p2/7p/7P/p3N3/1b2K3/r7 b - - 1 56",
|
||||
"8/R4k2/5p2/7p/7P/p3N3/1b2K3/7r b - - 3 57",
|
||||
"8/8/5pk1/7p/R6P/p3N3/1b2K3/7r b - - 5 58",
|
||||
"8/8/5pk1/7p/R6P/p7/4K3/2bN3r b - - 7 59",
|
||||
"8/8/5pk1/7p/R6P/p7/4KN1r/2b5 b - - 9 60",
|
||||
"8/8/5pk1/7p/R6P/p3K3/1b3N1r/8 b - - 11 61",
|
||||
"8/8/R4pk1/7p/7P/p1b1K3/5N1r/8 b - - 13 62",
|
||||
"8/8/5pk1/7p/7P/2b1K3/R4N1r/8 b - - 0 63",
|
||||
"8/8/5pk1/7p/3K3P/8/R4N1r/4b3 b - - 2 64",
|
||||
}
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace Stockfish::Benchmark {
|
||||
|
@ -160,4 +437,76 @@ std::vector<std::string> setup_bench(const std::string& currentFen, std::istream
|
|||
return list;
|
||||
}
|
||||
|
||||
BenchmarkSetup setup_benchmark(std::istream& is) {
|
||||
// TT_SIZE_PER_THREAD is chosen such that roughly half of the hash is used all positions
|
||||
// for the current sequence have been searched.
|
||||
static constexpr int TT_SIZE_PER_THREAD = 128;
|
||||
|
||||
static constexpr int DEFAULT_DURATION_S = 150;
|
||||
|
||||
BenchmarkSetup setup{};
|
||||
|
||||
// Assign default values to missing arguments
|
||||
int desiredTimeS;
|
||||
|
||||
if (!(is >> setup.threads))
|
||||
setup.threads = get_hardware_concurrency();
|
||||
else
|
||||
setup.originalInvocation += std::to_string(setup.threads);
|
||||
|
||||
if (!(is >> setup.ttSize))
|
||||
setup.ttSize = TT_SIZE_PER_THREAD * setup.threads;
|
||||
else
|
||||
setup.originalInvocation += " " + std::to_string(setup.ttSize);
|
||||
|
||||
if (!(is >> desiredTimeS))
|
||||
desiredTimeS = DEFAULT_DURATION_S;
|
||||
else
|
||||
setup.originalInvocation += " " + std::to_string(desiredTimeS);
|
||||
|
||||
setup.filledInvocation += std::to_string(setup.threads) + " " + std::to_string(setup.ttSize)
|
||||
+ " " + std::to_string(desiredTimeS);
|
||||
|
||||
auto getCorrectedTime = [&](int ply) {
|
||||
// time per move is fit roughly based on LTC games
|
||||
// seconds = 50/{ply+15}
|
||||
// ms = 50000/{ply+15}
|
||||
// with this fit 10th move gets 2000ms
|
||||
// adjust for desired 10th move time
|
||||
return 50000.0 / (static_cast<double>(ply) + 15.0);
|
||||
};
|
||||
|
||||
float totalTime = 0;
|
||||
for (const auto& game : BenchmarkPositions)
|
||||
{
|
||||
setup.commands.emplace_back("ucinewgame");
|
||||
int ply = 1;
|
||||
for (int i = 0; i < static_cast<int>(game.size()); ++i)
|
||||
{
|
||||
const float correctedTime = getCorrectedTime(ply);
|
||||
totalTime += correctedTime;
|
||||
ply += 1;
|
||||
}
|
||||
}
|
||||
|
||||
float timeScaleFactor = static_cast<float>(desiredTimeS * 1000) / totalTime;
|
||||
|
||||
for (const auto& game : BenchmarkPositions)
|
||||
{
|
||||
setup.commands.emplace_back("ucinewgame");
|
||||
int ply = 1;
|
||||
for (const std::string& fen : game)
|
||||
{
|
||||
setup.commands.emplace_back("position fen " + fen);
|
||||
|
||||
const int correctedTime = static_cast<int>(getCorrectedTime(ply) * timeScaleFactor);
|
||||
setup.commands.emplace_back("go movetime " + std::to_string(correctedTime));
|
||||
|
||||
ply += 1;
|
||||
}
|
||||
}
|
||||
|
||||
return setup;
|
||||
}
|
||||
|
||||
} // namespace Stockfish
|
|
@ -27,6 +27,16 @@ namespace Stockfish::Benchmark {
|
|||
|
||||
std::vector<std::string> setup_bench(const std::string&, std::istream&);
|
||||
|
||||
struct BenchmarkSetup {
|
||||
int ttSize;
|
||||
int threads;
|
||||
std::vector<std::string> commands;
|
||||
std::string originalInvocation;
|
||||
std::string filledInvocation;
|
||||
};
|
||||
|
||||
BenchmarkSetup setup_benchmark(std::istream&);
|
||||
|
||||
} // namespace Stockfish
|
||||
|
||||
#endif // #ifndef BENCHMARK_H_INCLUDED
|
||||
|
|
|
@ -67,12 +67,13 @@ Engine::Engine(std::optional<std::string> path) :
|
|||
|
||||
options["NumaPolicy"] << Option("auto", [this](const Option& o) {
|
||||
set_numa_config_from_option(o);
|
||||
return numa_config_information_as_string() + "\n" + thread_binding_information_as_string();
|
||||
return numa_config_information_as_string() + "\n"
|
||||
+ thread_allocation_information_as_string();
|
||||
});
|
||||
|
||||
options["Threads"] << Option(1, 1, 1024, [this](const Option&) {
|
||||
resize_threads();
|
||||
return thread_binding_information_as_string();
|
||||
return thread_allocation_information_as_string();
|
||||
});
|
||||
|
||||
options["Hash"] << Option(16, 1, MaxHashMB, [this](const Option& o) {
|
||||
|
@ -156,6 +157,10 @@ void Engine::set_on_bestmove(std::function<void(std::string_view, std::string_vi
|
|||
updateContext.onBestmove = std::move(f);
|
||||
}
|
||||
|
||||
void Engine::set_on_verify_networks(std::function<void(std::string_view)>&& f) {
|
||||
onVerifyNetworks = std::move(f);
|
||||
}
|
||||
|
||||
void Engine::wait_for_search_finished() { threads.main_thread()->wait_for_search_finished(); }
|
||||
|
||||
void Engine::set_position(const std::string& fen, const std::vector<std::string>& moves) {
|
||||
|
@ -226,8 +231,8 @@ void Engine::set_ponderhit(bool b) { threads.main_manager()->ponder = b; }
|
|||
// network related
|
||||
|
||||
void Engine::verify_networks() const {
|
||||
networks->big.verify(options["EvalFile"]);
|
||||
networks->small.verify(options["EvalFileSmall"]);
|
||||
networks->big.verify(options["EvalFile"], onVerifyNetworks);
|
||||
networks->small.verify(options["EvalFileSmall"], onVerifyNetworks);
|
||||
}
|
||||
|
||||
void Engine::load_networks() {
|
||||
|
@ -285,6 +290,8 @@ std::string Engine::visualize() const {
|
|||
return ss.str();
|
||||
}
|
||||
|
||||
int Engine::get_hashfull(int maxAge) const { return tt.hashfull(maxAge); }
|
||||
|
||||
std::vector<std::pair<size_t, size_t>> Engine::get_bound_thread_count_by_numa_node() const {
|
||||
auto counts = threads.get_bound_thread_count_by_numa_node();
|
||||
const NumaConfig& cfg = numaContext.get_numa_config();
|
||||
|
@ -310,15 +317,9 @@ std::string Engine::numa_config_information_as_string() const {
|
|||
std::string Engine::thread_binding_information_as_string() const {
|
||||
auto boundThreadsByNode = get_bound_thread_count_by_numa_node();
|
||||
std::stringstream ss;
|
||||
|
||||
size_t threadsSize = threads.size();
|
||||
ss << "Using " << threadsSize << (threadsSize > 1 ? " threads" : " thread");
|
||||
|
||||
if (boundThreadsByNode.empty())
|
||||
return ss.str();
|
||||
|
||||
ss << " with NUMA node thread binding: ";
|
||||
|
||||
bool isFirst = true;
|
||||
|
||||
for (auto&& [current, total] : boundThreadsByNode)
|
||||
|
@ -332,4 +333,20 @@ std::string Engine::thread_binding_information_as_string() const {
|
|||
return ss.str();
|
||||
}
|
||||
|
||||
std::string Engine::thread_allocation_information_as_string() const {
|
||||
std::stringstream ss;
|
||||
|
||||
size_t threadsSize = threads.size();
|
||||
ss << "Using " << threadsSize << (threadsSize > 1 ? " threads" : " thread");
|
||||
|
||||
auto boundThreadsByNodeStr = thread_binding_information_as_string();
|
||||
if (boundThreadsByNodeStr.empty())
|
||||
return ss.str();
|
||||
|
||||
ss << " with NUMA node thread binding: ";
|
||||
ss << boundThreadsByNodeStr;
|
||||
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -81,6 +81,7 @@ class Engine {
|
|||
void set_on_update_full(std::function<void(const InfoFull&)>&&);
|
||||
void set_on_iter(std::function<void(const InfoIter&)>&&);
|
||||
void set_on_bestmove(std::function<void(std::string_view, std::string_view)>&&);
|
||||
void set_on_verify_networks(std::function<void(std::string_view)>&&);
|
||||
|
||||
// network related
|
||||
|
||||
|
@ -97,12 +98,15 @@ class Engine {
|
|||
const OptionsMap& get_options() const;
|
||||
OptionsMap& get_options();
|
||||
|
||||
int get_hashfull(int maxAge = 0) const;
|
||||
|
||||
std::string fen() const;
|
||||
void flip();
|
||||
std::string visualize() const;
|
||||
std::vector<std::pair<size_t, size_t>> get_bound_thread_count_by_numa_node() const;
|
||||
std::string get_numa_config_as_string() const;
|
||||
std::string numa_config_information_as_string() const;
|
||||
std::string thread_allocation_information_as_string() const;
|
||||
std::string thread_binding_information_as_string() const;
|
||||
|
||||
private:
|
||||
|
@ -119,7 +123,8 @@ class Engine {
|
|||
TranspositionTable tt;
|
||||
LazyNumaReplicated<Eval::NNUE::Networks> networks;
|
||||
|
||||
Search::SearchManager::UpdateContext updateContext;
|
||||
Search::SearchManager::UpdateContext updateContext;
|
||||
std::function<void(std::string_view)> onVerifyNetworks;
|
||||
};
|
||||
|
||||
} // namespace Stockfish
|
||||
|
|
|
@ -212,6 +212,37 @@ void* aligned_large_pages_alloc(size_t allocSize) {
|
|||
|
||||
#endif
|
||||
|
||||
bool has_large_pages() {
|
||||
|
||||
#if defined(_WIN32)
|
||||
|
||||
constexpr size_t page_size = 2 * 1024 * 1024; // 2MB page size assumed
|
||||
void* mem = aligned_large_pages_alloc_windows(page_size);
|
||||
if (mem == nullptr)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
aligned_large_pages_free(mem);
|
||||
return true;
|
||||
}
|
||||
|
||||
#elif defined(__linux__)
|
||||
|
||||
#if defined(MADV_HUGEPAGE)
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
return false;
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
// aligned_large_pages_free() will free the previously memory allocated
|
||||
// by aligned_large_pages_alloc(). The effect is a nop if mem == nullptr.
|
||||
|
|
|
@ -38,6 +38,8 @@ void std_aligned_free(void* ptr);
|
|||
void* aligned_large_pages_alloc(size_t size);
|
||||
void aligned_large_pages_free(void* mem);
|
||||
|
||||
bool has_large_pages();
|
||||
|
||||
// Frees memory which was placed there with placement new.
|
||||
// Works for both single objects and arrays of unknown bound.
|
||||
template<typename T, typename FREE_FUNC>
|
||||
|
|
11
src/misc.cpp
11
src/misc.cpp
|
@ -122,7 +122,7 @@ class Logger {
|
|||
//
|
||||
// For releases (non-dev builds) we only include the version number:
|
||||
// Stockfish version
|
||||
std::string engine_info(bool to_uci) {
|
||||
std::string engine_version_info() {
|
||||
std::stringstream ss;
|
||||
ss << "Stockfish " << version << std::setfill('0');
|
||||
|
||||
|
@ -151,11 +151,14 @@ std::string engine_info(bool to_uci) {
|
|||
#endif
|
||||
}
|
||||
|
||||
ss << (to_uci ? "\nid author " : " by ") << "the Stockfish developers (see AUTHORS file)";
|
||||
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
std::string engine_info(bool to_uci) {
|
||||
return engine_version_info() + (to_uci ? "\nid author " : " by ")
|
||||
+ "the Stockfish developers (see AUTHORS file)";
|
||||
}
|
||||
|
||||
|
||||
// Returns a string trying to describe the compiler we use
|
||||
std::string compiler_info() {
|
||||
|
@ -451,7 +454,7 @@ void remove_whitespace(std::string& s) {
|
|||
s.erase(std::remove_if(s.begin(), s.end(), [](char c) { return std::isspace(c); }), s.end());
|
||||
}
|
||||
|
||||
bool is_whitespace(const std::string& s) {
|
||||
bool is_whitespace(std::string_view s) {
|
||||
return std::all_of(s.begin(), s.end(), [](char c) { return std::isspace(c); });
|
||||
}
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include <iosfwd>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
#define stringify2(x) #x
|
||||
|
@ -35,6 +36,7 @@
|
|||
|
||||
namespace Stockfish {
|
||||
|
||||
std::string engine_version_info();
|
||||
std::string engine_info(bool to_uci = false);
|
||||
std::string compiler_info();
|
||||
|
||||
|
@ -79,8 +81,8 @@ inline TimePoint now() {
|
|||
.count();
|
||||
}
|
||||
|
||||
inline std::vector<std::string> split(const std::string& s, const std::string& delimiter) {
|
||||
std::vector<std::string> res;
|
||||
inline std::vector<std::string_view> split(std::string_view s, std::string_view delimiter) {
|
||||
std::vector<std::string_view> res;
|
||||
|
||||
if (s.empty())
|
||||
return res;
|
||||
|
@ -102,7 +104,7 @@ inline std::vector<std::string> split(const std::string& s, const std::string& d
|
|||
}
|
||||
|
||||
void remove_whitespace(std::string& s);
|
||||
bool is_whitespace(const std::string& s);
|
||||
bool is_whitespace(std::string_view s);
|
||||
|
||||
enum SyncCout {
|
||||
IO_LOCK,
|
||||
|
|
|
@ -234,35 +234,44 @@ Network<Arch, Transformer>::evaluate(const Position& pos
|
|||
|
||||
|
||||
template<typename Arch, typename Transformer>
|
||||
void Network<Arch, Transformer>::verify(std::string evalfilePath) const {
|
||||
void Network<Arch, Transformer>::verify(std::string evalfilePath,
|
||||
const std::function<void(std::string_view)>& f) const {
|
||||
if (evalfilePath.empty())
|
||||
evalfilePath = evalFile.defaultName;
|
||||
|
||||
if (evalFile.current != evalfilePath)
|
||||
{
|
||||
std::string msg1 =
|
||||
"Network evaluation parameters compatible with the engine must be available.";
|
||||
std::string msg2 = "The network file " + evalfilePath + " was not loaded successfully.";
|
||||
std::string msg3 = "The UCI option EvalFile might need to specify the full path, "
|
||||
"including the directory name, to the network file.";
|
||||
std::string msg4 = "The default net can be downloaded from: "
|
||||
"https://tests.stockfishchess.org/api/nn/"
|
||||
+ evalFile.defaultName;
|
||||
std::string msg5 = "The engine will be terminated now.";
|
||||
if (f)
|
||||
{
|
||||
std::string msg1 =
|
||||
"Network evaluation parameters compatible with the engine must be available.";
|
||||
std::string msg2 = "The network file " + evalfilePath + " was not loaded successfully.";
|
||||
std::string msg3 = "The UCI option EvalFile might need to specify the full path, "
|
||||
"including the directory name, to the network file.";
|
||||
std::string msg4 = "The default net can be downloaded from: "
|
||||
"https://tests.stockfishchess.org/api/nn/"
|
||||
+ evalFile.defaultName;
|
||||
std::string msg5 = "The engine will be terminated now.";
|
||||
|
||||
std::string msg = "ERROR: " + msg1 + '\n' + "ERROR: " + msg2 + '\n' + "ERROR: " + msg3
|
||||
+ '\n' + "ERROR: " + msg4 + '\n' + "ERROR: " + msg5 + '\n';
|
||||
|
||||
f(msg);
|
||||
}
|
||||
|
||||
sync_cout << "info string ERROR: " << msg1 << sync_endl;
|
||||
sync_cout << "info string ERROR: " << msg2 << sync_endl;
|
||||
sync_cout << "info string ERROR: " << msg3 << sync_endl;
|
||||
sync_cout << "info string ERROR: " << msg4 << sync_endl;
|
||||
sync_cout << "info string ERROR: " << msg5 << sync_endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
size_t size = sizeof(*featureTransformer) + sizeof(Arch) * LayerStacks;
|
||||
sync_cout << "info string NNUE evaluation using " << evalfilePath << " ("
|
||||
<< size / (1024 * 1024) << "MiB, (" << featureTransformer->InputDimensions << ", "
|
||||
<< network[0].TransformedFeatureDimensions << ", " << network[0].FC_0_OUTPUTS << ", "
|
||||
<< network[0].FC_1_OUTPUTS << ", 1))" << sync_endl;
|
||||
if (f)
|
||||
{
|
||||
size_t size = sizeof(*featureTransformer) + sizeof(Arch) * LayerStacks;
|
||||
f("info string NNUE evaluation using " + evalfilePath + " ("
|
||||
+ std::to_string(size / (1024 * 1024)) + "MiB, ("
|
||||
+ std::to_string(featureTransformer->InputDimensions) + ", "
|
||||
+ std::to_string(network[0].TransformedFeatureDimensions) + ", "
|
||||
+ std::to_string(network[0].FC_0_OUTPUTS) + ", " + std::to_string(network[0].FC_1_OUTPUTS)
|
||||
+ ", 1))");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -20,9 +20,11 @@
|
|||
#define NETWORK_H_INCLUDED
|
||||
|
||||
#include <cstdint>
|
||||
#include <functional>
|
||||
#include <iostream>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <tuple>
|
||||
#include <utility>
|
||||
|
||||
|
@ -68,7 +70,7 @@ class Network {
|
|||
void hint_common_access(const Position& pos,
|
||||
AccumulatorCaches::Cache<FTDimensions>* cache) const;
|
||||
|
||||
void verify(std::string evalfilePath) const;
|
||||
void verify(std::string evalfilePath, const std::function<void(std::string_view)>&) const;
|
||||
NnueEvalTrace trace_evaluate(const Position& pos,
|
||||
AccumulatorCaches::Cache<FTDimensions>* cache) const;
|
||||
|
||||
|
|
11
src/numa.h
11
src/numa.h
|
@ -23,6 +23,7 @@
|
|||
#include <atomic>
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
#include <functional>
|
||||
#include <iostream>
|
||||
#include <limits>
|
||||
#include <map>
|
||||
|
@ -653,7 +654,7 @@ class NumaConfig {
|
|||
NumaIndex n = 0;
|
||||
for (auto&& nodeStr : split(s, ":"))
|
||||
{
|
||||
auto indices = indices_from_shortened_string(nodeStr);
|
||||
auto indices = indices_from_shortened_string(std::string(nodeStr));
|
||||
if (!indices.empty())
|
||||
{
|
||||
for (auto idx : indices)
|
||||
|
@ -1015,7 +1016,7 @@ class NumaConfig {
|
|||
if (s.empty())
|
||||
return indices;
|
||||
|
||||
for (const std::string& ss : split(s, ","))
|
||||
for (const auto& ss : split(s, ","))
|
||||
{
|
||||
if (ss.empty())
|
||||
continue;
|
||||
|
@ -1023,13 +1024,13 @@ class NumaConfig {
|
|||
auto parts = split(ss, "-");
|
||||
if (parts.size() == 1)
|
||||
{
|
||||
const CpuIndex c = CpuIndex{str_to_size_t(parts[0])};
|
||||
const CpuIndex c = CpuIndex{str_to_size_t(std::string(parts[0]))};
|
||||
indices.emplace_back(c);
|
||||
}
|
||||
else if (parts.size() == 2)
|
||||
{
|
||||
const CpuIndex cfirst = CpuIndex{str_to_size_t(parts[0])};
|
||||
const CpuIndex clast = CpuIndex{str_to_size_t(parts[1])};
|
||||
const CpuIndex cfirst = CpuIndex{str_to_size_t(std::string(parts[0]))};
|
||||
const CpuIndex clast = CpuIndex{str_to_size_t(std::string(parts[1]))};
|
||||
for (size_t c = cfirst; c <= clast; ++c)
|
||||
{
|
||||
indices.emplace_back(c);
|
||||
|
|
15
src/tt.cpp
15
src/tt.cpp
|
@ -193,13 +193,20 @@ void TranspositionTable::clear(ThreadPool& threads) {
|
|||
// Returns an approximation of the hashtable
|
||||
// occupation during a search. The hash is x permill full, as per UCI protocol.
|
||||
// Only counts entries which match the current generation.
|
||||
int TranspositionTable::hashfull() const {
|
||||
|
||||
int TranspositionTable::hashfull(int maxAge) const {
|
||||
int cnt = 0;
|
||||
for (int i = 0; i < 1000; ++i)
|
||||
for (int j = 0; j < ClusterSize; ++j)
|
||||
cnt += table[i].entry[j].is_occupied()
|
||||
&& (table[i].entry[j].genBound8 & GENERATION_MASK) == generation8;
|
||||
{
|
||||
if (table[i].entry[j].is_occupied())
|
||||
{
|
||||
int age = (generation8 >> GENERATION_BITS)
|
||||
- ((table[i].entry[j].genBound8 & GENERATION_MASK) >> GENERATION_BITS);
|
||||
if (age < 0)
|
||||
age += 1 << (8 - GENERATION_BITS);
|
||||
cnt += age <= maxAge;
|
||||
}
|
||||
}
|
||||
|
||||
return cnt / ClusterSize;
|
||||
}
|
||||
|
|
2
src/tt.h
2
src/tt.h
|
@ -73,7 +73,7 @@ class TranspositionTable {
|
|||
|
||||
void resize(size_t mbSize, ThreadPool& threads); // Set TT size
|
||||
void clear(ThreadPool& threads); // Re-initialize memory, multithreaded
|
||||
int hashfull()
|
||||
int hashfull(int maxAge = 0)
|
||||
const; // Approximate what fraction of entries (permille) have been written to during this root search
|
||||
|
||||
void
|
||||
|
|
174
src/uci.cpp
174
src/uci.cpp
|
@ -22,6 +22,7 @@
|
|||
#include <cctype>
|
||||
#include <cmath>
|
||||
#include <cstdint>
|
||||
#include <iterator>
|
||||
#include <optional>
|
||||
#include <sstream>
|
||||
#include <string_view>
|
||||
|
@ -30,6 +31,7 @@
|
|||
|
||||
#include "benchmark.h"
|
||||
#include "engine.h"
|
||||
#include "memory.h"
|
||||
#include "movegen.h"
|
||||
#include "position.h"
|
||||
#include "score.h"
|
||||
|
@ -39,6 +41,8 @@
|
|||
|
||||
namespace Stockfish {
|
||||
|
||||
constexpr auto BenchmarkCommand = "speedtest";
|
||||
|
||||
constexpr auto StartFEN = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1";
|
||||
template<typename... Ts>
|
||||
struct overload: Ts... {
|
||||
|
@ -48,7 +52,7 @@ struct overload: Ts... {
|
|||
template<typename... Ts>
|
||||
overload(Ts...) -> overload<Ts...>;
|
||||
|
||||
void UCIEngine::print_info_string(const std::string& str) {
|
||||
void UCIEngine::print_info_string(std::string_view str) {
|
||||
sync_cout_start();
|
||||
for (auto& line : split(str, "\n"))
|
||||
{
|
||||
|
@ -69,11 +73,16 @@ UCIEngine::UCIEngine(int argc, char** argv) :
|
|||
print_info_string(*str);
|
||||
});
|
||||
|
||||
init_search_update_listeners();
|
||||
}
|
||||
|
||||
void UCIEngine::init_search_update_listeners() {
|
||||
engine.set_on_iter([](const auto& i) { on_iter(i); });
|
||||
engine.set_on_update_no_moves([](const auto& i) { on_update_no_moves(i); });
|
||||
engine.set_on_update_full(
|
||||
[this](const auto& i) { on_update_full(i, engine.get_options()["UCI_ShowWDL"]); });
|
||||
engine.set_on_bestmove([](const auto& bm, const auto& p) { on_bestmove(bm, p); });
|
||||
engine.set_on_verify_networks([](const auto& s) { print_info_string(s); });
|
||||
}
|
||||
|
||||
void UCIEngine::loop() {
|
||||
|
@ -117,7 +126,7 @@ void UCIEngine::loop() {
|
|||
{
|
||||
// send info strings after the go command is sent for old GUIs and python-chess
|
||||
print_info_string(engine.numa_config_information_as_string());
|
||||
print_info_string(engine.thread_binding_information_as_string());
|
||||
print_info_string(engine.thread_allocation_information_as_string());
|
||||
go(is);
|
||||
}
|
||||
else if (token == "position")
|
||||
|
@ -133,6 +142,8 @@ void UCIEngine::loop() {
|
|||
engine.flip();
|
||||
else if (token == "bench")
|
||||
bench(is);
|
||||
else if (token == BenchmarkCommand)
|
||||
benchmark(is);
|
||||
else if (token == "d")
|
||||
sync_cout << engine.visualize() << sync_endl;
|
||||
else if (token == "eval")
|
||||
|
@ -285,6 +296,165 @@ void UCIEngine::bench(std::istream& args) {
|
|||
engine.set_on_update_full([&](const auto& i) { on_update_full(i, options["UCI_ShowWDL"]); });
|
||||
}
|
||||
|
||||
void UCIEngine::benchmark(std::istream& args) {
|
||||
// Probably not very important for a test this long, but include for completeness and sanity.
|
||||
static constexpr int NUM_WARMUP_POSITIONS = 3;
|
||||
|
||||
std::string token;
|
||||
uint64_t nodes = 0, cnt = 1;
|
||||
uint64_t nodesSearched = 0;
|
||||
|
||||
engine.set_on_update_full([&](const Engine::InfoFull& i) { nodesSearched = i.nodes; });
|
||||
|
||||
engine.set_on_iter([](const auto&) {});
|
||||
engine.set_on_update_no_moves([](const auto&) {});
|
||||
engine.set_on_bestmove([](const auto&, const auto&) {});
|
||||
engine.set_on_verify_networks([](const auto&) {});
|
||||
|
||||
Benchmark::BenchmarkSetup setup = Benchmark::setup_benchmark(args);
|
||||
|
||||
const int numGoCommands = count_if(setup.commands.begin(), setup.commands.end(),
|
||||
[](const std::string& s) { return s.find("go ") == 0; });
|
||||
|
||||
TimePoint totalTime = 0;
|
||||
|
||||
// Set options once at the start.
|
||||
auto ss = std::istringstream("name Threads value " + std::to_string(setup.threads));
|
||||
setoption(ss);
|
||||
ss = std::istringstream("name Hash value " + std::to_string(setup.ttSize));
|
||||
setoption(ss);
|
||||
ss = std::istringstream("name UCI_Chess960 value false");
|
||||
setoption(ss);
|
||||
|
||||
// Warmup
|
||||
for (const auto& cmd : setup.commands)
|
||||
{
|
||||
std::istringstream is(cmd);
|
||||
is >> std::skipws >> token;
|
||||
|
||||
if (token == "go")
|
||||
{
|
||||
// One new line is produced by the search, so omit it here
|
||||
std::cerr << "\rWarmup position " << cnt++ << '/' << NUM_WARMUP_POSITIONS;
|
||||
|
||||
Search::LimitsType limits = parse_limits(is);
|
||||
|
||||
TimePoint elapsed = now();
|
||||
|
||||
// Run with silenced network verification
|
||||
engine.go(limits);
|
||||
engine.wait_for_search_finished();
|
||||
|
||||
totalTime += now() - elapsed;
|
||||
|
||||
nodes += nodesSearched;
|
||||
nodesSearched = 0;
|
||||
}
|
||||
else if (token == "position")
|
||||
position(is);
|
||||
else if (token == "ucinewgame")
|
||||
{
|
||||
engine.search_clear(); // search_clear may take a while
|
||||
}
|
||||
|
||||
if (cnt > NUM_WARMUP_POSITIONS)
|
||||
break;
|
||||
}
|
||||
|
||||
std::cerr << "\n";
|
||||
|
||||
cnt = 1;
|
||||
nodes = 0;
|
||||
|
||||
int numHashfullReadings = 0;
|
||||
constexpr int hashfullAges[] = {0, 999}; // Only normal hashfull and touched hash.
|
||||
int totalHashfull[std::size(hashfullAges)] = {0};
|
||||
int maxHashfull[std::size(hashfullAges)] = {0};
|
||||
|
||||
auto updateHashfullReadings = [&]() {
|
||||
numHashfullReadings += 1;
|
||||
|
||||
for (int i = 0; i < static_cast<int>(std::size(hashfullAges)); ++i)
|
||||
{
|
||||
const int hashfull = engine.get_hashfull(hashfullAges[i]);
|
||||
maxHashfull[i] = std::max(maxHashfull[i], hashfull);
|
||||
totalHashfull[i] += hashfull;
|
||||
}
|
||||
};
|
||||
|
||||
engine.search_clear(); // search_clear may take a while
|
||||
|
||||
for (const auto& cmd : setup.commands)
|
||||
{
|
||||
std::istringstream is(cmd);
|
||||
is >> std::skipws >> token;
|
||||
|
||||
if (token == "go")
|
||||
{
|
||||
// One new line is produced by the search, so omit it here
|
||||
std::cerr << "\rPosition " << cnt++ << '/' << numGoCommands;
|
||||
|
||||
Search::LimitsType limits = parse_limits(is);
|
||||
|
||||
TimePoint elapsed = now();
|
||||
|
||||
// Run with silenced network verification
|
||||
engine.go(limits);
|
||||
engine.wait_for_search_finished();
|
||||
|
||||
totalTime += now() - elapsed;
|
||||
|
||||
updateHashfullReadings();
|
||||
|
||||
nodes += nodesSearched;
|
||||
nodesSearched = 0;
|
||||
}
|
||||
else if (token == "position")
|
||||
position(is);
|
||||
else if (token == "ucinewgame")
|
||||
{
|
||||
engine.search_clear(); // search_clear may take a while
|
||||
}
|
||||
}
|
||||
|
||||
totalTime = std::max<TimePoint>(totalTime, 1); // Ensure positivity to avoid a 'divide by zero'
|
||||
|
||||
dbg_print();
|
||||
|
||||
std::cerr << "\n";
|
||||
|
||||
static_assert(
|
||||
std::size(hashfullAges) == 2 && hashfullAges[0] == 0 && hashfullAges[1] == 999,
|
||||
"Hardcoded for display. Would complicate the code needlessly in the current state.");
|
||||
|
||||
std::string threadBinding = engine.thread_binding_information_as_string();
|
||||
if (threadBinding.empty())
|
||||
threadBinding = "none";
|
||||
|
||||
std::cerr << "==========================="
|
||||
<< "\nVersion : "
|
||||
<< engine_version_info()
|
||||
// "\nCompiled by : "
|
||||
<< compiler_info()
|
||||
<< "Large pages : " << (has_large_pages() ? "yes" : "no")
|
||||
<< "\nUser invocation : " << BenchmarkCommand << " "
|
||||
<< setup.originalInvocation << "\nFilled invocation : " << BenchmarkCommand
|
||||
<< " " << setup.filledInvocation
|
||||
<< "\nAvailable processors : " << engine.get_numa_config_as_string()
|
||||
<< "\nThread count : " << setup.threads
|
||||
<< "\nThread binding : " << threadBinding
|
||||
<< "\nTT size [MiB] : " << setup.ttSize
|
||||
<< "\nHash max, avg [per mille] : "
|
||||
<< "\n single search : " << maxHashfull[0] << ", "
|
||||
<< totalHashfull[0] / numHashfullReadings
|
||||
<< "\n single game : " << maxHashfull[1] << ", "
|
||||
<< totalHashfull[1] / numHashfullReadings
|
||||
<< "\nTotal nodes searched : " << nodes
|
||||
<< "\nTotal search time [s] : " << totalTime / 1000.0
|
||||
<< "\nNodes/second : " << 1000 * nodes / totalTime << std::endl;
|
||||
|
||||
init_search_update_listeners();
|
||||
}
|
||||
|
||||
void UCIEngine::setoption(std::istringstream& is) {
|
||||
engine.wait_for_search_finished();
|
||||
|
|
|
@ -58,10 +58,11 @@ class UCIEngine {
|
|||
Engine engine;
|
||||
CommandLine cli;
|
||||
|
||||
static void print_info_string(const std::string& str);
|
||||
static void print_info_string(std::string_view str);
|
||||
|
||||
void go(std::istringstream& is);
|
||||
void bench(std::istream& args);
|
||||
void benchmark(std::istream& args);
|
||||
void position(std::istringstream& is);
|
||||
void setoption(std::istringstream& is);
|
||||
std::uint64_t perft(const Search::LimitsType&);
|
||||
|
@ -70,6 +71,8 @@ class UCIEngine {
|
|||
static void on_update_full(const Engine::InfoFull& info, bool showWDL);
|
||||
static void on_iter(const Engine::InfoIter& info);
|
||||
static void on_bestmove(std::string_view bestmove, std::string_view ponder);
|
||||
|
||||
void init_search_update_listeners();
|
||||
};
|
||||
|
||||
} // namespace Stockfish
|
||||
|
|
Loading…
Add table
Reference in a new issue