X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fthread.cpp;h=5c013c6a0b72e06830d2a7389706f45d73b9a43a;hp=9400b38d06805813da71f993da1a8b22025dfab4;hb=dccaa145d2b57999aa3e368c7c9203731b4e9685;hpb=62f531254e03f946c92ad307fb68c7faa2806d16 diff --git a/src/thread.cpp b/src/thread.cpp index 9400b38d..5c013c6a 100644 --- a/src/thread.cpp +++ b/src/thread.cpp @@ -1,7 +1,7 @@ /* Stockfish, a UCI chess playing engine derived from Glaurung 2.1 Copyright (C) 2004-2008 Tord Romstad (Glaurung author) - Copyright (C) 2008-2014 Marco Costalba, Joona Kiiski, Tord Romstad + Copyright (C) 2008-2015 Marco Costalba, Joona Kiiski, Tord Romstad Stockfish is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -86,7 +86,7 @@ void ThreadBase::wait_for(volatile const bool& condition) { // Thread c'tor makes some init but does not launch any execution thread that // will be started only when c'tor returns. -Thread::Thread() /* : splitPoints() */ { // Value-initialization bug in MSVC +Thread::Thread() /* : splitPoints() */ { // Initialization of non POD broken in MSVC searching = false; maxPly = splitPointsSize = 0; @@ -155,6 +155,7 @@ void Thread::split(Position& pos, Stack* ss, Value alpha, Value beta, Value* bes sp.masterThread = this; sp.parentSplitPoint = activeSplitPoint; sp.slavesMask = 0, sp.slavesMask.set(idx); + sp.slavesCount = 1; sp.depth = depth; sp.bestValue = *bestValue; sp.bestMove = *bestMove; @@ -182,9 +183,11 @@ void Thread::split(Position& pos, Stack* ss, Value alpha, Value beta, Value* bes Thread* slave; - while ((slave = Threads.available_slave(this)) != NULL) + while ( sp.slavesCount < MAX_SLAVES_PER_SPLITPOINT + && (slave = Threads.available_slave(this)) != NULL) { sp.slavesMask.set(slave->idx); + sp.slavesCount++; slave->activeSplitPoint = &sp; slave->searching = true; // Slave leaves idle_loop() slave->notify_one(); // Could be sleeping