mirror of
https://github.com/sockspls/badfish
synced 2025-04-30 00:33:09 +00:00
Another split() tweak session
Function split() doesn't need to return a value, also remove useless 'master' field. No functional change. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
parent
e63ab4bd03
commit
6e5bb3279f
2 changed files with 20 additions and 26 deletions
|
@ -89,8 +89,8 @@ namespace {
|
||||||
void idle_loop(int threadID, SplitPoint* sp);
|
void idle_loop(int threadID, SplitPoint* sp);
|
||||||
|
|
||||||
template <bool Fake>
|
template <bool Fake>
|
||||||
bool split(const Position& pos, SearchStack* ss, int ply, Value* alpha, const Value beta, Value* bestValue,
|
void split(const Position& pos, SearchStack* ss, int ply, Value* alpha, const Value beta, Value* bestValue,
|
||||||
Depth depth, bool mateThreat, int* moves, MovePicker* mp, int master, bool pvNode);
|
Depth depth, bool mateThreat, int* moveCount, MovePicker* mp, int master, bool pvNode);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend void poll();
|
friend void poll();
|
||||||
|
@ -1366,10 +1366,9 @@ namespace {
|
||||||
&& Iteration <= 99
|
&& Iteration <= 99
|
||||||
&& TM.available_thread_exists(threadID)
|
&& TM.available_thread_exists(threadID)
|
||||||
&& !AbortSearch
|
&& !AbortSearch
|
||||||
&& !TM.thread_should_stop(threadID)
|
&& !TM.thread_should_stop(threadID))
|
||||||
&& TM.split<FakeSplit>(pos, ss, ply, &alpha, beta, &bestValue, depth,
|
TM.split<FakeSplit>(pos, ss, ply, &alpha, beta, &bestValue, depth,
|
||||||
mateThreat, &moveCount, &mp, threadID, PvNode))
|
mateThreat, &moveCount, &mp, threadID, PvNode);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 19. Check for mate and stalemate
|
// Step 19. Check for mate and stalemate
|
||||||
|
@ -1635,7 +1634,7 @@ namespace {
|
||||||
&& (move = sp->mp->get_next_move()) != MOVE_NONE
|
&& (move = sp->mp->get_next_move()) != MOVE_NONE
|
||||||
&& !TM.thread_should_stop(threadID))
|
&& !TM.thread_should_stop(threadID))
|
||||||
{
|
{
|
||||||
moveCount = ++sp->moves;
|
moveCount = ++sp->moveCount;
|
||||||
lock_release(&(sp->lock));
|
lock_release(&(sp->lock));
|
||||||
|
|
||||||
assert(move_is_ok(move));
|
assert(move_is_ok(move));
|
||||||
|
@ -2589,20 +2588,19 @@ namespace {
|
||||||
|
|
||||||
|
|
||||||
// split() does the actual work of distributing the work at a node between
|
// split() does the actual work of distributing the work at a node between
|
||||||
// several threads at PV nodes. If it does not succeed in splitting the
|
// several available threads. If it does not succeed in splitting the
|
||||||
// node (because no idle threads are available, or because we have no unused
|
// node (because no idle threads are available, or because we have no unused
|
||||||
// split point objects), the function immediately returns false. If
|
// split point objects), the function immediately returns. If splitting is
|
||||||
// splitting is possible, a SplitPoint object is initialized with all the
|
// possible, a SplitPoint object is initialized with all the data that must be
|
||||||
// data that must be copied to the helper threads (the current position and
|
// copied to the helper threads and we tell our helper threads that they have
|
||||||
// search stack, alpha, beta, the search depth, etc.), and we tell our
|
// been assigned work. This will cause them to instantly leave their idle loops
|
||||||
// helper threads that they have been assigned work. This will cause them
|
// and call sp_search(). When all threads have returned from sp_search() then
|
||||||
// to instantly leave their idle loops and call sp_search(). When all
|
// split() returns.
|
||||||
// threads have returned from sp_search() then split() returns true.
|
|
||||||
|
|
||||||
template <bool Fake>
|
template <bool Fake>
|
||||||
bool ThreadsManager::split(const Position& p, SearchStack* sstck, int ply, Value* alpha,
|
void ThreadsManager::split(const Position& p, SearchStack* sstck, int ply, Value* alpha,
|
||||||
const Value beta, Value* bestValue, Depth depth, bool mateThreat,
|
const Value beta, Value* bestValue, Depth depth, bool mateThreat,
|
||||||
int* moves, MovePicker* mp, int master, bool pvNode) {
|
int* moveCount, MovePicker* mp, int master, bool pvNode) {
|
||||||
assert(p.is_ok());
|
assert(p.is_ok());
|
||||||
assert(sstck != NULL);
|
assert(sstck != NULL);
|
||||||
assert(ply >= 0 && ply < PLY_MAX);
|
assert(ply >= 0 && ply < PLY_MAX);
|
||||||
|
@ -2614,8 +2612,6 @@ namespace {
|
||||||
assert(master >= 0 && master < ActiveThreads);
|
assert(master >= 0 && master < ActiveThreads);
|
||||||
assert(ActiveThreads > 1);
|
assert(ActiveThreads > 1);
|
||||||
|
|
||||||
SplitPoint* splitPoint;
|
|
||||||
|
|
||||||
lock_grab(&MPLock);
|
lock_grab(&MPLock);
|
||||||
|
|
||||||
// If no other thread is available to help us, or if we have too many
|
// If no other thread is available to help us, or if we have too many
|
||||||
|
@ -2624,11 +2620,11 @@ namespace {
|
||||||
|| threads[master].activeSplitPoints >= ACTIVE_SPLIT_POINTS_MAX)
|
|| threads[master].activeSplitPoints >= ACTIVE_SPLIT_POINTS_MAX)
|
||||||
{
|
{
|
||||||
lock_release(&MPLock);
|
lock_release(&MPLock);
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pick the next available split point object from the split point stack
|
// Pick the next available split point object from the split point stack
|
||||||
splitPoint = &SplitPointStack[master][threads[master].activeSplitPoints];
|
SplitPoint* splitPoint = &SplitPointStack[master][threads[master].activeSplitPoints];
|
||||||
|
|
||||||
// Initialize the split point object
|
// Initialize the split point object
|
||||||
splitPoint->parent = threads[master].splitPoint;
|
splitPoint->parent = threads[master].splitPoint;
|
||||||
|
@ -2640,9 +2636,8 @@ namespace {
|
||||||
splitPoint->beta = beta;
|
splitPoint->beta = beta;
|
||||||
splitPoint->pvNode = pvNode;
|
splitPoint->pvNode = pvNode;
|
||||||
splitPoint->bestValue = *bestValue;
|
splitPoint->bestValue = *bestValue;
|
||||||
splitPoint->master = master;
|
|
||||||
splitPoint->mp = mp;
|
splitPoint->mp = mp;
|
||||||
splitPoint->moves = *moves;
|
splitPoint->moveCount = *moveCount;
|
||||||
splitPoint->pos = &p;
|
splitPoint->pos = &p;
|
||||||
splitPoint->parentSstack = sstck;
|
splitPoint->parentSstack = sstck;
|
||||||
for (int i = 0; i < ActiveThreads; i++)
|
for (int i = 0; i < ActiveThreads; i++)
|
||||||
|
@ -2700,7 +2695,6 @@ namespace {
|
||||||
threads[master].splitPoint = splitPoint->parent;
|
threads[master].splitPoint = splitPoint->parent;
|
||||||
|
|
||||||
lock_release(&MPLock);
|
lock_release(&MPLock);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ struct SplitPoint {
|
||||||
Depth depth;
|
Depth depth;
|
||||||
bool pvNode, mateThreat;
|
bool pvNode, mateThreat;
|
||||||
Value beta;
|
Value beta;
|
||||||
int ply, master;
|
int ply;
|
||||||
SearchStack sstack[MAX_THREADS][PLY_MAX_PLUS_2];
|
SearchStack sstack[MAX_THREADS][PLY_MAX_PLUS_2];
|
||||||
|
|
||||||
// Const pointers to shared data
|
// Const pointers to shared data
|
||||||
|
@ -65,7 +65,7 @@ struct SplitPoint {
|
||||||
Lock lock;
|
Lock lock;
|
||||||
volatile Value alpha;
|
volatile Value alpha;
|
||||||
volatile Value bestValue;
|
volatile Value bestValue;
|
||||||
volatile int moves;
|
volatile int moveCount;
|
||||||
volatile bool stopRequest;
|
volatile bool stopRequest;
|
||||||
volatile int slaves[MAX_THREADS];
|
volatile int slaves[MAX_THREADS];
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue