122 lines
4.8 KiB
C
122 lines
4.8 KiB
C
|
|
// warm_pool_dbg_box.h
|
||
|
|
// Box: Debug-only counters for C7 Warm Pool instrumentation.
|
||
|
|
#pragma once
|
||
|
|
|
||
|
|
#include <stdatomic.h>
|
||
|
|
#include <stdint.h>
|
||
|
|
|
||
|
|
#if !HAKMEM_BUILD_RELEASE
|
||
|
|
#ifdef WARM_POOL_DBG_DEFINE
|
||
|
|
_Atomic uint64_t g_dbg_c7_warm_pop_attempts = 0;
|
||
|
|
_Atomic uint64_t g_dbg_c7_warm_pop_hits = 0;
|
||
|
|
_Atomic uint64_t g_dbg_c7_warm_pop_carve = 0;
|
||
|
|
_Atomic uint64_t g_dbg_c7_tls_carve_attempts = 0;
|
||
|
|
_Atomic uint64_t g_dbg_c7_tls_carve_success = 0;
|
||
|
|
_Atomic uint64_t g_dbg_c7_tls_carve_fail = 0;
|
||
|
|
_Atomic uint64_t g_dbg_c7_uc_miss_warm_refill = 0;
|
||
|
|
_Atomic uint64_t g_dbg_c7_uc_miss_tls_refill = 0;
|
||
|
|
_Atomic uint64_t g_dbg_c7_uc_miss_shared_refill = 0;
|
||
|
|
#else
|
||
|
|
extern _Atomic uint64_t g_dbg_c7_warm_pop_attempts;
|
||
|
|
extern _Atomic uint64_t g_dbg_c7_warm_pop_hits;
|
||
|
|
extern _Atomic uint64_t g_dbg_c7_warm_pop_carve;
|
||
|
|
extern _Atomic uint64_t g_dbg_c7_tls_carve_attempts;
|
||
|
|
extern _Atomic uint64_t g_dbg_c7_tls_carve_success;
|
||
|
|
extern _Atomic uint64_t g_dbg_c7_tls_carve_fail;
|
||
|
|
extern _Atomic uint64_t g_dbg_c7_uc_miss_warm_refill;
|
||
|
|
extern _Atomic uint64_t g_dbg_c7_uc_miss_tls_refill;
|
||
|
|
extern _Atomic uint64_t g_dbg_c7_uc_miss_shared_refill;
|
||
|
|
#endif
|
||
|
|
|
||
|
|
static inline void warm_pool_dbg_c7_attempt(void) {
|
||
|
|
atomic_fetch_add_explicit(&g_dbg_c7_warm_pop_attempts, 1, memory_order_relaxed);
|
||
|
|
}
|
||
|
|
|
||
|
|
static inline void warm_pool_dbg_c7_hit(void) {
|
||
|
|
atomic_fetch_add_explicit(&g_dbg_c7_warm_pop_hits, 1, memory_order_relaxed);
|
||
|
|
}
|
||
|
|
|
||
|
|
static inline void warm_pool_dbg_c7_carve(void) {
|
||
|
|
atomic_fetch_add_explicit(&g_dbg_c7_warm_pop_carve, 1, memory_order_relaxed);
|
||
|
|
}
|
||
|
|
|
||
|
|
static inline void warm_pool_dbg_c7_tls_attempt(void) {
|
||
|
|
atomic_fetch_add_explicit(&g_dbg_c7_tls_carve_attempts, 1, memory_order_relaxed);
|
||
|
|
}
|
||
|
|
|
||
|
|
static inline void warm_pool_dbg_c7_tls_success(void) {
|
||
|
|
atomic_fetch_add_explicit(&g_dbg_c7_tls_carve_success, 1, memory_order_relaxed);
|
||
|
|
}
|
||
|
|
|
||
|
|
static inline void warm_pool_dbg_c7_tls_fail(void) {
|
||
|
|
atomic_fetch_add_explicit(&g_dbg_c7_tls_carve_fail, 1, memory_order_relaxed);
|
||
|
|
}
|
||
|
|
|
||
|
|
static inline void warm_pool_dbg_c7_uc_miss_warm(void) {
|
||
|
|
atomic_fetch_add_explicit(&g_dbg_c7_uc_miss_warm_refill, 1, memory_order_relaxed);
|
||
|
|
}
|
||
|
|
|
||
|
|
static inline void warm_pool_dbg_c7_uc_miss_tls(void) {
|
||
|
|
atomic_fetch_add_explicit(&g_dbg_c7_uc_miss_tls_refill, 1, memory_order_relaxed);
|
||
|
|
}
|
||
|
|
|
||
|
|
static inline void warm_pool_dbg_c7_uc_miss_shared(void) {
|
||
|
|
atomic_fetch_add_explicit(&g_dbg_c7_uc_miss_shared_refill, 1, memory_order_relaxed);
|
||
|
|
}
|
||
|
|
|
||
|
|
static inline uint64_t warm_pool_dbg_c7_attempts(void) {
|
||
|
|
return atomic_load_explicit(&g_dbg_c7_warm_pop_attempts, memory_order_relaxed);
|
||
|
|
}
|
||
|
|
|
||
|
|
static inline uint64_t warm_pool_dbg_c7_hits(void) {
|
||
|
|
return atomic_load_explicit(&g_dbg_c7_warm_pop_hits, memory_order_relaxed);
|
||
|
|
}
|
||
|
|
|
||
|
|
static inline uint64_t warm_pool_dbg_c7_carves(void) {
|
||
|
|
return atomic_load_explicit(&g_dbg_c7_warm_pop_carve, memory_order_relaxed);
|
||
|
|
}
|
||
|
|
|
||
|
|
static inline uint64_t warm_pool_dbg_c7_tls_attempts(void) {
|
||
|
|
return atomic_load_explicit(&g_dbg_c7_tls_carve_attempts, memory_order_relaxed);
|
||
|
|
}
|
||
|
|
|
||
|
|
static inline uint64_t warm_pool_dbg_c7_tls_successes(void) {
|
||
|
|
return atomic_load_explicit(&g_dbg_c7_tls_carve_success, memory_order_relaxed);
|
||
|
|
}
|
||
|
|
|
||
|
|
static inline uint64_t warm_pool_dbg_c7_tls_failures(void) {
|
||
|
|
return atomic_load_explicit(&g_dbg_c7_tls_carve_fail, memory_order_relaxed);
|
||
|
|
}
|
||
|
|
|
||
|
|
static inline uint64_t warm_pool_dbg_c7_uc_miss_warm_refills(void) {
|
||
|
|
return atomic_load_explicit(&g_dbg_c7_uc_miss_warm_refill, memory_order_relaxed);
|
||
|
|
}
|
||
|
|
|
||
|
|
static inline uint64_t warm_pool_dbg_c7_uc_miss_tls_refills(void) {
|
||
|
|
return atomic_load_explicit(&g_dbg_c7_uc_miss_tls_refill, memory_order_relaxed);
|
||
|
|
}
|
||
|
|
|
||
|
|
static inline uint64_t warm_pool_dbg_c7_uc_miss_shared_refills(void) {
|
||
|
|
return atomic_load_explicit(&g_dbg_c7_uc_miss_shared_refill, memory_order_relaxed);
|
||
|
|
}
|
||
|
|
#else
|
||
|
|
static inline void warm_pool_dbg_c7_attempt(void) { }
|
||
|
|
static inline void warm_pool_dbg_c7_hit(void) { }
|
||
|
|
static inline void warm_pool_dbg_c7_carve(void) { }
|
||
|
|
static inline void warm_pool_dbg_c7_tls_attempt(void) { }
|
||
|
|
static inline void warm_pool_dbg_c7_tls_success(void) { }
|
||
|
|
static inline void warm_pool_dbg_c7_tls_fail(void) { }
|
||
|
|
static inline void warm_pool_dbg_c7_uc_miss_warm(void) { }
|
||
|
|
static inline void warm_pool_dbg_c7_uc_miss_tls(void) { }
|
||
|
|
static inline void warm_pool_dbg_c7_uc_miss_shared(void) { }
|
||
|
|
static inline uint64_t warm_pool_dbg_c7_attempts(void) { return 0; }
|
||
|
|
static inline uint64_t warm_pool_dbg_c7_hits(void) { return 0; }
|
||
|
|
static inline uint64_t warm_pool_dbg_c7_carves(void) { return 0; }
|
||
|
|
static inline uint64_t warm_pool_dbg_c7_tls_attempts(void) { return 0; }
|
||
|
|
static inline uint64_t warm_pool_dbg_c7_tls_successes(void) { return 0; }
|
||
|
|
static inline uint64_t warm_pool_dbg_c7_tls_failures(void) { return 0; }
|
||
|
|
static inline uint64_t warm_pool_dbg_c7_uc_miss_warm_refills(void) { return 0; }
|
||
|
|
static inline uint64_t warm_pool_dbg_c7_uc_miss_tls_refills(void) { return 0; }
|
||
|
|
static inline uint64_t warm_pool_dbg_c7_uc_miss_shared_refills(void) { return 0; }
|
||
|
|
#endif
|