Skip to content

Commit

Permalink
Bench: 22158564
Browse files Browse the repository at this point in the history
  • Loading branch information
TerjeKir committed Nov 15, 2024
1 parent 083a4df commit 17c140b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
9 changes: 5 additions & 4 deletions src/transposition.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ TTEntry* ProbeTT(const Key key, bool *ttHit) {
TTEntry* first = GetTTBucket(key)->entries;

for (TTEntry *entry = first; entry < first + BUCKET_SIZE; ++entry)
if (entry->key == (int32_t)key || !Bound(entry)) {
if (entry->key == (int32_t)key || EntryEmpty(entry)) {
entry->genBound = TT.generation | Bound(entry);
return *ttHit = Bound(entry), entry;
return *ttHit = !EntryEmpty(entry), entry;
}

TTEntry *replace = first;
Expand Down Expand Up @@ -77,8 +77,8 @@ int HashFull() {

for (TTBucket *bucket = TT.table; bucket < TT.table + 1000; ++bucket)
for (TTEntry *entry = bucket->entries; entry < bucket->entries + BUCKET_SIZE; ++entry)
used += ( Bound(entry) != 0
&& Generation(entry) == TT.generation);
if (!EntryEmpty(entry) && Generation(entry) == TT.generation)
used += 1;

return used / BUCKET_SIZE;
}
Expand Down Expand Up @@ -106,6 +106,7 @@ static void *ThreadClearTT(void *voidThread) {
void ClearTT() {
if (!TT.dirty) return;
RunWithAllThreads(ThreadClearTT);
TT.generation = 0;
TT.dirty = false;
}

Expand Down
3 changes: 2 additions & 1 deletion src/transposition.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ INLINE uint8_t Bound(TTEntry *entry) { return entry->genBound & TT_BOUND_MA
INLINE uint8_t Generation(TTEntry *entry) { return entry->genBound & TT_GEN_MASK; }
INLINE uint8_t Age(TTEntry *entry) { return (TT_GEN_CYCLE + TT.generation - entry->genBound) & TT_GEN_MASK; }

INLINE int EntryValue(TTEntry *entry) { return entry->depth - Age(entry); }
INLINE int EntryValue(TTEntry *entry) { return entry->depth - Age(entry); }
INLINE bool EntryEmpty(TTEntry *entry) { return Bound(entry) == BOUND_NONE; }

// Store terminal scores as distance from the current position to mate/TB
INLINE int ScoreToTT (const int score, const uint8_t ply) {
Expand Down

0 comments on commit 17c140b

Please sign in to comment.