]> git.sesse.net Git - stockfish/blobdiff - src/tt.cpp
Another take at TT alignment
[stockfish] / src / tt.cpp
index 271b98b74009eaf8f7e5e6601c5225c33a5be7f5..c6b294a00cad8fd5aeb1eae1bf673b53b3f4026a 100644 (file)
@@ -50,8 +50,7 @@ void TranspositionTable::set_size(size_t mbSize) {
       exit(EXIT_FAILURE);
   }
 
-  // Align table start address to a cache line
-  for (char* c = (char*)mem; unsigned(table = (TTEntry*)(c)) % CACHE_LINE_SIZE; c++) {}
+  table = (TTEntry*)((uintptr_t(mem) + CACHE_LINE_SIZE - 1) & ~(CACHE_LINE_SIZE - 1));
   clear(); // Operator new is not guaranteed to initialize memory to zero
 }