X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fevaluate.cpp;h=25451da5211aef741986626c52552a5a2d7fdff9;hp=e9feba06fe42a31b3b48979a0844aff19664ff23;hb=633c83f648893979999b57383cb84534b81c8506;hpb=bd33766da0a00d9df69afcbf31a75d5f9972f1c8 diff --git a/src/evaluate.cpp b/src/evaluate.cpp index e9feba06..25451da5 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -233,7 +233,9 @@ namespace { }; // Pawn and material hash tables, indexed by the current thread id. - // Note that they will be initialized at 0 being global variables. + // We use per-thread tables so that once we get a pointer to an entry + // its life time is unlimited and we don't have to care about someone + // changing the entry under our feet. MaterialInfoTable* MaterialTable[MAX_THREADS]; PawnInfoTable* PawnTable[MAX_THREADS]; @@ -269,16 +271,13 @@ namespace { } -//// -//// Functions -//// - +/// prefetchTables() is called in do_move() to prefetch pawn and material +/// hash tables data that will be needed shortly after in evaluation. -/// Prefetches in pawn hash tables +void prefetchTables(Key pKey, Key mKey, int threadID) { -void prefetchPawn(Key key, int threadID) { - - PawnTable[threadID]->prefetch(key); + PawnTable[threadID]->prefetch(pKey); + MaterialTable[threadID]->prefetch(mKey); } @@ -1159,9 +1158,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)); }