From 293c44bc09587259818a82e1d2afb511e552badd Mon Sep 17 00:00:00 2001 From: Marco Costalba Date: Tue, 30 Apr 2013 08:08:54 +0200 Subject: [PATCH] Revert "Cache line aligned TT" This reverts commit 083fe5812485597e13943b690cc24a8f25c0d140 It seems to break Android build No functional change. --- src/misc.cpp | 2 ++ src/tt.cpp | 12 ++++++------ src/tt.h | 3 +-- src/types.h | 5 ++--- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/misc.cpp b/src/misc.cpp index 477fb392..c0c00b00 100644 --- a/src/misc.cpp +++ b/src/misc.cpp @@ -237,8 +237,10 @@ void prefetch(char* addr) { # if defined(__INTEL_COMPILER) || defined(_MSC_VER) _mm_prefetch(addr, _MM_HINT_T0); + _mm_prefetch(addr+64, _MM_HINT_T0); // 64 bytes ahead # else __builtin_prefetch(addr); + __builtin_prefetch(addr+64); # endif } diff --git a/src/tt.cpp b/src/tt.cpp index 998d7378..80ea493b 100644 --- a/src/tt.cpp +++ b/src/tt.cpp @@ -39,18 +39,18 @@ void TranspositionTable::set_size(size_t mbSize) { if (hashMask == size - ClusterSize) return; - free(mem); - mem = malloc(size * sizeof(TTEntry) + (CACHE_LINE_SIZE - 1)); - if (!mem) + hashMask = size - ClusterSize; + delete [] table; + table = new (std::nothrow) TTEntry[size]; + + if (!table) { std::cerr << "Failed to allocate " << mbSize << "MB for transposition table." << std::endl; exit(EXIT_FAILURE); } - table = (TTEntry*)((size_t(mem) + CACHE_LINE_SIZE - 1) & ~(CACHE_LINE_SIZE - 1)); - hashMask = size - ClusterSize; - clear(); // Newly allocated block of memory is not initialized + clear(); // Operator new is not guaranteed to initialize memory to zero } diff --git a/src/tt.h b/src/tt.h index 1caa277e..c7c39e90 100644 --- a/src/tt.h +++ b/src/tt.h @@ -85,7 +85,7 @@ class TranspositionTable { static const unsigned ClusterSize = 4; // A cluster is 64 Bytes public: - ~TranspositionTable() { free(mem); } + ~TranspositionTable() { delete [] table; } void new_search() { generation++; } TTEntry* probe(const Key key) const; @@ -98,7 +98,6 @@ public: private: uint32_t hashMask; TTEntry* table; - void* mem; uint8_t generation; // Size must be not bigger then TTEntry::generation8 }; diff --git a/src/types.h b/src/types.h index dae86db3..1def7d00 100644 --- a/src/types.h +++ b/src/types.h @@ -56,11 +56,10 @@ # include // Intel and Microsoft header for _mm_prefetch() # endif -#define CACHE_LINE_SIZE 64 #if defined(_MSC_VER) || defined(__INTEL_COMPILER) -# define CACHE_LINE_ALIGNMENT __declspec(align(CACHE_LINE_SIZE)) +# define CACHE_LINE_ALIGNMENT __declspec(align(64)) #else -# define CACHE_LINE_ALIGNMENT __attribute__ ((aligned(CACHE_LINE_SIZE))) +# define CACHE_LINE_ALIGNMENT __attribute__ ((aligned(64))) #endif #if defined(_MSC_VER) -- 2.39.2