Merge commit 'a169c78b6d3b082068deb49a39aaa1fd75464c7f' into cluster

This commit is contained in:
Steinar H. Gunderson
2025-12-24 16:18:37 +01:00
19 changed files with 1419 additions and 290 deletions
+22 -16
View File
@@ -138,15 +138,17 @@ void update_all_stats(const Position& pos,
Search::Worker::Worker(SharedState& sharedState,
std::unique_ptr<ISearchManager> sm,
size_t thread_id) :
size_t thread_id,
NumaReplicatedAccessToken token) :
// Unpack the SharedState struct into member variables
thread_idx(thread_id),
numaAccessToken(token),
manager(std::move(sm)),
options(sharedState.options),
threads(sharedState.threads),
tt(sharedState.tt),
networks(sharedState.networks),
refreshTable(networks) {
refreshTable(networks[token]) {
clear();
}
@@ -476,7 +478,7 @@ void Search::Worker::iterative_deepening() {
skill.pick_best(rootMoves, multiPV);
// Use part of the gained time from a previous stable move for the current move
for (Thread* th : threads)
for (auto&& th : threads)
{
totBestMoveChanges += th->worker->bestMoveChanges;
th->worker->bestMoveChanges = 0;
@@ -558,7 +560,7 @@ void Search::Worker::clear() {
for (size_t i = 1; i < reductions.size(); ++i)
reductions[i] = int((19.90 + std::log(size_t(options["Threads"])) / 2) * std::log(i));
refreshTable.clear(networks);
refreshTable.clear(networks[numaAccessToken]);
}
@@ -625,7 +627,8 @@ Value Search::Worker::search(
if (threads.stop.load(std::memory_order_relaxed) || pos.is_draw(ss->ply)
|| ss->ply >= MAX_PLY)
return (ss->ply >= MAX_PLY && !ss->inCheck)
? evaluate(networks, pos, refreshTable, thisThread->optimism[us])
? evaluate(networks[numaAccessToken], pos, refreshTable,
thisThread->optimism[us])
: value_draw(thisThread->nodes);
// Step 3. Mate distance pruning. Even if we mate at the next move our score
@@ -754,7 +757,7 @@ Value Search::Worker::search(
{
// Providing the hint that this node's accumulator will be used often
// brings significant Elo gain (~13 Elo).
Eval::NNUE::hint_common_parent_position(pos, networks, refreshTable);
Eval::NNUE::hint_common_parent_position(pos, networks[numaAccessToken], refreshTable);
unadjustedStaticEval = eval = ss->staticEval;
}
else if (ss->ttHit)
@@ -762,9 +765,10 @@ Value Search::Worker::search(
// Never assume anything about values stored in TT
unadjustedStaticEval = tte->eval();
if (unadjustedStaticEval == VALUE_NONE)
unadjustedStaticEval = evaluate(networks, pos, refreshTable, thisThread->optimism[us]);
unadjustedStaticEval =
evaluate(networks[numaAccessToken], pos, refreshTable, thisThread->optimism[us]);
else if (PvNode)
Eval::NNUE::hint_common_parent_position(pos, networks, refreshTable);
Eval::NNUE::hint_common_parent_position(pos, networks[numaAccessToken], refreshTable);
ss->staticEval = eval = to_corrected_static_eval(unadjustedStaticEval, *thisThread, pos);
@@ -774,7 +778,8 @@ Value Search::Worker::search(
}
else
{
unadjustedStaticEval = evaluate(networks, pos, refreshTable, thisThread->optimism[us]);
unadjustedStaticEval =
evaluate(networks[numaAccessToken], pos, refreshTable, thisThread->optimism[us]);
ss->staticEval = eval = to_corrected_static_eval(unadjustedStaticEval, *thisThread, pos);
// Static evaluation is saved as it was before adjustment by correction history
@@ -941,7 +946,7 @@ Value Search::Worker::search(
}
}
Eval::NNUE::hint_common_parent_position(pos, networks, refreshTable);
Eval::NNUE::hint_common_parent_position(pos, networks[numaAccessToken], refreshTable);
}
moves_loop: // When in check, search starts here
@@ -1491,7 +1496,7 @@ Value Search::Worker::qsearch(Position& pos, Stack* ss, Value alpha, Value beta,
// Step 2. Check for an immediate draw or maximum ply reached
if (pos.is_draw(ss->ply) || ss->ply >= MAX_PLY)
return (ss->ply >= MAX_PLY && !ss->inCheck)
? evaluate(networks, pos, refreshTable, thisThread->optimism[us])
? evaluate(networks[numaAccessToken], pos, refreshTable, thisThread->optimism[us])
: VALUE_DRAW;
assert(0 <= ss->ply && ss->ply < MAX_PLY);
@@ -1526,7 +1531,7 @@ Value Search::Worker::qsearch(Position& pos, Stack* ss, Value alpha, Value beta,
unadjustedStaticEval = tte->eval();
if (unadjustedStaticEval == VALUE_NONE)
unadjustedStaticEval =
evaluate(networks, pos, refreshTable, thisThread->optimism[us]);
evaluate(networks[numaAccessToken], pos, refreshTable, thisThread->optimism[us]);
ss->staticEval = bestValue =
to_corrected_static_eval(unadjustedStaticEval, *thisThread, pos);
@@ -1538,10 +1543,11 @@ Value Search::Worker::qsearch(Position& pos, Stack* ss, Value alpha, Value beta,
else
{
// In case of null move search, use previous static eval with a different sign
unadjustedStaticEval = (ss - 1)->currentMove != Move::null()
? evaluate(networks, pos, refreshTable, thisThread->optimism[us])
: -(ss - 1)->staticEval;
ss->staticEval = bestValue =
unadjustedStaticEval =
(ss - 1)->currentMove != Move::null()
? evaluate(networks[numaAccessToken], pos, refreshTable, thisThread->optimism[us])
: -(ss - 1)->staticEval;
ss->staticEval = bestValue =
to_corrected_static_eval(unadjustedStaticEval, *thisThread, pos);
}