mirror of
https://github.com/sockspls/badfish
synced 2025-05-01 01:03:09 +00:00
Further simplify skipping of plies with threads
No functional change Closes #1020
This commit is contained in:
parent
3627348e2b
commit
cc76524c2e
1 changed files with 7 additions and 15 deletions
|
@ -132,19 +132,6 @@ namespace {
|
||||||
Move pv[3];
|
Move pv[3];
|
||||||
};
|
};
|
||||||
|
|
||||||
// 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.
|
|
||||||
|
|
||||||
// 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;
|
EasyMoveManager EasyMove;
|
||||||
Value DrawValue[COLOR_NB];
|
Value DrawValue[COLOR_NB];
|
||||||
|
|
||||||
|
@ -321,6 +308,9 @@ void MainThread::search() {
|
||||||
std::cout << sync_endl;
|
std::cout << sync_endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sizes and phases of the skip-blocks, used for distributing search depths across the threads.
|
||||||
|
static int skipsize[20] = {1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4};
|
||||||
|
static int phase [20] = {0, 1, 0, 1, 2, 3, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 6, 7};
|
||||||
|
|
||||||
// Thread::search() is the main iterative deepening loop. It calls search()
|
// Thread::search() is the main iterative deepening loop. It calls search()
|
||||||
// repeatedly with increasing depth until the allocated thinking time has been
|
// repeatedly with increasing depth until the allocated thinking time has been
|
||||||
|
@ -358,13 +348,15 @@ void Thread::search() {
|
||||||
|
|
||||||
multiPV = std::min(multiPV, rootMoves.size());
|
multiPV = std::min(multiPV, rootMoves.size());
|
||||||
|
|
||||||
|
int hIdx = (idx - 1) % 20; // helper index, cycle after 20 threads
|
||||||
|
|
||||||
// Iterative deepening loop until requested to stop or the target depth is reached
|
// Iterative deepening loop until requested to stop or the target depth is reached
|
||||||
while ( (rootDepth += ONE_PLY) < DEPTH_MAX
|
while ( (rootDepth += ONE_PLY) < DEPTH_MAX
|
||||||
&& !Signals.stop
|
&& !Signals.stop
|
||||||
&& (!Limits.depth || Threads.main()->rootDepth / ONE_PLY <= Limits.depth))
|
&& (!Limits.depth || Threads.main()->rootDepth / ONE_PLY <= Limits.depth))
|
||||||
{
|
{
|
||||||
// skip plies for helper threads
|
// skip half of the plies in blocks depending on game ply and helper index.
|
||||||
if (idx && skip_ply(idx, rootDepth / ONE_PLY + rootPos.game_ply()))
|
if (idx && ((rootDepth / ONE_PLY + rootPos.game_ply() + phase[hIdx]) / skipsize[hIdx]) % 2)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Age out PV variability metric
|
// Age out PV variability metric
|
||||||
|
|
Loading…
Add table
Reference in a new issue