summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
7b4c985)
After increasing the number of threads, the histories were not cleared,
resulting in uninitialized memory usage.
This patch fixes this by clearing threads histories in Thread c'tor as
is the idomatic way.
This fixes issue 1227
No functional change.
int FutilityMoveCounts[2][16]; // [improving][depth]
int Reductions[2][2][64][64]; // [pv][improving][depth][moveNumber]
int FutilityMoveCounts[2][16]; // [improving][depth]
int Reductions[2][2][64][64]; // [pv][improving][depth][moveNumber]
- // Threshold used for countermoves based pruning
- const int CounterMovePruneThreshold = 0;
-
template <bool PvNode> Depth reduction(bool i, Depth d, int mn) {
return Reductions[PvNode][i][std::min(d / ONE_PLY, 63)][std::min(mn, 63)] * ONE_PLY;
}
template <bool PvNode> Depth reduction(bool i, Depth d, int mn) {
return Reductions[PvNode][i][std::min(d / ONE_PLY, 63)][std::min(mn, 63)] * ONE_PLY;
}
TT.clear();
for (Thread* th : Threads)
TT.clear();
for (Thread* th : Threads)
- {
- th->counterMoves.fill(MOVE_NONE);
- th->mainHistory.fill(0);
-
- for (auto& to : th->contHistory)
- for (auto& h : to)
- h.fill(0);
-
- th->contHistory[NO_PIECE][0].fill(CounterMovePruneThreshold - 1);
- }
Threads.main()->callsCnt = 0;
Threads.main()->previousScore = VALUE_INFINITE;
Threads.main()->callsCnt = 0;
Threads.main()->previousScore = VALUE_INFINITE;
+/// Threshold used for countermoves based pruning
+const int CounterMovePruneThreshold = 0;
+
+
/// Stack struct keeps track of the information we need to remember from nodes
/// shallower and deeper in the tree during the search. Each search thread has
/// its own array of Stack objects, indexed by the current ply.
/// Stack struct keeps track of the information we need to remember from nodes
/// shallower and deeper in the tree during the search. Each search thread has
/// its own array of Stack objects, indexed by the current ply.
Thread::Thread(size_t n) : idx(n), stdThread(&Thread::idle_loop, this) {
wait_for_search_finished();
Thread::Thread(size_t n) : idx(n), stdThread(&Thread::idle_loop, this) {
wait_for_search_finished();
+ clear(); // Zero-init histories (based on std::array)
+/// Thread::clear() reset histories, usually before a new game
+
+void Thread::clear() {
+
+ counterMoves.fill(MOVE_NONE);
+ mainHistory.fill(0);
+
+ for (auto& to : contHistory)
+ for (auto& h : to)
+ h.fill(0);
+
+ contHistory[NO_PIECE][0].fill(Search::CounterMovePruneThreshold - 1);
+}
+
/// Thread::start_searching() wakes up the thread that will start the search
void Thread::start_searching() {
/// Thread::start_searching() wakes up the thread that will start the search
void Thread::start_searching() {
explicit Thread(size_t);
virtual ~Thread();
virtual void search();
explicit Thread(size_t);
virtual ~Thread();
virtual void search();
void idle_loop();
void start_searching();
void wait_for_search_finished();
void idle_loop();
void start_searching();
void wait_for_search_finished();