mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-19 00:26:33 +08:00
Reuse 5 slots instead of 4
But this time with the guarantee of an always aligned access so that prefetching is not adversely impacted. On Joona PC 1+0, 64Mb hash: Orig - Mod: 174 - 237 - 359 Instead after 1000 games at 1+0 with 128MB hash size we are at + 1 ELO (just 4 games of difference). Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
11
src/tt.cpp
11
src/tt.cpp
@@ -33,9 +33,6 @@
|
||||
#include <xmmintrin.h>
|
||||
#endif
|
||||
|
||||
// This is the number of TTEntry slots for each position
|
||||
static const int ClusterSize = 4;
|
||||
|
||||
// The main transposition table
|
||||
TranspositionTable TT;
|
||||
|
||||
@@ -67,14 +64,14 @@ void TranspositionTable::set_size(unsigned mbSize) {
|
||||
|
||||
// We store a cluster of ClusterSize number of TTEntry for each position
|
||||
// and newSize is the maximum number of storable positions.
|
||||
while ((2 * newSize) * ClusterSize * (sizeof(TTEntry)) <= (mbSize << 20))
|
||||
while ((2 * newSize) * sizeof(TTCluster) <= (mbSize << 20))
|
||||
newSize *= 2;
|
||||
|
||||
if (newSize != size)
|
||||
{
|
||||
size = newSize;
|
||||
delete [] entries;
|
||||
entries = new TTEntry[size * ClusterSize];
|
||||
entries = new TTCluster[size];
|
||||
if (!entries)
|
||||
{
|
||||
std::cerr << "Failed to allocate " << mbSize
|
||||
@@ -93,7 +90,7 @@ void TranspositionTable::set_size(unsigned mbSize) {
|
||||
|
||||
void TranspositionTable::clear() {
|
||||
|
||||
memset(entries, 0, size * ClusterSize * sizeof(TTEntry));
|
||||
memset(entries, 0, size * sizeof(TTCluster));
|
||||
}
|
||||
|
||||
|
||||
@@ -103,7 +100,7 @@ void TranspositionTable::clear() {
|
||||
|
||||
inline TTEntry* TranspositionTable::first_entry(const Key posKey) const {
|
||||
|
||||
return entries + ((uint32_t(posKey) & (size - 1)) * ClusterSize);
|
||||
return entries[uint32_t(posKey) & (size - 1)].data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user