Add dbg_clear helper function

closes https://github.com/official-stockfish/Stockfish/pull/5921

No functional change
This commit is contained in:
Shawn Xu
2025-03-02 21:38:11 -08:00
committed by Disservin
parent e407a4f269
commit e3660b47bd
2 changed files with 15 additions and 1 deletions

View File

@@ -287,12 +287,18 @@ namespace {
template<size_t N>
struct DebugInfo {
std::atomic<int64_t> data[N] = {0};
std::array<std::atomic<int64_t>, N> data = {0};
[[nodiscard]] constexpr std::atomic<int64_t>& operator[](size_t index) {
assert(index < N);
return data[index];
}
constexpr DebugInfo& operator=(const DebugInfo& other) {
for (size_t i = 0; i < N; i++)
data[i].store(other.data[i].load());
return *this;
}
};
struct DebugExtremes: public DebugInfo<3> {
@@ -393,6 +399,13 @@ void dbg_print() {
}
}
void dbg_clear() {
hit.fill({});
mean.fill({});
stdev.fill({});
correl.fill({});
extremes.fill({});
}
// Used to serialize access to std::cout
// to avoid multiple threads writing at the same time.

View File

@@ -73,6 +73,7 @@ void dbg_stdev_of(int64_t value, int slot = 0);
void dbg_extremes_of(int64_t value, int slot = 0);
void dbg_correl_of(int64_t value1, int64_t value2, int slot = 0);
void dbg_print();
void dbg_clear();
using TimePoint = std::chrono::milliseconds::rep; // A value in milliseconds
static_assert(sizeof(TimePoint) == sizeof(int64_t), "TimePoint should be 64 bits");