X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fthread.cpp;h=a466df87cbb9a2dfa5fa2b9280a858414de71706;hp=c232b849babacc66ef6e262322678b18883a37e5;hb=7ff965eebfbc17d2bb4be9c64d56fecf68615010;hpb=3c07603dac03f0da20194097cf4eb1a396fea60d diff --git a/src/thread.cpp b/src/thread.cpp index c232b849..a466df87 100644 --- a/src/thread.cpp +++ b/src/thread.cpp @@ -81,7 +81,8 @@ void ThreadBase::wait_for(volatile const bool& condition) { Thread::Thread() /* : splitPoints() */ { // Initialization of non POD broken in MSVC searching = false; - maxPly = splitPointsSize = 0; + maxPly = 0; + splitPointsSize = 0; activeSplitPoint = nullptr; activePosition = nullptr; idx = Threads.size(); // Starts from 0 @@ -115,7 +116,7 @@ bool Thread::available_to(const Thread* master) const { // Make a local copy to be sure it doesn't become zero under our feet while // testing next condition and so leading to an out of bounds access. - const int size = splitPointsSize; + const size_t size = splitPointsSize; // No split points means that the thread is available as a slave for any // other thread otherwise apply the "helpful master" concept if possible. @@ -144,7 +145,7 @@ void Thread::split(Position& pos, Stack* ss, Value alpha, Value beta, Value* bes // Pick and init the next available split point SplitPoint& sp = splitPoints[splitPointsSize]; - sp.masterThread = this; + sp.master = this; sp.parentSplitPoint = activeSplitPoint; sp.slavesMask = 0, sp.slavesMask.set(idx); sp.depth = depth; @@ -174,7 +175,8 @@ void Thread::split(Position& pos, Stack* ss, Value alpha, Value beta, Value* bes Thread* slave; - while ((slave = Threads.available_slave(this)) != nullptr) + while ( sp.slavesMask.count() < MAX_SLAVES_PER_SPLITPOINT + && (slave = Threads.available_slave(this)) != nullptr) { sp.slavesMask.set(slave->idx); slave->activeSplitPoint = &sp; @@ -365,10 +367,10 @@ void ThreadPool::start_thinking(const Position& pos, const LimitsType& limits, assert(!states.get()); } - for (const ExtMove& ms : MoveList(pos)) + for (const auto& m : MoveList(pos)) if ( limits.searchmoves.empty() - || std::count(limits.searchmoves.begin(), limits.searchmoves.end(), ms.move)) - RootMoves.push_back(RootMove(ms.move)); + || std::count(limits.searchmoves.begin(), limits.searchmoves.end(), m)) + RootMoves.push_back(RootMove(m)); main()->thinking = true; main()->notify_one(); // Starts main thread