From 04399d90c589c154cbc89530d9ccb78a5cbf1eb5 Mon Sep 17 00:00:00 2001 From: Wei Song Date: Tue, 3 Dec 2024 15:46:29 +0800 Subject: [PATCH] let regression report replace prio --- cache/cache.hpp | 6 ++--- cache/dynamic_random.hpp | 2 +- cache/exclusive.hpp | 18 +++++++++----- cache/memory.hpp | 4 +-- regression | 2 +- util/monitor.hpp | 54 ++++++++++++++++++++-------------------- 6 files changed, 46 insertions(+), 40 deletions(-) diff --git a/cache/cache.hpp b/cache/cache.hpp index e6c4721..ac201b5 100644 --- a/cache/cache.hpp +++ b/cache/cache.hpp @@ -335,7 +335,7 @@ class CacheSkewed : public CacheBase } virtual void hook_read(uint64_t addr, uint32_t ai, uint32_t s, uint32_t w, bool hit, const CMMetadataBase * meta, const CMDataBase *data, uint64_t *delay) override { - if constexpr (EnMon || !C_VOID) monitors->hook_read(addr, ai, s, w, hit, meta, data, delay); + if constexpr (EnMon || !C_VOID) monitors->hook_read(addr, ai, s, w, (ai < P ? replacer[ai].eviction_rank(s, w) : -1), hit, meta, data, delay); } virtual void replace_read(uint32_t ai, uint32_t s, uint32_t w, bool prefetch, bool genre = false) override { @@ -343,7 +343,7 @@ class CacheSkewed : public CacheBase } virtual void hook_write(uint64_t addr, uint32_t ai, uint32_t s, uint32_t w, bool hit, const CMMetadataBase * meta, const CMDataBase *data, uint64_t *delay) override { - if constexpr (EnMon || !C_VOID) monitors->hook_write(addr, ai, s, w, hit, meta, data, delay); + if constexpr (EnMon || !C_VOID) monitors->hook_write(addr, ai, s, w, (ai < P ? replacer[ai].eviction_rank(s, w) : -1), hit, meta, data, delay); } virtual void replace_write(uint32_t ai, uint32_t s, uint32_t w, bool demand_acc, bool genre = false) override { @@ -351,7 +351,7 @@ class CacheSkewed : public CacheBase } virtual void hook_manage(uint64_t addr, uint32_t ai, uint32_t s, uint32_t w, bool hit, uint32_t evict, bool writeback, const CMMetadataBase * meta, const CMDataBase *data, uint64_t *delay) override { - if constexpr (EnMon || !C_VOID) monitors->hook_manage(addr, ai, s, w, hit, evict, writeback, meta, data, delay); + if constexpr (EnMon || !C_VOID) monitors->hook_manage(addr, ai, s, w, (ai < P ? replacer[ai].eviction_rank(s, w) : -1), hit, evict, writeback, meta, data, delay); } virtual void replace_manage(uint32_t ai, uint32_t s, uint32_t w, bool hit, uint32_t evict, bool genre = false) override { diff --git a/cache/dynamic_random.hpp b/cache/dynamic_random.hpp index 3fbe3cc..0662aaa 100644 --- a/cache/dynamic_random.hpp +++ b/cache/dynamic_random.hpp @@ -208,7 +208,7 @@ class SimpleEVRemapper : public RemapperBase public: SimpleEVRemapper(uint64_t period) : period(period) {} - virtual void invalid(uint64_t cache_id, uint64_t addr, int32_t ai, int32_t s, int32_t w, const CMMetadataBase *meta, const CMDataBase *data) override { + virtual void invalid(uint64_t cache_id, uint64_t addr, int32_t ai, int32_t s, int32_t w, int32_t ev_rank, const CMMetadataBase *meta, const CMDataBase *data) override { if(!active) return; cnt_invalid++; if(cnt_invalid !=0 && (cnt_invalid % period) == 0) { diff --git a/cache/exclusive.hpp b/cache/exclusive.hpp index 202a75f..5af85e0 100644 --- a/cache/exclusive.hpp +++ b/cache/exclusive.hpp @@ -129,9 +129,11 @@ class CacheSkewedExclusive : public CacheSkewed) monitors->hook_read(addr, ai, s, w, hit, meta, data, delay); + if constexpr (EnMon || !C_VOID) monitors->hook_read(addr, ai, s, w, + (w >= NW ? ext_replacer[ai].eviction_rank(s, w-NW) : replacer[ai].eviction_rank(s, w)), + hit, meta, data, delay); } else { - if constexpr (EnMon || !C_VOID) monitors->hook_read(addr, -1, -1, -1, hit, meta, data, delay); + if constexpr (EnMon || !C_VOID) monitors->hook_read(addr, -1, -1, -1, -1, hit, meta, data, delay); } } @@ -144,9 +146,11 @@ class CacheSkewedExclusive : public CacheSkewed) monitors->hook_write(addr, ai, s, w, hit, meta, data, delay); + if constexpr (EnMon || !C_VOID) monitors->hook_write(addr, ai, s, w, + (w >= NW ? ext_replacer[ai].eviction_rank(s, w-NW) : replacer[ai].eviction_rank(s, w)), + hit, meta, data, delay); } else { - if constexpr (EnMon || !C_VOID) monitors->hook_write(addr, -1, -1, -1, hit, meta, data, delay); + if constexpr (EnMon || !C_VOID) monitors->hook_write(addr, -1, -1, -1, -1, hit, meta, data, delay); } } @@ -159,9 +163,11 @@ class CacheSkewedExclusive : public CacheSkewed) monitors->hook_manage(addr, ai, s, w, hit, evict, writeback, meta, data, delay); + if constexpr (EnMon || !C_VOID) monitors->hook_manage(addr, ai, s, w, + (w >= NW ? ext_replacer[ai].eviction_rank(s, w-NW) : replacer[ai].eviction_rank(s, w)), + hit, evict, writeback, meta, data, delay); } else { - if constexpr (EnMon || !C_VOID) monitors->hook_manage(addr, -1, -1, -1, hit, evict, writeback, meta, data, delay); + if constexpr (EnMon || !C_VOID) monitors->hook_manage(addr, -1, -1, -1, -1, hit, evict, writeback, meta, data, delay); } } diff --git a/cache/memory.hpp b/cache/memory.hpp index f2fc5a7..e01eea8 100644 --- a/cache/memory.hpp +++ b/cache/memory.hpp @@ -131,11 +131,11 @@ class SimpleMemoryModel : public InnerCohPortUncached, publ void detach_monitor() { monitors->detach_monitor(); } virtual void hook_read(uint64_t addr, uint32_t ai, uint32_t s, uint32_t w, bool hit, const CMMetadataBase *meta, const CMDataBase *data, uint64_t *delay) override { - if constexpr (EnMon || !C_VOID) monitors->hook_read(addr, -1, -1, -1, hit, meta, data, delay); + if constexpr (EnMon || !C_VOID) monitors->hook_read(addr, -1, -1, -1, -1, hit, meta, data, delay); } virtual void hook_write(uint64_t addr, uint32_t ai, uint32_t s, uint32_t w, bool hit, const CMMetadataBase *meta, const CMDataBase *data, uint64_t *delay) override { - if constexpr (EnMon || !C_VOID) monitors->hook_write(addr, -1, -1, -1, hit, meta, data, delay); + if constexpr (EnMon || !C_VOID) monitors->hook_write(addr, -1, -1, -1, -1, hit, meta, data, delay); } private: diff --git a/regression b/regression index 5ad4256..ecff453 160000 --- a/regression +++ b/regression @@ -1 +1 @@ -Subproject commit 5ad4256db8a82a62fecf7127f4eca7d08db7184d +Subproject commit ecff453eb315676f4e804ba861c06783539ff675 diff --git a/util/monitor.hpp b/util/monitor.hpp index 8a57d32..a8c906a 100644 --- a/util/monitor.hpp +++ b/util/monitor.hpp @@ -25,9 +25,9 @@ class MonitorBase // standard functions to supprt a type of monitoring virtual bool attach(uint64_t cache_id) = 0; // decide whether to attach the mointor to this cache - virtual void read(uint64_t cache_id, uint64_t addr, int32_t ai, int32_t s, int32_t w, bool hit, const CMMetadataBase *meta, const CMDataBase *data) = 0; - virtual void write(uint64_t cache_id, uint64_t addr, int32_t ai, int32_t s, int32_t w, bool hit, const CMMetadataBase *meta, const CMDataBase *data) = 0; - virtual void invalid(uint64_t cache_id, uint64_t addr, int32_t ai, int32_t s, int32_t w, const CMMetadataBase *meta, const CMDataBase *data) = 0; + virtual void read(uint64_t cache_id, uint64_t addr, int32_t ai, int32_t s, int32_t w, int32_t ev_rank, bool hit, const CMMetadataBase *meta, const CMDataBase *data) = 0; + virtual void write(uint64_t cache_id, uint64_t addr, int32_t ai, int32_t s, int32_t w, int32_t ev_rank, bool hit, const CMMetadataBase *meta, const CMDataBase *data) = 0; + virtual void invalid(uint64_t cache_id, uint64_t addr, int32_t ai, int32_t s, int32_t w, int32_t ev_rank, const CMMetadataBase *meta, const CMDataBase *data) = 0; virtual bool magic_func(uint64_t cache_id, uint64_t addr, uint64_t magic_id, void *magic_data) { return false; } // a special function to log non-standard information to a special monitor // control @@ -56,9 +56,9 @@ class MonitorContainerBase // support run-time assign/reassign mointors void detach_monitor() { monitors.clear(); } - virtual void hook_read(uint64_t addr, int32_t ai, int32_t s, int32_t w, bool hit, const CMMetadataBase *meta, const CMDataBase *data, uint64_t *delay, unsigned int genre = 0) = 0; - virtual void hook_write(uint64_t addr, int32_t ai, int32_t s, int32_t w, bool hit, const CMMetadataBase *meta, const CMDataBase *data, uint64_t *delay, unsigned int genre = 0) = 0; - virtual void hook_manage(uint64_t addr, int32_t ai, int32_t s, int32_t w, bool hit, bool evict, bool writeback, const CMMetadataBase *meta, const CMDataBase *data, uint64_t *delay, unsigned int genre = 0) = 0; + virtual void hook_read(uint64_t addr, int32_t ai, int32_t s, int32_t w, int32_t ev_rank, bool hit, const CMMetadataBase *meta, const CMDataBase *data, uint64_t *delay, unsigned int genre = 0) = 0; + virtual void hook_write(uint64_t addr, int32_t ai, int32_t s, int32_t w, int32_t ev_rank, bool hit, const CMMetadataBase *meta, const CMDataBase *data, uint64_t *delay, unsigned int genre = 0) = 0; + virtual void hook_manage(uint64_t addr, int32_t ai, int32_t s, int32_t w, int32_t ev_rank, bool hit, bool evict, bool writeback, const CMMetadataBase *meta, const CMDataBase *data, uint64_t *delay, unsigned int genre = 0) = 0; virtual void magic_func(uint64_t addr, uint64_t magic_id, void *magic_data) = 0; // an interface for special communication with a specific monitor if attached virtual void pause() = 0; virtual void resume() = 0; @@ -103,19 +103,19 @@ class CacheMonitorImp : public MonitorContainerBase } } - virtual void hook_read(uint64_t addr, int32_t ai, int32_t s, int32_t w, bool hit, const CMMetadataBase *meta, const CMDataBase *data, uint64_t *delay, unsigned int genre = 0) override { - if constexpr (EnMon) for(auto m:monitors) m->read(id, addr, ai, s, w, hit, meta, data); + virtual void hook_read(uint64_t addr, int32_t ai, int32_t s, int32_t w, int32_t ev_rank, bool hit, const CMMetadataBase *meta, const CMDataBase *data, uint64_t *delay, unsigned int genre = 0) override { + if constexpr (EnMon) for(auto m:monitors) m->read(id, addr, ai, s, w, ev_rank, hit, meta, data); if constexpr (!C_VOID) timer->read(addr, ai, s, w, hit, delay); } - virtual void hook_write(uint64_t addr, int32_t ai, int32_t s, int32_t w, bool hit, const CMMetadataBase *meta, const CMDataBase *data, uint64_t *delay, unsigned int genre = 0) override { - if constexpr (EnMon) for(auto m:monitors) m->write(id, addr, ai, s, w, hit, meta, data); + virtual void hook_write(uint64_t addr, int32_t ai, int32_t s, int32_t w, int32_t ev_rank, bool hit, const CMMetadataBase *meta, const CMDataBase *data, uint64_t *delay, unsigned int genre = 0) override { + if constexpr (EnMon) for(auto m:monitors) m->write(id, addr, ai, s, w, ev_rank, hit, meta, data); if constexpr (!C_VOID) timer->write(addr, ai, s, w, hit, delay); } - virtual void hook_manage(uint64_t addr, int32_t ai, int32_t s, int32_t w, bool hit, bool evict, bool writeback, const CMMetadataBase *meta, const CMDataBase *data, uint64_t *delay, unsigned int genre = 0) override { + virtual void hook_manage(uint64_t addr, int32_t ai, int32_t s, int32_t w, int32_t ev_rank, bool hit, bool evict, bool writeback, const CMMetadataBase *meta, const CMDataBase *data, uint64_t *delay, unsigned int genre = 0) override { if(hit && evict) { - if constexpr (EnMon) for(auto m:monitors) m->invalid(id, addr, ai, s, w, meta, data); + if constexpr (EnMon) for(auto m:monitors) m->invalid(id, addr, ai, s, w, ev_rank, meta, data); } if constexpr (!C_VOID) timer->manage(addr, ai, s, w, hit, evict, writeback, delay); } @@ -153,13 +153,13 @@ class SimpleAccMonitor : public MonitorBase virtual bool attach(uint64_t cache_id) override { return true; } - virtual void read(uint64_t cache_id, uint64_t addr, int32_t ai, int32_t s, int32_t w, bool hit, const CMMetadataBase *meta, const CMDataBase *data) override { + virtual void read(uint64_t cache_id, uint64_t addr, int32_t ai, int32_t s, int32_t w, int32_t ev_rank, bool hit, const CMMetadataBase *meta, const CMDataBase *data) override { if(!active) return; cnt_access++; if(!hit) cnt_miss++; } - virtual void write(uint64_t cache_id, uint64_t addr, int32_t ai, int32_t s, int32_t w, bool hit, const CMMetadataBase *meta, const CMDataBase *data) override { + virtual void write(uint64_t cache_id, uint64_t addr, int32_t ai, int32_t s, int32_t w, int32_t ev_rank, bool hit, const CMMetadataBase *meta, const CMDataBase *data) override { if(!active) return; cnt_access++; cnt_write++; @@ -169,7 +169,7 @@ class SimpleAccMonitor : public MonitorBase } } - virtual void invalid(uint64_t cache_id, uint64_t addr, int32_t ai, int32_t s, int32_t w, const CMMetadataBase *meta, const CMDataBase *data) override { + virtual void invalid(uint64_t cache_id, uint64_t addr, int32_t ai, int32_t s, int32_t w, int32_t ev_rank, const CMMetadataBase *meta, const CMDataBase *data) override { if(!active) return; cnt_invalid++; } @@ -210,10 +210,10 @@ class SimpleTracer : public MonitorBase virtual bool attach(uint64_t cache_id) { return true; } - virtual void read(uint64_t cache_id, uint64_t addr, int32_t ai, int32_t s, int32_t w, bool hit, const CMMetadataBase *meta, const CMDataBase *data) override { + virtual void read(uint64_t cache_id, uint64_t addr, int32_t ai, int32_t s, int32_t w, int32_t ev_rank, bool hit, const CMMetadataBase *meta, const CMDataBase *data) override { if(!active) return; std::string msg; msg.reserve(100); - msg += (boost::format("%-10s read %016x %02d %04d %02d %1x") % UniqueID::name(cache_id) % addr % ai % s % w % hit).str(); + msg += (boost::format("%-10s read %016x %02d %04d %02d %02d %1x") % UniqueID::name(cache_id) % addr % ai % s % w % ev_rank % hit).str(); if(meta) msg.append(" [").append(meta->to_string()).append("]"); @@ -225,10 +225,10 @@ class SimpleTracer : public MonitorBase print(msg); } - virtual void write(uint64_t cache_id, uint64_t addr, int32_t ai, int32_t s, int32_t w, bool hit, const CMMetadataBase *meta, const CMDataBase *data) override { + virtual void write(uint64_t cache_id, uint64_t addr, int32_t ai, int32_t s, int32_t w, int32_t ev_rank, bool hit, const CMMetadataBase *meta, const CMDataBase *data) override { if(!active) return; std::string msg; msg.reserve(100); - msg += (boost::format("%-10s write %016x %02d %04d %02d %1x") % UniqueID::name(cache_id) % addr % ai % s % w % hit).str(); + msg += (boost::format("%-10s write %016x %02d %04d %02d %02d %1x") % UniqueID::name(cache_id) % addr % ai % s % w % ev_rank % hit).str(); if(meta) msg.append(" [").append(meta->to_string()).append("]"); @@ -240,10 +240,10 @@ class SimpleTracer : public MonitorBase print(msg); } - virtual void invalid(uint64_t cache_id, uint64_t addr, int32_t ai, int32_t s, int32_t w, const CMMetadataBase *meta, const CMDataBase *data) override { + virtual void invalid(uint64_t cache_id, uint64_t addr, int32_t ai, int32_t s, int32_t w, int32_t ev_rank, const CMMetadataBase *meta, const CMDataBase *data) override { if(!active) return; std::string msg; msg.reserve(100); - msg += (boost::format("%-10s evict %016x %02d %04d %02d ") % UniqueID::name(cache_id) % addr % ai % s % w).str() ; + msg += (boost::format("%-10s evict %016x %02d %04d %02d %02d ") % UniqueID::name(cache_id) % addr % ai % s % w % ev_rank).str() ; if(meta) msg.append(" [").append(meta->to_string()).append("]"); @@ -297,10 +297,10 @@ class AddrTracer : public MonitorBase virtual bool attach(uint64_t cache_id) override { return true; } - virtual void read(uint64_t cache_id, uint64_t addr, int32_t ai, int32_t s, int32_t w, bool hit, const CMMetadataBase *meta, const CMDataBase *data) override { + virtual void read(uint64_t cache_id, uint64_t addr, int32_t ai, int32_t s, int32_t w, int32_t ev_rank, bool hit, const CMMetadataBase *meta, const CMDataBase *data) override { if(!active || addr != target) return; std::string msg; msg.reserve(100); - msg += (boost::format("%-10s read %016x %02d %04d %02d %1x") % UniqueID::name(cache_id) % addr % ai % s % w % hit).str(); + msg += (boost::format("%-10s read %016x %02d %04d %02d %02d %1x") % UniqueID::name(cache_id) % addr % ai % s % w % ev_rank % hit).str(); if(meta) msg.append(" [").append(meta->to_string()).append("]"); @@ -313,10 +313,10 @@ class AddrTracer : public MonitorBase print(msg); } - virtual void write(uint64_t cache_id, uint64_t addr, int32_t ai, int32_t s, int32_t w, bool hit, const CMMetadataBase *meta, const CMDataBase *data) override { + virtual void write(uint64_t cache_id, uint64_t addr, int32_t ai, int32_t s, int32_t w, int32_t ev_rank, bool hit, const CMMetadataBase *meta, const CMDataBase *data) override { if(!active || target != addr) return; std::string msg; msg.reserve(100); - msg += (boost::format("%-10s write %016x %02d %04d %02d %1x") % UniqueID::name(cache_id) % addr % ai % s % w % hit).str(); + msg += (boost::format("%-10s write %016x %02d %04d %02d %02d %1x") % UniqueID::name(cache_id) % addr % ai % s % w % ev_rank % hit).str(); if(meta) msg.append(" [").append(meta->to_string()).append("]"); @@ -329,10 +329,10 @@ class AddrTracer : public MonitorBase print(msg); } - virtual void invalid(uint64_t cache_id, uint64_t addr, int32_t ai, int32_t s, int32_t w, const CMMetadataBase *meta, const CMDataBase *data) override { + virtual void invalid(uint64_t cache_id, uint64_t addr, int32_t ai, int32_t s, int32_t w, int32_t ev_rank, const CMMetadataBase *meta, const CMDataBase *data) override { if(!active || target != addr) return; std::string msg; msg.reserve(100); - msg += (boost::format("%-10s evict %016x %02d %04d %02d ") % UniqueID::name(cache_id) % addr % ai % s % w).str() ; + msg += (boost::format("%-10s evict %016x %02d %04d %02d %02d ") % UniqueID::name(cache_id) % addr % ai % s % w % ev_rank).str() ; if(meta) msg.append(" [").append(meta->to_string()).append("]");