mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-20 00:56:39 +08:00
Per-thread TB hit counters
Use a per-thread counter to reduce contention with many cores and endgame positions. Measured around 1% speed-up on a 12 core and 8% on 28 cores with 6-men, searching on: 7R/1p3k2/2p2P2/3nR1P1/8/3b1P2/7K/r7 b - - 3 38 Also retire the unused set_nodes_searched() and fix a couple of return types and naming conventions. No functional change.
This commit is contained in:
@@ -46,7 +46,6 @@ namespace Search {
|
||||
namespace Tablebases {
|
||||
|
||||
int Cardinality;
|
||||
uint64_t Hits;
|
||||
bool RootInTB;
|
||||
bool UseRule50;
|
||||
Depth ProbeDepth;
|
||||
@@ -672,7 +671,7 @@ namespace {
|
||||
|
||||
if (found)
|
||||
{
|
||||
TB::Hits++;
|
||||
thisThread->tbHits++;
|
||||
|
||||
int drawScore = TB::UseRule50 ? 1 : 0;
|
||||
|
||||
@@ -1519,7 +1518,7 @@ moves_loop: // When in check search starts from here
|
||||
|
||||
if ( (Limits.use_time_management() && elapsed > Time.maximum() - 10)
|
||||
|| (Limits.movetime && elapsed >= Limits.movetime)
|
||||
|| (Limits.nodes && Threads.nodes_searched() >= Limits.nodes))
|
||||
|| (Limits.nodes && Threads.nodes_searched() >= (uint64_t)Limits.nodes))
|
||||
Signals.stop = true;
|
||||
}
|
||||
|
||||
@@ -1536,7 +1535,8 @@ string UCI::pv(const Position& pos, Depth depth, Value alpha, Value beta) {
|
||||
const RootMoves& rootMoves = pos.this_thread()->rootMoves;
|
||||
size_t PVIdx = pos.this_thread()->PVIdx;
|
||||
size_t multiPV = std::min((size_t)Options["MultiPV"], rootMoves.size());
|
||||
uint64_t nodes_searched = Threads.nodes_searched();
|
||||
uint64_t nodesSearched = Threads.nodes_searched();
|
||||
uint64_t tbHits = Threads.tb_hits() + (TB::RootInTB ? rootMoves.size() : 0);
|
||||
|
||||
for (size_t i = 0; i < multiPV; ++i)
|
||||
{
|
||||
@@ -1563,13 +1563,13 @@ string UCI::pv(const Position& pos, Depth depth, Value alpha, Value beta) {
|
||||
if (!tb && i == PVIdx)
|
||||
ss << (v >= beta ? " lowerbound" : v <= alpha ? " upperbound" : "");
|
||||
|
||||
ss << " nodes " << nodes_searched
|
||||
<< " nps " << nodes_searched * 1000 / elapsed;
|
||||
ss << " nodes " << nodesSearched
|
||||
<< " nps " << nodesSearched * 1000 / elapsed;
|
||||
|
||||
if (elapsed > 1000) // Earlier makes little sense
|
||||
ss << " hashfull " << TT.hashfull();
|
||||
|
||||
ss << " tbhits " << TB::Hits
|
||||
ss << " tbhits " << tbHits
|
||||
<< " time " << elapsed
|
||||
<< " pv";
|
||||
|
||||
@@ -1612,7 +1612,6 @@ bool RootMove::extract_ponder_from_tt(Position& pos) {
|
||||
|
||||
void Tablebases::filter_root_moves(Position& pos, Search::RootMoves& rootMoves) {
|
||||
|
||||
Hits = 0;
|
||||
RootInTB = false;
|
||||
UseRule50 = Options["Syzygy50MoveRule"];
|
||||
ProbeDepth = Options["SyzygyProbeDepth"] * ONE_PLY;
|
||||
@@ -1645,13 +1644,8 @@ void Tablebases::filter_root_moves(Position& pos, Search::RootMoves& rootMoves)
|
||||
Cardinality = 0;
|
||||
}
|
||||
|
||||
if (RootInTB)
|
||||
{
|
||||
Hits = rootMoves.size();
|
||||
|
||||
if (!UseRule50)
|
||||
TB::Score = TB::Score > VALUE_DRAW ? VALUE_MATE - MAX_PLY - 1
|
||||
: TB::Score < VALUE_DRAW ? -VALUE_MATE + MAX_PLY + 1
|
||||
: VALUE_DRAW;
|
||||
}
|
||||
if (RootInTB && !UseRule50)
|
||||
TB::Score = TB::Score > VALUE_DRAW ? VALUE_MATE - MAX_PLY - 1
|
||||
: TB::Score < VALUE_DRAW ? -VALUE_MATE + MAX_PLY + 1
|
||||
: VALUE_DRAW;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user