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-21 11:09:28 +01:00
committed by Disservin
parent e407a4f269
commit e3660b47bd
2 changed files with 15 additions and 1 deletions
+14 -1
View File
@@ -287,12 +287,18 @@ namespace {
template<size_t N> template<size_t N>
struct DebugInfo { 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) { [[nodiscard]] constexpr std::atomic<int64_t>& operator[](size_t index) {
assert(index < N); assert(index < N);
return data[index]; 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> { 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 // Used to serialize access to std::cout
// to avoid multiple threads writing at the same time. // to avoid multiple threads writing at the same time.
+1
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_extremes_of(int64_t value, int slot = 0);
void dbg_correl_of(int64_t value1, int64_t value2, int slot = 0); void dbg_correl_of(int64_t value1, int64_t value2, int slot = 0);
void dbg_print(); void dbg_print();
void dbg_clear();
using TimePoint = std::chrono::milliseconds::rep; // A value in milliseconds using TimePoint = std::chrono::milliseconds::rep; // A value in milliseconds
static_assert(sizeof(TimePoint) == sizeof(int64_t), "TimePoint should be 64 bits"); static_assert(sizeof(TimePoint) == sizeof(int64_t), "TimePoint should be 64 bits");