Browse files

Setup correct master data before to run the slaves

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
  • Loading branch information...
1 parent 4a71c86 commit c3efdd35183f3e415e9a0dd75a0df8e724e041b8 @mcostalba committed Oct 16, 2011
Showing with 6 additions and 9 deletions.
  1. +6 −9 src/thread.cpp
View
15 src/thread.cpp
@@ -281,6 +281,10 @@ Value ThreadsManager::split(Position& pos, SearchStack* ss, Value alpha, Value b
// If we are here it means we are not available
assert(masterThread.state == Thread::SEARCHING);
+ masterThread.splitPoint = &splitPoint;
+ masterThread.activeSplitPoints++;
+ masterThread.state = Thread::WORKISWAITING;
+
int workersCnt = 1; // At least the master is included
// Try to allocate available threads and ask them to start searching setting
@@ -304,20 +308,13 @@ Value ThreadsManager::split(Position& pos, SearchStack* ss, Value alpha, Value b
lock_release(&threadsLock);
- // We failed to allocate even one slave, return
- if (!Fake && workersCnt == 1)
- return bestValue;
-
- masterThread.splitPoint = &splitPoint;
- masterThread.activeSplitPoints++;
- masterThread.state = Thread::WORKISWAITING;
-
// Everything is set up. The master thread enters the idle loop, from
// which it will instantly launch a search, because its state is
// Thread::WORKISWAITING. We send the split point as a second parameter to
// the idle loop, which means that the main thread will return from the idle
// loop when all threads have finished their work at this split point.
- idle_loop(master, &splitPoint);
+ if (Fake || workersCnt > 1)
+ idle_loop(master, &splitPoint);
// We have returned from the idle loop, which means that all threads are
// finished. Note that changing state and decreasing activeSplitPoints is done

0 comments on commit c3efdd3

Please sign in to comment.