File tree Expand file tree Collapse file tree 4 files changed +11
-11
lines changed
Expand file tree Collapse file tree 4 files changed +11
-11
lines changed Original file line number Diff line number Diff line change @@ -237,8 +237,10 @@ void prefetch(char* addr) {
237237
238238# if defined(__INTEL_COMPILER) || defined(_MSC_VER)
239239 _mm_prefetch (addr, _MM_HINT_T0);
240+ _mm_prefetch (addr+64 , _MM_HINT_T0); // 64 bytes ahead
240241# else
241242 __builtin_prefetch (addr);
243+ __builtin_prefetch (addr+64 );
242244# endif
243245}
244246
Original file line number Diff line number Diff line change @@ -39,18 +39,18 @@ void TranspositionTable::set_size(size_t mbSize) {
3939 if (hashMask == size - ClusterSize)
4040 return ;
4141
42- free (mem);
43- mem = malloc (size * sizeof (TTEntry) + (CACHE_LINE_SIZE - 1 ));
44- if (!mem)
42+ hashMask = size - ClusterSize;
43+ delete [] table;
44+ table = new (std::nothrow) TTEntry[size];
45+
46+ if (!table)
4547 {
4648 std::cerr << " Failed to allocate " << mbSize
4749 << " MB for transposition table." << std::endl;
4850 exit (EXIT_FAILURE);
4951 }
5052
51- table = (TTEntry*)((size_t (mem) + CACHE_LINE_SIZE - 1 ) & ~(CACHE_LINE_SIZE - 1 ));
52- hashMask = size - ClusterSize;
53- clear (); // Newly allocated block of memory is not initialized
53+ clear (); // Operator new is not guaranteed to initialize memory to zero
5454}
5555
5656
Original file line number Diff line number Diff line change @@ -85,7 +85,7 @@ class TranspositionTable {
8585 static const unsigned ClusterSize = 4 ; // A cluster is 64 Bytes
8686
8787public:
88- ~TranspositionTable () { free (mem) ; }
88+ ~TranspositionTable () { delete [] table ; }
8989 void new_search () { generation++; }
9090
9191 TTEntry* probe (const Key key) const ;
@@ -98,7 +98,6 @@ class TranspositionTable {
9898private:
9999 uint32_t hashMask;
100100 TTEntry* table;
101- void * mem;
102101 uint8_t generation; // Size must be not bigger then TTEntry::generation8
103102};
104103
Original file line number Diff line number Diff line change 5656# include < xmmintrin.h> // Intel and Microsoft header for _mm_prefetch()
5757# endif
5858
59- #define CACHE_LINE_SIZE 64
6059#if defined(_MSC_VER) || defined(__INTEL_COMPILER)
61- # define CACHE_LINE_ALIGNMENT __declspec (align(CACHE_LINE_SIZE ))
60+ # define CACHE_LINE_ALIGNMENT __declspec (align(64 ))
6261#else
63- # define CACHE_LINE_ALIGNMENT __attribute__ ((aligned(CACHE_LINE_SIZE )))
62+ # define CACHE_LINE_ALIGNMENT __attribute__ ((aligned(64 )))
6463#endif
6564
6665#if defined(_MSC_VER)
You can’t perform that action at this time.
0 commit comments