mirror of
https://github.com/sockspls/badfish
synced 2025-04-30 00:33:09 +00:00
Retire SearchStack sstack[] from SplitPoint
Use a local variable instead. To make it work we need to correctly init next ply search stack at the beginning of the search because now that ss is allocated on the stack instead of on the global storage it contains garbage. As a side effect we can peform a fast search stack init in id_loop(). With this patch size of SplitPoint goes from 71944 to 136 bytes, and consequently size of Thread goes from 575568 to 1104 bytes. Finally the size of ThreadsManager that contains all the thread info goes from 9209248 to just 17824 bytes !! No functional change also in faked split. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
parent
932ae761c6
commit
823a5918e7
2 changed files with 11 additions and 10 deletions
|
@ -611,7 +611,7 @@ namespace {
|
|||
// Initialize FIXME move before Rml.init()
|
||||
TT.new_search();
|
||||
H.clear();
|
||||
memset(ss, 0, PLY_MAX_PLUS_2 * sizeof(SearchStack));
|
||||
memset(ss, 0, 4 * sizeof(SearchStack));
|
||||
*ponderMove = bestMove = easyMove = MOVE_NONE;
|
||||
depth = aspirationDelta = 0;
|
||||
ss->currentMove = MOVE_NULL; // Hack to skip update_gains()
|
||||
|
@ -801,7 +801,8 @@ namespace {
|
|||
bestValue = alpha;
|
||||
|
||||
// Step 1. Initialize node and poll. Polling can abort search
|
||||
ss->currentMove = ss->bestMove = threatMove = MOVE_NONE;
|
||||
ss->currentMove = ss->bestMove = threatMove = (ss+1)->excludedMove = MOVE_NONE;
|
||||
(ss+1)->skipNullMove = false; (ss+1)->reduction = DEPTH_ZERO;
|
||||
(ss+2)->killers[0] = (ss+2)->killers[1] = (ss+2)->mateKiller = MOVE_NONE;
|
||||
|
||||
if (threadID == 0 && ++NodesSincePoll > NodesBetweenPolls)
|
||||
|
@ -2109,16 +2110,19 @@ split_point_start: // At split points actual search starts from here
|
|||
|
||||
threads[threadID].state = THREAD_SEARCHING;
|
||||
|
||||
// Here we call search() with SplitPoint template parameter set to true
|
||||
// Copy SplitPoint position and search stack and call search()
|
||||
// with SplitPoint template parameter set to true.
|
||||
SearchStack ss[PLY_MAX_PLUS_2];
|
||||
SplitPoint* tsp = threads[threadID].splitPoint;
|
||||
Position pos(*tsp->pos, threadID);
|
||||
SearchStack* ss = tsp->sstack[threadID] + 1;
|
||||
ss->sp = tsp;
|
||||
|
||||
memcpy(ss, tsp->parentSstack - 1, 4 * sizeof(SearchStack));
|
||||
(ss+1)->sp = tsp;
|
||||
|
||||
if (tsp->pvNode)
|
||||
search<PV, true, false>(pos, ss, tsp->alpha, tsp->beta, tsp->depth, tsp->ply);
|
||||
search<PV, true, false>(pos, ss+1, tsp->alpha, tsp->beta, tsp->depth, tsp->ply);
|
||||
else
|
||||
search<NonPV, true, false>(pos, ss, tsp->alpha, tsp->beta, tsp->depth, tsp->ply);
|
||||
search<NonPV, true, false>(pos, ss+1, tsp->alpha, tsp->beta, tsp->depth, tsp->ply);
|
||||
|
||||
assert(threads[threadID].state == THREAD_SEARCHING);
|
||||
|
||||
|
@ -2394,8 +2398,6 @@ split_point_start: // At split points actual search starts from here
|
|||
for (i = 0; i < activeThreads; i++)
|
||||
if (i == master || splitPoint.slaves[i])
|
||||
{
|
||||
memcpy(splitPoint.sstack[i], ss - 1, 4 * sizeof(SearchStack));
|
||||
|
||||
assert(i == master || threads[i].state == THREAD_BOOKED);
|
||||
|
||||
threads[i].state = THREAD_WORKISWAITING; // This makes the slave to exit from idle_loop()
|
||||
|
|
|
@ -57,7 +57,6 @@ struct SplitPoint {
|
|||
int ply;
|
||||
int master;
|
||||
Move threatMove;
|
||||
SearchStack sstack[MAX_THREADS][PLY_MAX_PLUS_2];
|
||||
|
||||
// Const pointers to shared data
|
||||
MovePicker* mp;
|
||||
|
|
Loading…
Add table
Reference in a new issue