From 8e45e70e55c42c4750ccb729dcd49cdaafe5af44 Mon Sep 17 00:00:00 2001 From: ajithcj Date: Fri, 10 Jun 2016 18:10:40 +0000 Subject: [PATCH] Don't insert pv back into tt This code was added before the accurate pv patch, when we retrieved PV directly from TT. It's not required for correct (and long) PVs any more and should be safe to remove it. Also, allowing helper threads to repeatedly over-write TT doesn't seem to make sense(that was probably an un-intended side-effect of lazy smp). Before Lazy SMP only Main Thread used to run ID loop and insert PV into TT. STC: LLR: 2.96 (-2.94,2.94) [-3.00,1.00] Total: 74346 W: 13946 L: 13918 D: 46482 LTC LLR: 2.95 (-2.94,2.94) [-3.00,1.00] Total: 47265 W: 6531 L: 6447 D: 34287 bench: 8819179 --- src/search.cpp | 32 -------------------------------- src/search.h | 1 - 2 files changed, 33 deletions(-) diff --git a/src/search.cpp b/src/search.cpp index 995204f3..0b4125fc 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -413,11 +413,6 @@ void Thread::search() { // search the already searched PV lines are preserved. std::stable_sort(rootMoves.begin() + PVIdx, rootMoves.end()); - // Write PV back to the transposition table in case the relevant - // entries have been overwritten during the search. - for (size_t i = 0; i <= PVIdx; ++i) - rootMoves[i].insert_pv_in_tt(rootPos); - // If search has been stopped, break immediately. Sorting and // writing PV back to TT is safe because RootMoves is still // valid, although it refers to the previous iteration. @@ -1564,33 +1559,6 @@ string UCI::pv(const Position& pos, Depth depth, Value alpha, Value beta) { } -/// RootMove::insert_pv_in_tt() is called at the end of a search iteration, and -/// inserts the PV back into the TT. This makes sure the old PV moves are searched -/// first, even if the old TT entries have been overwritten. - -void RootMove::insert_pv_in_tt(Position& pos) { - - StateInfo state[MAX_PLY], *st = state; - bool ttHit; - - for (Move m : pv) - { - assert(MoveList(pos).contains(m)); - - TTEntry* tte = TT.probe(pos.key(), ttHit); - - if (!ttHit || tte->move() != m) // Don't overwrite correct entries - tte->save(pos.key(), VALUE_NONE, BOUND_NONE, DEPTH_NONE, - m, VALUE_NONE, TT.generation()); - - pos.do_move(m, *st++, pos.gives_check(m, CheckInfo(pos))); - } - - for (size_t i = pv.size(); i > 0; ) - pos.undo_move(pv[--i]); -} - - /// RootMove::extract_ponder_from_tt() is called in case we have no ponder move /// before exiting the search, for instance, in case we stop the search during a /// fail high at root. We try hard to have a ponder move to return to the GUI, diff --git a/src/search.h b/src/search.h index 73d8cdfa..599d058f 100644 --- a/src/search.h +++ b/src/search.h @@ -59,7 +59,6 @@ struct RootMove { bool operator<(const RootMove& m) const { return m.score < score; } // Descending sort bool operator==(const Move& m) const { return pv[0] == m; } - void insert_pv_in_tt(Position& pos); bool extract_ponder_from_tt(Position& pos); Value score = -VALUE_INFINITE; -- 2.39.2