]> git.sesse.net Git - stockfish/commitdiff
Prefetch also material tables
authorMarco Costalba <mcostalba@gmail.com>
Mon, 11 Apr 2011 07:03:34 +0000 (09:03 +0200)
committerMarco Costalba <mcostalba@gmail.com>
Mon, 11 Apr 2011 11:24:02 +0000 (12:24 +0100)
Prefetch both pawn and material tables in do_move() and
prefetch always, not only after a pawn move or a capture.

Speed up of 0,7%

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
src/evaluate.cpp
src/misc.h
src/position.cpp

index e9feba06fe42a31b3b48979a0844aff19664ff23..86b37e3b045a63ae92ebe1b962d132f770b55555 100644 (file)
@@ -269,16 +269,13 @@ namespace {
 }
 
 
-////
-//// Functions
-////
-
-
-/// Prefetches in pawn hash tables
+/// prefetchTables() is called in do_move() to prefetch pawn and material
+/// hash tables data that will be needed shortly after in evaluation.
 
-void prefetchPawn(Key key, int threadID) {
+void prefetchTables(Key pKey, Key mKey, int threadID) {
 
-    PawnTable[threadID]->prefetch(key);
+    PawnTable[threadID]->prefetch(pKey);
+    MaterialTable[threadID]->prefetch(mKey);
 }
 
 
index 0c4bd64454824c54eacfd9113a41e0ebba52825b..6c451934997ba63fd91c8cb7e7fa53571d33530a 100644 (file)
@@ -29,7 +29,7 @@ extern int get_system_time();
 extern int cpu_count();
 extern int input_available();
 extern void prefetch(char* addr);
-extern void prefetchPawn(Key, int);
+extern void prefetchTables(Key pKey, Key mKey, int threadID);
 
 // Debug functions
 extern bool dbg_show_mean;
index f4a098d988d4e1a868d36b110b77c44d195204ff..abe7fde3226692ad6fc1f0d376f0518c2d9cfb4a 100644 (file)
@@ -885,7 +885,6 @@ void Position::do_move(Move m, StateInfo& newSt, const CheckInfo& ci, bool moveI
 
       // Update pawn hash key and prefetch in L1/L2 cache
       st->pawnKey ^= zobrist[us][PAWN][from] ^ zobrist[us][PAWN][to];
-      prefetchPawn(st->pawnKey, threadID);
 
       // Set en passant square, only if moved pawn can be captured
       if ((to ^ from) == 16)
@@ -938,6 +937,9 @@ void Position::do_move(Move m, StateInfo& newSt, const CheckInfo& ci, bool moveI
       }
   }
 
+  // Prefetch pawn and material hash tables
+  prefetchTables(st->pawnKey, st->materialKey, threadID);
+
   // Update incremental scores
   st->value += pst_delta(piece, from, to);