mirror of
https://github.com/sockspls/badfish
synced 2025-04-30 08:43:09 +00:00
Some renaming in split()
Naming suggested by jundery. No functional change.
This commit is contained in:
parent
6560e4cc5b
commit
b8c5ea869c
4 changed files with 25 additions and 25 deletions
|
@ -360,4 +360,4 @@ Move MovePicker::next_move<false>() {
|
||||||
/// from the split point's shared MovePicker object. This function is not thread
|
/// from the split point's shared MovePicker object. This function is not thread
|
||||||
/// safe so must be lock protected by the caller.
|
/// safe so must be lock protected by the caller.
|
||||||
template<>
|
template<>
|
||||||
Move MovePicker::next_move<true>() { return ss->sp->mp->next_move<false>(); }
|
Move MovePicker::next_move<true>() { return ss->sp->movePicker->next_move<false>(); }
|
||||||
|
|
|
@ -1616,7 +1616,7 @@ void Thread::idle_loop() {
|
||||||
// at the thread creation. So it means we are the split point's master.
|
// at the thread creation. So it means we are the split point's master.
|
||||||
const SplitPoint* this_sp = splitPointsSize ? activeSplitPoint : NULL;
|
const SplitPoint* this_sp = splitPointsSize ? activeSplitPoint : NULL;
|
||||||
|
|
||||||
assert(!this_sp || (this_sp->master == this && searching));
|
assert(!this_sp || (this_sp->masterThread == this && searching));
|
||||||
|
|
||||||
// If this thread is the master of a split point and all slaves have finished
|
// If this thread is the master of a split point and all slaves have finished
|
||||||
// their work at this split point, return from the idle loop.
|
// their work at this split point, return from the idle loop.
|
||||||
|
@ -1700,11 +1700,11 @@ void Thread::idle_loop() {
|
||||||
// Wake up master thread so to allow it to return from the idle loop
|
// Wake up master thread so to allow it to return from the idle loop
|
||||||
// in case we are the last slave of the split point.
|
// in case we are the last slave of the split point.
|
||||||
if ( Threads.sleepWhileIdle
|
if ( Threads.sleepWhileIdle
|
||||||
&& this != sp->master
|
&& this != sp->masterThread
|
||||||
&& !sp->slavesMask)
|
&& !sp->slavesMask)
|
||||||
{
|
{
|
||||||
assert(!sp->master->searching);
|
assert(!sp->masterThread->searching);
|
||||||
sp->master->notify_one();
|
sp->masterThread->notify_one();
|
||||||
}
|
}
|
||||||
|
|
||||||
// After releasing the lock we cannot access anymore any SplitPoint
|
// After releasing the lock we cannot access anymore any SplitPoint
|
||||||
|
|
|
@ -147,7 +147,7 @@ void Thread::wait_for(volatile const bool& b) {
|
||||||
|
|
||||||
bool Thread::cutoff_occurred() const {
|
bool Thread::cutoff_occurred() const {
|
||||||
|
|
||||||
for (SplitPoint* sp = activeSplitPoint; sp; sp = sp->parent)
|
for (SplitPoint* sp = activeSplitPoint; sp; sp = sp->parentSplitPoint)
|
||||||
if (sp->cutoff)
|
if (sp->cutoff)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
@ -258,17 +258,17 @@ Value ThreadPool::split(Position& pos, Stack* ss, Value alpha, Value beta,
|
||||||
assert(bestValue > -VALUE_INFINITE);
|
assert(bestValue > -VALUE_INFINITE);
|
||||||
assert(depth >= Threads.minimumSplitDepth);
|
assert(depth >= Threads.minimumSplitDepth);
|
||||||
|
|
||||||
Thread* master = pos.this_thread();
|
Thread* thisThread = pos.this_thread();
|
||||||
|
|
||||||
assert(master->searching);
|
assert(thisThread->searching);
|
||||||
assert(master->splitPointsSize < MAX_SPLITPOINTS_PER_THREAD);
|
assert(thisThread->splitPointsSize < MAX_SPLITPOINTS_PER_THREAD);
|
||||||
|
|
||||||
// Pick the next available split point from the split point stack
|
// Pick the next available split point from the split point stack
|
||||||
SplitPoint& sp = master->splitPoints[master->splitPointsSize];
|
SplitPoint& sp = thisThread->splitPoints[thisThread->splitPointsSize];
|
||||||
|
|
||||||
sp.master = master;
|
sp.masterThread = thisThread;
|
||||||
sp.parent = master->activeSplitPoint;
|
sp.parentSplitPoint = thisThread->activeSplitPoint;
|
||||||
sp.slavesMask = 1ULL << master->idx;
|
sp.slavesMask = 1ULL << thisThread->idx;
|
||||||
sp.depth = depth;
|
sp.depth = depth;
|
||||||
sp.bestMove = *bestMove;
|
sp.bestMove = *bestMove;
|
||||||
sp.threatMove = threatMove;
|
sp.threatMove = threatMove;
|
||||||
|
@ -276,7 +276,7 @@ Value ThreadPool::split(Position& pos, Stack* ss, Value alpha, Value beta,
|
||||||
sp.beta = beta;
|
sp.beta = beta;
|
||||||
sp.nodeType = nodeType;
|
sp.nodeType = nodeType;
|
||||||
sp.bestValue = bestValue;
|
sp.bestValue = bestValue;
|
||||||
sp.mp = ∓
|
sp.movePicker = ∓
|
||||||
sp.moveCount = moveCount;
|
sp.moveCount = moveCount;
|
||||||
sp.pos = &pos;
|
sp.pos = &pos;
|
||||||
sp.nodes = 0;
|
sp.nodes = 0;
|
||||||
|
@ -289,13 +289,13 @@ Value ThreadPool::split(Position& pos, Stack* ss, Value alpha, Value beta,
|
||||||
mutex.lock();
|
mutex.lock();
|
||||||
sp.mutex.lock();
|
sp.mutex.lock();
|
||||||
|
|
||||||
master->splitPointsSize++;
|
thisThread->splitPointsSize++;
|
||||||
master->activeSplitPoint = &sp;
|
thisThread->activeSplitPoint = &sp;
|
||||||
|
|
||||||
size_t slavesCnt = 1; // Master is always included
|
size_t slavesCnt = 1; // Master is always included
|
||||||
|
|
||||||
for (size_t i = 0; i < threads.size() && !Fake; ++i)
|
for (size_t i = 0; i < threads.size() && !Fake; ++i)
|
||||||
if (threads[i]->is_available_to(master) && ++slavesCnt <= maxThreadsPerSplitPoint)
|
if (threads[i]->is_available_to(thisThread) && ++slavesCnt <= maxThreadsPerSplitPoint)
|
||||||
{
|
{
|
||||||
sp.slavesMask |= 1ULL << threads[i]->idx;
|
sp.slavesMask |= 1ULL << threads[i]->idx;
|
||||||
threads[i]->activeSplitPoint = &sp;
|
threads[i]->activeSplitPoint = &sp;
|
||||||
|
@ -312,11 +312,11 @@ Value ThreadPool::split(Position& pos, Stack* ss, Value alpha, Value beta,
|
||||||
// their work at this split point.
|
// their work at this split point.
|
||||||
if (slavesCnt > 1 || Fake)
|
if (slavesCnt > 1 || Fake)
|
||||||
{
|
{
|
||||||
master->Thread::idle_loop(); // Force a call to base class idle_loop()
|
thisThread->Thread::idle_loop(); // Force a call to base class idle_loop()
|
||||||
|
|
||||||
// In helpful master concept a master can help only a sub-tree of its split
|
// In helpful master concept a master can help only a sub-tree of its split
|
||||||
// point, and because here is all finished is not possible master is booked.
|
// point, and because here is all finished is not possible master is booked.
|
||||||
assert(!master->searching);
|
assert(!thisThread->searching);
|
||||||
}
|
}
|
||||||
|
|
||||||
// We have returned from the idle loop, which means that all threads are
|
// We have returned from the idle loop, which means that all threads are
|
||||||
|
@ -325,9 +325,9 @@ Value ThreadPool::split(Position& pos, Stack* ss, Value alpha, Value beta,
|
||||||
mutex.lock();
|
mutex.lock();
|
||||||
sp.mutex.lock();
|
sp.mutex.lock();
|
||||||
|
|
||||||
master->searching = true;
|
thisThread->searching = true;
|
||||||
master->splitPointsSize--;
|
thisThread->splitPointsSize--;
|
||||||
master->activeSplitPoint = sp.parent;
|
thisThread->activeSplitPoint = sp.parentSplitPoint;
|
||||||
pos.set_nodes_searched(pos.nodes_searched() + sp.nodes);
|
pos.set_nodes_searched(pos.nodes_searched() + sp.nodes);
|
||||||
*bestMove = sp.bestMove;
|
*bestMove = sp.bestMove;
|
||||||
|
|
||||||
|
|
|
@ -63,15 +63,15 @@ struct SplitPoint {
|
||||||
// Const data after split point has been setup
|
// Const data after split point has been setup
|
||||||
const Position* pos;
|
const Position* pos;
|
||||||
const Search::Stack* ss;
|
const Search::Stack* ss;
|
||||||
Thread* master;
|
Thread* masterThread;
|
||||||
Depth depth;
|
Depth depth;
|
||||||
Value beta;
|
Value beta;
|
||||||
int nodeType;
|
int nodeType;
|
||||||
Move threatMove;
|
Move threatMove;
|
||||||
|
|
||||||
// Const pointers to shared data
|
// Const pointers to shared data
|
||||||
MovePicker* mp;
|
MovePicker* movePicker;
|
||||||
SplitPoint* parent;
|
SplitPoint* parentSplitPoint;
|
||||||
|
|
||||||
// Shared data
|
// Shared data
|
||||||
Mutex mutex;
|
Mutex mutex;
|
||||||
|
|
Loading…
Add table
Reference in a new issue