Another take at TT alignment
authorMarco Costalba <mcostalba@gmail.com>
Thu, 2 May 2013 07:35:52 +0000 (09:35 +0200)
committerMarco Costalba <mcostalba@gmail.com>
Thu, 2 May 2013 07:38:23 +0000 (09:38 +0200)
This time revert to original version but using
uintptr_t instead of size_t

Suggested by Lucas.

No functional change.

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
 }