mirror of
https://github.com/sockspls/badfish
synced 2025-04-30 16:53:09 +00:00
Reformat all_slaves_finished()
Rename and move under ThreadsManager class. No functional change. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
parent
369789b426
commit
43204d9ac2
3 changed files with 17 additions and 15 deletions
|
@ -2071,22 +2071,10 @@ split_point_start: // At split points actual search starts from here
|
||||||
|
|
||||||
do pos.undo_move(pv[--ply]); while (ply);
|
do pos.undo_move(pv[--ply]); while (ply);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
|
||||||
// Little helper used by idle_loop() to check that all the slave threads of a
|
|
||||||
// split point have finished searching.
|
|
||||||
|
|
||||||
static bool all_slaves_finished(SplitPoint* sp) {
|
|
||||||
|
|
||||||
for (int i = 0; i < Threads.size(); i++)
|
|
||||||
if (sp->is_slave[i])
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Thread::idle_loop() is where the thread is parked when it has no work to do.
|
// Thread::idle_loop() is where the thread is parked when it has no work to do.
|
||||||
// The parameter 'sp', if non-NULL, is a pointer to an active SplitPoint object
|
// The parameter 'sp', if non-NULL, is a pointer to an active SplitPoint object
|
||||||
// for which the thread is the master.
|
// for which the thread is the master.
|
||||||
|
@ -2114,7 +2102,7 @@ void Thread::idle_loop(SplitPoint* sp) {
|
||||||
lock_grab(&sleepLock);
|
lock_grab(&sleepLock);
|
||||||
|
|
||||||
// If we are master and all slaves have finished don't go to sleep
|
// If we are master and all slaves have finished don't go to sleep
|
||||||
if (sp && all_slaves_finished(sp))
|
if (sp && Threads.split_point_finished(sp))
|
||||||
{
|
{
|
||||||
lock_release(&sleepLock);
|
lock_release(&sleepLock);
|
||||||
break;
|
break;
|
||||||
|
@ -2166,7 +2154,7 @@ void Thread::idle_loop(SplitPoint* sp) {
|
||||||
|
|
||||||
// If this thread is the master of a split point and all slaves have
|
// If this thread is the master of a split point and all slaves have
|
||||||
// finished their work at this split point, return from the idle loop.
|
// finished their work at this split point, return from the idle loop.
|
||||||
if (sp && all_slaves_finished(sp))
|
if (sp && Threads.split_point_finished(sp))
|
||||||
{
|
{
|
||||||
// Because sp->is_slave[] is reset under lock protection,
|
// Because sp->is_slave[] is reset under lock protection,
|
||||||
// be sure sp->lock has been released before to return.
|
// be sure sp->lock has been released before to return.
|
||||||
|
|
|
@ -239,6 +239,19 @@ bool ThreadsManager::available_slave_exists(int master) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// split_point_finished() checks if all the slave threads of a given split
|
||||||
|
// point have finished searching.
|
||||||
|
|
||||||
|
bool ThreadsManager::split_point_finished(SplitPoint* sp) const {
|
||||||
|
|
||||||
|
for (int i = 0; i < activeThreads; i++)
|
||||||
|
if (sp->is_slave[i])
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// split() does the actual work of distributing the work at a node between
|
// split() does the actual work of distributing the work at a node between
|
||||||
// several available threads. If it does not succeed in splitting the
|
// several available threads. If it does not succeed in splitting the
|
||||||
// node (because no idle threads are available, or because we have no unused
|
// node (because no idle threads are available, or because we have no unused
|
||||||
|
|
|
@ -114,6 +114,7 @@ public:
|
||||||
void set_size(int cnt);
|
void set_size(int cnt);
|
||||||
void read_uci_options();
|
void read_uci_options();
|
||||||
bool available_slave_exists(int master) const;
|
bool available_slave_exists(int master) const;
|
||||||
|
bool split_point_finished(SplitPoint* sp) const;
|
||||||
|
|
||||||
void getline(std::string& cmd);
|
void getline(std::string& cmd);
|
||||||
void start_listener();
|
void start_listener();
|
||||||
|
|
Loading…
Add table
Reference in a new issue