X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fevaluate.cpp;h=649842dc87384f568b390e497649f5c62fba6195;hp=86b37e3b045a63ae92ebe1b962d132f770b55555;hb=1d0159075e916c738760b788d605b71b3736cb7c;hpb=6738b65be97af10e4b5b783dc8ad21ae0faf36a8 diff --git a/src/evaluate.cpp b/src/evaluate.cpp index 86b37e3b..649842dc 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -232,11 +232,6 @@ namespace { PASSED = 12, UNSTOPPABLE = 13, SPACE = 14, TOTAL = 15 }; - // Pawn and material hash tables, indexed by the current thread id. - // Note that they will be initialized at 0 being global variables. - MaterialInfoTable* MaterialTable[MAX_THREADS]; - PawnInfoTable* PawnTable[MAX_THREADS]; - // Function prototypes template Value do_evaluate(const Position& pos, Value& margin); @@ -269,16 +264,6 @@ namespace { } -/// prefetchTables() is called in do_move() to prefetch pawn and material -/// hash tables data that will be needed shortly after in evaluation. - -void prefetchTables(Key pKey, Key mKey, int threadID) { - - PawnTable[threadID]->prefetch(pKey); - MaterialTable[threadID]->prefetch(mKey); -} - - /// evaluate() is the main evaluation function. It always computes two /// values, an endgame score and a middle game score, and interpolates /// between them based on the remaining material. @@ -318,7 +303,7 @@ Value do_evaluate(const Position& pos, Value& margin) { margins[WHITE] = margins[BLACK] = VALUE_ZERO; // Probe the material hash table - MaterialInfo* mi = MaterialTable[pos.thread()]->get_material_info(pos); + MaterialInfo* mi = Threads[pos.thread()].materialTable.get_material_info(pos); bonus += mi->material_value(); // If we have a specialized evaluation function for the current material @@ -330,7 +315,7 @@ Value do_evaluate(const Position& pos, Value& margin) { } // Probe the pawn hash table - ei.pi = PawnTable[pos.thread()]->get_pawn_info(pos); + ei.pi = Threads[pos.thread()].pawnTable.get_pawn_info(pos); bonus += apply_weight(ei.pi->pawns_value(), Weights[PawnStructure]); // Initialize attack and king safety bitboards @@ -431,39 +416,6 @@ Value do_evaluate(const Position& pos, Value& margin) { } // namespace -/// init_eval() initializes various tables used by the evaluation function - -void init_eval(int threads) { - - assert(threads <= MAX_THREADS); - - for (int i = 0; i < MAX_THREADS; i++) - { - if (i >= threads) - { - delete PawnTable[i]; - delete MaterialTable[i]; - PawnTable[i] = NULL; - MaterialTable[i] = NULL; - continue; - } - if (!PawnTable[i]) - PawnTable[i] = new PawnInfoTable(); - - if (!MaterialTable[i]) - MaterialTable[i] = new MaterialInfoTable(); - } -} - - -/// quit_eval() releases heap-allocated memory at program termination - -void quit_eval() { - - init_eval(0); -} - - /// read_weights() reads evaluation weights from the corresponding UCI parameters void read_evaluation_uci_options(Color us) { @@ -1156,9 +1108,7 @@ namespace { assert(eg_value(v) > -VALUE_INFINITE && eg_value(v) < VALUE_INFINITE); assert(ph >= PHASE_ENDGAME && ph <= PHASE_MIDGAME); - Value eg = eg_value(v); - Value ev = Value((eg * int(sf)) / SCALE_FACTOR_NORMAL); - + int ev = (eg_value(v) * int(sf)) / SCALE_FACTOR_NORMAL; int result = (mg_value(v) * int(ph) + ev * int(128 - ph)) / 128; return Value((result + GrainSize / 2) & ~(GrainSize - 1)); }