Skip to content

Commit

Permalink
Normalize some variable names and reuse existing logic
Browse files Browse the repository at this point in the history
closes official-stockfish/Stockfish#5346

No functional change
  • Loading branch information
Disservin committed Jun 3, 2024
1 parent 86b5640 commit ba06671
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,10 @@ void update_all_stats(const Position& pos,

Search::Worker::Worker(SharedState& sharedState,
std::unique_ptr<ISearchManager> 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),
Expand Down
6 changes: 3 additions & 3 deletions src/search.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<SearchManager*>(manager.get());
}

Expand All @@ -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
Expand Down
4 changes: 1 addition & 3 deletions src/thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,7 @@ void Thread::idle_loop() {
}
}

Search::SearchManager* ThreadPool::main_manager() {
return static_cast<Search::SearchManager*>(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); }
Expand Down

0 comments on commit ba06671

Please sign in to comment.