Skip to content

Commit

Permalink
Better MultiPV performance
Browse files Browse the repository at this point in the history
Allows better use of the TT for multiPV, resulting in greater depth and
thus strength.
  • Loading branch information
jhellis3 committed May 9, 2024
1 parent 070e564 commit 2236edb
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,11 @@ Value Search::Worker::search(
return alpha;
}
else
{
thisThread->rootDelta = beta - alpha;
if (thisThread->pvIdx > 0 && depth > 3)
depth -= 2;
}

assert(0 <= ss->ply && ss->ply < MAX_PLY);

Expand All @@ -614,8 +618,13 @@ Value Search::Worker::search(
if (!excludedMove)
ss->ttPv = PvNode || (ss->ttHit && tte->is_pv());

bool multiTT = thisThread->pvIdx > 0
&& !rootNode
&& !(ss->ply & 1)
&& (tte->bound() & BOUND_LOWER);

// At non-PV nodes we check for an early TT cutoff
if (!PvNode && !excludedMove && tte->depth() > depth
if ((!PvNode || multiTT) && !excludedMove && tte->depth() > depth
&& ttValue != VALUE_NONE // Possible in case of TT access race or if !ttHit
&& (tte->bound() & (ttValue >= beta ? BOUND_LOWER : BOUND_UPPER)))
{
Expand Down Expand Up @@ -1445,8 +1454,12 @@ Value Search::Worker::qsearch(Position& pos, Stack* ss, Value alpha, Value beta,
ttMove = ss->ttHit ? tte->move() : Move::none();
pvHit = ss->ttHit && tte->is_pv();

bool multiTT = thisThread->pvIdx > 0
&& !(ss->ply & 1)
&& (tte->bound() & BOUND_LOWER);

// At non-PV nodes we check for an early TT cutoff
if (!PvNode && tte->depth() >= ttDepth
if ((!PvNode || multiTT) && tte->depth() >= ttDepth
&& ttValue != VALUE_NONE // Only in case of TT access race or if !ttHit
&& (tte->bound() & (ttValue >= beta ? BOUND_LOWER : BOUND_UPPER)))
return ttValue;
Expand Down

0 comments on commit 2236edb

Please sign in to comment.