From ba06671aa9df5c0a3fa5f1fa2ce17ea4aa742b7a Mon Sep 17 00:00:00 2001 From: Disservin Date: Mon, 3 Jun 2024 19:47:34 +0200 Subject: [PATCH] Normalize some variable names and reuse existing logic closes https://github.com/official-stockfish/Stockfish/pull/5346 No functional change --- src/search.cpp | 4 ++-- src/search.h | 6 +++--- src/thread.cpp | 4 +--- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/search.cpp b/src/search.cpp index 4defbadb40b..c03fe7811de 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -137,10 +137,10 @@ void update_all_stats(const Position& pos, Search::Worker::Worker(SharedState& sharedState, std::unique_ptr sm, - size_t thread_id, + size_t threadId, NumaReplicatedAccessToken token) : // Unpack the SharedState struct into member variables - thread_idx(thread_id), + threadIdx(threadId), numaAccessToken(token), manager(std::move(sm)), options(sharedState.options), diff --git a/src/search.h b/src/search.h index 01f7b8bdb00..a22d32004f5 100644 --- a/src/search.h +++ b/src/search.h @@ -244,7 +244,7 @@ class Worker { // It searches from the root position and outputs the "bestmove". void start_searching(); - bool is_mainthread() const { return thread_idx == 0; } + bool is_mainthread() const { return threadIdx == 0; } // Public because they need to be updatable by the stats CounterMoveHistory counterMoves; @@ -270,7 +270,7 @@ class Worker { // Get a pointer to the search manager, only allowed to be called by the // main thread. SearchManager* main_manager() const { - assert(thread_idx == 0); + assert(threadIdx == 0); return static_cast(manager.get()); } @@ -291,7 +291,7 @@ class Worker { Depth rootDepth, completedDepth; Value rootDelta; - size_t thread_idx; + size_t threadIdx; NumaReplicatedAccessToken numaAccessToken; // Reductions lookup table initialized at startup diff --git a/src/thread.cpp b/src/thread.cpp index a36c2efb7c1..0a33422acc9 100644 --- a/src/thread.cpp +++ b/src/thread.cpp @@ -127,9 +127,7 @@ void Thread::idle_loop() { } } -Search::SearchManager* ThreadPool::main_manager() { - return static_cast(main_thread()->worker.get()->manager.get()); -} +Search::SearchManager* ThreadPool::main_manager() { return main_thread()->worker->main_manager(); } uint64_t ThreadPool::nodes_searched() const { return accumulate(&Search::Worker::nodes); } uint64_t ThreadPool::tb_hits() const { return accumulate(&Search::Worker::tbHits); }