]> git.sesse.net Git - stockfish/commitdiff
Reduce SMP contention on TT
authorMarco Costalba <mcostalba@gmail.com>
Sat, 13 Jun 2009 10:13:09 +0000 (11:13 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Sat, 13 Jun 2009 10:13:09 +0000 (11:13 +0100)
Move TT object away from heavy write accessed NodesSincePoll
and also, inside TT isolate the heavy accessed writes variable.

No functional change.

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

index 577484a9c24b895b224b4e9103d70acad759faa9..3382e09c745183130458ca1db03506fa3345b71e 100644 (file)
@@ -189,6 +189,9 @@ namespace {
   // Remaining depth:                 1 ply         1.5 ply       2 ply         2.5 ply       3 ply         3.5 ply
   const Value RazorApprMargins[6] = { Value(0x520), Value(0x300), Value(0x300), Value(0x300), Value(0x300), Value(0x300) };
 
   // Remaining depth:                 1 ply         1.5 ply       2 ply         2.5 ply       3 ply         3.5 ply
   const Value RazorApprMargins[6] = { Value(0x520), Value(0x300), Value(0x300), Value(0x300), Value(0x300), Value(0x300) };
 
+  // The main transposition table
+  TranspositionTable TT;
+
 
   /// Variables initialized by UCI options
 
 
   /// Variables initialized by UCI options
 
@@ -268,9 +271,6 @@ namespace {
   int NodesSincePoll;
   int NodesBetweenPolls = 30000;
 
   int NodesSincePoll;
   int NodesBetweenPolls = 30000;
 
-   // The main transposition table
-   TranspositionTable TT;
-
 
   /// Functions
 
 
   /// Functions
 
index c570761bdec0fd91120fe99a28b1b18f562c7bcc..fb414bf157aeba9fa98fbe70bbb728cd27445e1e 100644 (file)
--- a/src/tt.h
+++ b/src/tt.h
@@ -92,7 +92,13 @@ public:
 private:
   inline TTEntry* first_entry(const Key posKey) const;
 
 private:
   inline TTEntry* first_entry(const Key posKey) const;
 
-  unsigned size, writes;
+  // Be sure 'writes' is at least one cacheline away
+  // from read only variables.
+  unsigned char pad_before[64 - sizeof(unsigned)];
+  unsigned writes; // heavy SMP read/write access here
+  unsigned char pad_after[64];
+
+  unsigned size;
   TTEntry* entries;
   uint8_t generation;
 };
   TTEntry* entries;
   uint8_t generation;
 };