StateInfo is usually allocated on the stack by search()

And passed in do_move(), this ensures maximum efficiency and
speed and at the same time unlimited move numbers.

The draw back is that to handle Position init we need to
reserve a StateInfo inside Position itself and use at
init time and when copying from another Position.

After lazy SMP we don't need anymore this gimmick and we can
get rid of this special case and always pass an external
StateInfo to Position object.

Also rewritten and simplified Position constructors.

Verified it does not regress with a 3 threads SMP test:
ELO: -0.00 +-12.7 (95%) LOS: 50.0%
Total: 1000 W: 173 L: 173 D: 654

No functional change.
This commit is contained in:
Marco Costalba
2016-04-11 16:45:36 +02:00
parent ee7a68ea5f
commit 7eaea3848c
12 changed files with 70 additions and 94 deletions
+2 -11
View File
@@ -40,7 +40,6 @@ namespace Search {
SignalsType Signals;
LimitsType Limits;
StateStackPtr SetupStates;
}
namespace Tablebases {
@@ -317,16 +316,8 @@ void MainThread::search() {
}
for (Thread* th : Threads)
{
th->maxPly = 0;
th->rootDepth = DEPTH_ZERO;
if (th != this)
{
th->rootPos = Position(rootPos, th);
th->rootMoves = rootMoves;
th->start_searching();
}
}
Thread::search(); // Let's start searching!
}
@@ -1488,7 +1479,7 @@ moves_loop: // When in check search starts from here
Move Skill::pick_best(size_t multiPV) {
const Search::RootMoveVector& rootMoves = Threads.main()->rootMoves;
const RootMoves& rootMoves = Threads.main()->rootMoves;
static PRNG rng(now()); // PRNG sequence should be non-deterministic
// RootMoves are already sorted by score in descending order
@@ -1553,7 +1544,7 @@ string UCI::pv(const Position& pos, Depth depth, Value alpha, Value beta) {
std::stringstream ss;
int elapsed = Time.elapsed() + 1;
const Search::RootMoveVector& rootMoves = pos.this_thread()->rootMoves;
const RootMoves& rootMoves = pos.this_thread()->rootMoves;
size_t PVIdx = pos.this_thread()->PVIdx;
size_t multiPV = std::min((size_t)Options["MultiPV"], rootMoves.size());
uint64_t nodes_searched = Threads.nodes_searched();