]> git.sesse.net Git - stockfish/commitdiff
L1/L2 friendly PhaseTable[]
authorMarco Costalba <mcostalba@gmail.com>
Sat, 15 Aug 2009 14:18:17 +0000 (15:18 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Sat, 15 Aug 2009 15:09:10 +0000 (16:09 +0100)
In Movepicker c'tor we access during initialization one of
MainSearchPhaseIndex..QsearchWithoutChecksPhaseIndex globals.

Postpone definition of PhaseTable[] just after them so that
when PhaseTable[] will be accessed later in get_next_move()
it will be already present in L1/L2.

It works like an implicit prefetching of PhaseTable[].

Also shrink PhaseTable[] to fit an L1 cache line of 16 bytes
using uint8_t instead of int.

This apparentely innocuous patch gives an astonish speed
up of 1.6% under MSVC 2010 beta, pgo optimized !

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
src/movepick.cpp
src/types.h

index 4529af7dd73edcca6a8e887799f129e727a1099b..77c42efac8026716cd14237ddbe966a5d1bd0785 100644 (file)
@@ -42,12 +42,12 @@ namespace {
 
   /// Variables
 
-  MovePicker::MovegenPhase PhaseTable[32];
+  CACHE_LINE_ALIGNMENT
   int MainSearchPhaseIndex;
   int EvasionsPhaseIndex;
   int QsearchWithChecksPhaseIndex;
   int QsearchWithoutChecksPhaseIndex;
-
+  uint8_t PhaseTable[32];
 }
 
 
index 95e3f6eeb46c4357b297f308f63f666bb5679757..a9badca0d1027538d60628cda45d87dc593ce58c 100644 (file)
@@ -66,4 +66,11 @@ typedef uint64_t Bitboard;
 #define USE_BSFQ
 #endif
 
+// Cache line alignment specification
+#if defined(_MSC_VER) || defined(__INTEL_COMPILER)
+#define CACHE_LINE_ALIGNMENT __declspec(align(64))
+#else
+#define CACHE_LINE_ALIGNMENT  __attribute__ ((aligned(64)))
+#endif
+
 #endif // !defined(TYPES_H_INCLUDED)