X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fsearch.cpp;h=31e8b0b661f46392453d097c39e137ba52bead57;hb=3627348e2b4633604a878b0e5397acb6218a6afc;hp=458f149077e9dc30ffa8cfe30517884b36ee3ca8;hpb=05cf45f2d137600387d5e560e22a464a84ad7b0d;p=stockfish diff --git a/src/search.cpp b/src/search.cpp index 458f1490..31e8b0b6 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -132,34 +132,18 @@ namespace { Move pv[3]; }; - // Set of rows with half bits set to 1 and half to 0. It is used to allocate - // the search depths across the threads. - typedef std::vector Row; - - const Row HalfDensity[] = { - {0, 1}, - {1, 0}, - {0, 0, 1, 1}, - {0, 1, 1, 0}, - {1, 1, 0, 0}, - {1, 0, 0, 1}, - {0, 0, 0, 1, 1, 1}, - {0, 0, 1, 1, 1, 0}, - {0, 1, 1, 1, 0, 0}, - {1, 1, 1, 0, 0, 0}, - {1, 1, 0, 0, 0, 1}, - {1, 0, 0, 0, 1, 1}, - {0, 0, 0, 0, 1, 1, 1, 1}, - {0, 0, 0, 1, 1, 1, 1, 0}, - {0, 0, 1, 1, 1, 1, 0 ,0}, - {0, 1, 1, 1, 1, 0, 0 ,0}, - {1, 1, 1, 1, 0, 0, 0 ,0}, - {1, 1, 1, 0, 0, 0, 0 ,1}, - {1, 1, 0, 0, 0, 0, 1 ,1}, - {1, 0, 0, 0, 0, 1, 1 ,1}, - }; + // skip half of the plies in blocks depending on the helper thread idx. + bool skip_ply(int idx, int ply) { + + idx = (idx - 1) % 20 + 1; // cycle after 20 threads. - const size_t HalfDensitySize = std::extent::value; + // number of successive plies to skip, depending on idx. + int ones = 1; + while (ones * (ones + 1) < idx) + ones++; + + return ((ply + idx - 1) / ones - ones) % 2 == 0; + } EasyMoveManager EasyMove; Value DrawValue[COLOR_NB]; @@ -379,14 +363,9 @@ void Thread::search() { && !Signals.stop && (!Limits.depth || Threads.main()->rootDepth / ONE_PLY <= Limits.depth)) { - // Set up the new depths for the helper threads skipping on average every - // 2nd ply (using a half-density matrix). - if (!mainThread) - { - const Row& row = HalfDensity[(idx - 1) % HalfDensitySize]; - if (row[(rootDepth / ONE_PLY + rootPos.game_ply()) % row.size()]) - continue; - } + // skip plies for helper threads + if (idx && skip_ply(idx, rootDepth / ONE_PLY + rootPos.game_ply())) + continue; // Age out PV variability metric if (mainThread) @@ -923,7 +902,7 @@ moves_loop: // When in check search starts from here { if ( !captureOrPromotion && !givesCheck - && !pos.advanced_pawn_push(move)) + && (!pos.advanced_pawn_push(move) || pos.non_pawn_material(WHITE) + pos.non_pawn_material(BLACK) >= 5000)) { // Move count based pruning if (moveCountPruning)