mirror of
https://github.com/sockspls/badfish
synced 2025-04-30 16:53:09 +00:00
Do not copy master position in split()
A pointer is enough because after a split point has been setup master and slaves thread end up calling sp_search() or sp_search_pv() and here a full copy of split point position is done again, note that even master does another copy (of itself) and this is done before any do_move() call so that master Position is never updated between split() and sp_search(). Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
parent
c2df60048e
commit
0ff91e16da
4 changed files with 8 additions and 13 deletions
|
@ -147,8 +147,8 @@ public:
|
||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
Position();
|
Position();
|
||||||
Position(const Position& pos);
|
explicit Position(const Position& pos);
|
||||||
Position(const std::string& fen);
|
explicit Position(const std::string& fen);
|
||||||
|
|
||||||
// Text input/output
|
// Text input/output
|
||||||
void from_fen(const std::string& fen);
|
void from_fen(const std::string& fen);
|
||||||
|
|
|
@ -1813,8 +1813,7 @@ namespace {
|
||||||
assert(threadID >= 0 && threadID < ActiveThreads);
|
assert(threadID >= 0 && threadID < ActiveThreads);
|
||||||
assert(ActiveThreads > 1);
|
assert(ActiveThreads > 1);
|
||||||
|
|
||||||
Position pos;
|
Position pos(*sp->pos);
|
||||||
pos.fast_copy(sp->pos);
|
|
||||||
CheckInfo ci(pos);
|
CheckInfo ci(pos);
|
||||||
SearchStack* ss = sp->sstack[threadID];
|
SearchStack* ss = sp->sstack[threadID];
|
||||||
Value value = -VALUE_INFINITE;
|
Value value = -VALUE_INFINITE;
|
||||||
|
@ -1956,8 +1955,7 @@ namespace {
|
||||||
assert(threadID >= 0 && threadID < ActiveThreads);
|
assert(threadID >= 0 && threadID < ActiveThreads);
|
||||||
assert(ActiveThreads > 1);
|
assert(ActiveThreads > 1);
|
||||||
|
|
||||||
Position pos;
|
Position pos(*sp->pos);
|
||||||
pos.fast_copy(sp->pos);
|
|
||||||
CheckInfo ci(pos);
|
CheckInfo ci(pos);
|
||||||
SearchStack* ss = sp->sstack[threadID];
|
SearchStack* ss = sp->sstack[threadID];
|
||||||
Value value = -VALUE_INFINITE;
|
Value value = -VALUE_INFINITE;
|
||||||
|
@ -2969,7 +2967,7 @@ namespace {
|
||||||
splitPoint = SplitPointStack[master] + Threads[master].activeSplitPoints;
|
splitPoint = SplitPointStack[master] + Threads[master].activeSplitPoints;
|
||||||
Threads[master].activeSplitPoints++;
|
Threads[master].activeSplitPoints++;
|
||||||
|
|
||||||
// Initialize the split point object and copy current position
|
// Initialize the split point object
|
||||||
splitPoint->parent = Threads[master].splitPoint;
|
splitPoint->parent = Threads[master].splitPoint;
|
||||||
splitPoint->finished = false;
|
splitPoint->finished = false;
|
||||||
splitPoint->ply = ply;
|
splitPoint->ply = ply;
|
||||||
|
@ -2983,14 +2981,11 @@ namespace {
|
||||||
splitPoint->mp = mp;
|
splitPoint->mp = mp;
|
||||||
splitPoint->moves = *moves;
|
splitPoint->moves = *moves;
|
||||||
splitPoint->cpus = 1;
|
splitPoint->cpus = 1;
|
||||||
splitPoint->pos.fast_copy(p);
|
splitPoint->pos = &p;
|
||||||
splitPoint->parentSstack = sstck;
|
splitPoint->parentSstack = sstck;
|
||||||
for (i = 0; i < ActiveThreads; i++)
|
for (i = 0; i < ActiveThreads; i++)
|
||||||
splitPoint->slaves[i] = 0;
|
splitPoint->slaves[i] = 0;
|
||||||
|
|
||||||
// Detach splitPoint Position from the master one
|
|
||||||
splitPoint->pos.detach();
|
|
||||||
|
|
||||||
// Copy the tail of current search stack to the master thread
|
// Copy the tail of current search stack to the master thread
|
||||||
memcpy(splitPoint->sstack[master] + ply - 1, sstck + ply - 1, 3 * sizeof(SearchStack));
|
memcpy(splitPoint->sstack[master] + ply - 1, sstck + ply - 1, 3 * sizeof(SearchStack));
|
||||||
Threads[master].splitPoint = splitPoint;
|
Threads[master].splitPoint = splitPoint;
|
||||||
|
|
|
@ -46,7 +46,7 @@ const int ACTIVE_SPLIT_POINTS_MAX = 8;
|
||||||
|
|
||||||
struct SplitPoint {
|
struct SplitPoint {
|
||||||
SplitPoint *parent;
|
SplitPoint *parent;
|
||||||
Position pos;
|
const Position* pos;
|
||||||
SearchStack sstack[THREAD_MAX][PLY_MAX_PLUS_2];
|
SearchStack sstack[THREAD_MAX][PLY_MAX_PLUS_2];
|
||||||
SearchStack *parentSstack;
|
SearchStack *parentSstack;
|
||||||
int ply;
|
int ply;
|
||||||
|
|
|
@ -314,7 +314,7 @@ namespace {
|
||||||
|
|
||||||
string token;
|
string token;
|
||||||
int depth, tm, n;
|
int depth, tm, n;
|
||||||
Position pos = RootPosition;
|
Position pos(RootPosition);
|
||||||
|
|
||||||
if (!(uip >> depth))
|
if (!(uip >> depth))
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Add table
Reference in a new issue