]> git.sesse.net Git - stockfish/blobdiff - src/thread.cpp
Retire history.h
[stockfish] / src / thread.cpp
index 9aa0b55ef0deaafac39f430bbab900a754ba855f..316ed76ba63783b4542ca2cc7bd5f89e80043dd1 100644 (file)
@@ -17,6 +17,7 @@
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
+#include <algorithm> // For std::count
 #include <cassert>
 #include <iostream>
 
@@ -296,7 +297,7 @@ Value ThreadPool::split(Position& pos, Stack* ss, Value alpha, Value beta,
   for (size_t i = 0; i < threads.size() && !Fake; ++i)
       if (threads[i]->is_available_to(master) && ++slavesCnt <= maxThreadsPerSplitPoint)
       {
-          sp.slavesMask |= 1ULL << i;
+          sp.slavesMask |= 1ULL << threads[i]->idx;
           threads[i]->activeSplitPoint = &sp;
           threads[i]->searching = true; // Slave leaves idle_loop()
           threads[i]->notify_one(); // Could be sleeping
@@ -352,8 +353,8 @@ void ThreadPool::wait_for_think_finished() {
 }
 
 
-// start_thinking() wakes up the main thread sleeping in  main_loop() so to start
-// a new search, then returns immediately.
+// start_thinking() wakes up the main thread sleeping in MainThread::idle_loop()
+// so to start a new search, then returns immediately.
 
 void ThreadPool::start_thinking(const Position& pos, const LimitsType& limits,
                                 const std::vector<Move>& searchMoves, StateStackPtr& states) {
@@ -370,7 +371,8 @@ void ThreadPool::start_thinking(const Position& pos, const LimitsType& limits,
   RootMoves.clear();
 
   for (MoveList<LEGAL> ml(pos); !ml.end(); ++ml)
-      if (searchMoves.empty() || count(searchMoves.begin(), searchMoves.end(), ml.move()))
+      if (  searchMoves.empty()
+         || std::count(searchMoves.begin(), searchMoves.end(), ml.move()))
           RootMoves.push_back(RootMove(ml.move()));
 
   main_thread()->thinking = true;