Skip to content

Commit beedc8b

Browse files
committed
Move ponder to MainThread
the variable is only used to exchange signals between the UCI thread and mainThread. No functional change
1 parent 2ed87d2 commit beedc8b

File tree

4 files changed

+7
-6
lines changed

4 files changed

+7
-6
lines changed

src/search.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ void MainThread::search() {
229229
// GUI sends a "stop" or "ponderhit" command. We therefore simply wait here
230230
// until the GUI sends one of those commands.
231231

232-
while (!Threads.stop && (Threads.ponder || Limits.infinite))
232+
while (!Threads.stop && (ponder || Limits.infinite))
233233
{} // Busy wait for a stop or a ponder reset
234234

235235
// Stop the threads if not already stopped (also raise the stop if
@@ -517,7 +517,7 @@ void Thread::search() {
517517
{
518518
// If we are allowed to ponder do not stop the search now but
519519
// keep pondering until the GUI sends "ponderhit" or "stop".
520-
if (Threads.ponder)
520+
if (mainThread->ponder)
521521
mainThread->stopOnPonderhit = true;
522522
else
523523
Threads.stop = true;
@@ -1587,7 +1587,7 @@ void MainThread::check_time() {
15871587
}
15881588

15891589
// We should not stop pondering until told so by the GUI
1590-
if (Threads.ponder)
1590+
if (ponder)
15911591
return;
15921592

15931593
if ( (Limits.use_time_management() && (elapsed > Time.maximum() - 10 || stopOnPonderhit))

src/thread.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ void ThreadPool::start_thinking(Position& pos, StateListPtr& states,
163163
main()->wait_for_search_finished();
164164

165165
main()->stopOnPonderhit = stop = false;
166-
ponder = ponderMode;
166+
main()->ponder = ponderMode;
167167
Search::Limits = limits;
168168
Search::RootMoves rootMoves;
169169

src/thread.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ struct MainThread : public Thread {
8989
Value previousScore;
9090
int callsCnt;
9191
bool stopOnPonderhit;
92+
std::atomic_bool ponder;
9293
};
9394

9495

@@ -106,7 +107,7 @@ struct ThreadPool : public std::vector<Thread*> {
106107
uint64_t nodes_searched() const { return accumulate(&Thread::nodes); }
107108
uint64_t tb_hits() const { return accumulate(&Thread::tbHits); }
108109

109-
std::atomic_bool stop, ponder;
110+
std::atomic_bool stop;
110111

111112
private:
112113
StateListPtr setupStates;

src/uci.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ void UCI::loop(int argc, char* argv[]) {
216216
// user has played. We should continue searching but switch from pondering to
217217
// normal search.
218218
else if (token == "ponderhit")
219-
Threads.ponder = false; // Switch to normal search
219+
Threads.main()->ponder = false; // Switch to normal search
220220

221221
else if (token == "uci")
222222
sync_cout << "id name " << engine_info(true)

0 commit comments

Comments
 (0)