summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
41ccc88)
Backported from C++11 branch:
https://github.com/official-stockfish/Stockfish/commit/
7ff965eebfbc17d2b
https://github.com/official-stockfish/Stockfish/commit/
e74c2df907d5336d3d2b
Fully verified it is equivalent to master (see log msg
of individual commits for details).
No functional change.
// Pointer 'this_sp' is not null only if we are called from split(), and not
// at the thread creation. This means we are the split point's master.
// Pointer 'this_sp' is not null only if we are called from split(), and not
// at the thread creation. This means we are the split point's master.
- SplitPoint* this_sp = splitPointsSize ? activeSplitPoint : NULL;
+ SplitPoint* this_sp = activeSplitPoint;
- assert(!this_sp || (this_sp->masterThread == this && searching));
+ assert(!this_sp || (this_sp->master == this && searching));
Threads.mutex.lock();
assert(activeSplitPoint);
Threads.mutex.lock();
assert(activeSplitPoint);
SplitPoint* sp = activeSplitPoint;
Threads.mutex.unlock();
SplitPoint* sp = activeSplitPoint;
Threads.mutex.unlock();
// Wake up the master thread so to allow it to return from the idle
// loop in case we are the last slave of the split point.
// Wake up the master thread so to allow it to return from the idle
// loop in case we are the last slave of the split point.
- if ( this != sp->masterThread
- && sp->slavesMask.none())
+ if (this != sp->master && sp->slavesMask.none())
- assert(!sp->masterThread->searching);
- sp->masterThread->notify_one();
+ assert(!sp->master->searching);
+
+ sp->master->notify_one();
}
// After releasing the lock we can't access any SplitPoint related data
}
// After releasing the lock we can't access any SplitPoint related data
// Try to late join to another split point if none of its slaves has
// already finished.
SplitPoint* bestSp = NULL;
// Try to late join to another split point if none of its slaves has
// already finished.
SplitPoint* bestSp = NULL;
- Thread* bestThread = NULL;
int bestScore = INT_MAX;
for (size_t i = 0; i < Threads.size(); ++i)
int bestScore = INT_MAX;
for (size_t i = 0; i < Threads.size(); ++i)
if (score < bestScore)
{
bestSp = sp;
if (score < bestScore)
{
bestSp = sp;
- bestThread = Threads[i];
if ( sp->allSlavesSearching
&& sp->slavesMask.count() < MAX_SLAVES_PER_SPLITPOINT
if ( sp->allSlavesSearching
&& sp->slavesMask.count() < MAX_SLAVES_PER_SPLITPOINT
- && available_to(bestThread))
+ && available_to(sp->master))
{
sp->slavesMask.set(idx);
activeSplitPoint = sp;
{
sp->slavesMask.set(idx);
activeSplitPoint = sp;
- // Grab the lock to avoid races with Thread::notify_one()
+ // Avoid races with notify_one() fired from last slave of the split point
mutex.lock();
// If we are master and all slaves have finished then exit idle_loop
mutex.lock();
// If we are master and all slaves have finished then exit idle_loop
// Pick and init the next available split point
SplitPoint& sp = splitPoints[splitPointsSize];
// Pick and init the next available split point
SplitPoint& sp = splitPoints[splitPointsSize];
- sp.masterThread = this;
sp.parentSplitPoint = activeSplitPoint;
sp.slavesMask = 0, sp.slavesMask.set(idx);
sp.depth = depth;
sp.parentSplitPoint = activeSplitPoint;
sp.slavesMask = 0, sp.slavesMask.set(idx);
sp.depth = depth;
// Const data after split point has been setup
const Position* pos;
Search::Stack* ss;
// Const data after split point has been setup
const Position* pos;
Search::Stack* ss;
Depth depth;
Value beta;
int nodeType;
Depth depth;
Value beta;
int nodeType;