Skip to content

Commit

Permalink
Merge pull request #166 from comparch-security/report-replace-prio
Browse files Browse the repository at this point in the history
let regression report replace prio
  • Loading branch information
wsong83 authored Dec 3, 2024
2 parents 0d56566 + 04399d9 commit 1312011
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 40 deletions.
6 changes: 3 additions & 3 deletions cache/cache.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,23 +335,23 @@ 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<DLY>) monitors->hook_read(addr, ai, s, w, hit, meta, data, delay);
if constexpr (EnMon || !C_VOID<DLY>) 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 {
if(ai < P) replacer[ai].access(s, w, true, prefetch);
}

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<DLY>) monitors->hook_write(addr, ai, s, w, hit, meta, data, delay);
if constexpr (EnMon || !C_VOID<DLY>) 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 {
if(ai < P) replacer[ai].access(s, w, demand_acc, false);
}

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<DLY>) monitors->hook_manage(addr, ai, s, w, hit, evict, writeback, meta, data, delay);
if constexpr (EnMon || !C_VOID<DLY>) 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 {
Expand Down
2 changes: 1 addition & 1 deletion cache/dynamic_random.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
18 changes: 12 additions & 6 deletions cache/exclusive.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,11 @@ class CacheSkewedExclusive : public CacheSkewed<IW, NW, P, MT, DT, IDX, RPC, DLY

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(ai < P) {
if constexpr (EnMon || !C_VOID<DLY>) monitors->hook_read(addr, ai, s, w, hit, meta, data, delay);
if constexpr (EnMon || !C_VOID<DLY>) 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<DLY>) monitors->hook_read(addr, -1, -1, -1, hit, meta, data, delay);
if constexpr (EnMon || !C_VOID<DLY>) monitors->hook_read(addr, -1, -1, -1, -1, hit, meta, data, delay);
}
}

Expand All @@ -144,9 +146,11 @@ class CacheSkewedExclusive : public CacheSkewed<IW, NW, P, MT, DT, IDX, RPC, DLY

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(ai < P) {
if constexpr (EnMon || !C_VOID<DLY>) monitors->hook_write(addr, ai, s, w, hit, meta, data, delay);
if constexpr (EnMon || !C_VOID<DLY>) 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<DLY>) monitors->hook_write(addr, -1, -1, -1, hit, meta, data, delay);
if constexpr (EnMon || !C_VOID<DLY>) monitors->hook_write(addr, -1, -1, -1, -1, hit, meta, data, delay);
}
}

Expand All @@ -159,9 +163,11 @@ class CacheSkewedExclusive : public CacheSkewed<IW, NW, P, MT, DT, IDX, RPC, DLY

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(ai < P){
if constexpr (EnMon || !C_VOID<DLY>) monitors->hook_manage(addr, ai, s, w, hit, evict, writeback, meta, data, delay);
if constexpr (EnMon || !C_VOID<DLY>) 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<DLY>) monitors->hook_manage(addr, -1, -1, -1, hit, evict, writeback, meta, data, delay);
if constexpr (EnMon || !C_VOID<DLY>) monitors->hook_manage(addr, -1, -1, -1, -1, hit, evict, writeback, meta, data, delay);
}
}

Expand Down
4 changes: 2 additions & 2 deletions cache/memory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,11 @@ class SimpleMemoryModel : public InnerCohPortUncached<policy_memory, EnMT>, 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<DLY>) monitors->hook_read(addr, -1, -1, -1, hit, meta, data, delay);
if constexpr (EnMon || !C_VOID<DLY>) 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<DLY>) monitors->hook_write(addr, -1, -1, -1, hit, meta, data, delay);
if constexpr (EnMon || !C_VOID<DLY>) monitors->hook_write(addr, -1, -1, -1, -1, hit, meta, data, delay);
}

private:
Expand Down
2 changes: 1 addition & 1 deletion regression
Submodule regression updated 12 files
+818 −818 c1-l1.expect
+2,126 −2,126 c2-l2-exc-mesi.expect
+1,751 −1,751 c2-l2-exc-mi.expect
+1,793 −1,793 c2-l2-exc.expect
+1,652 −1,652 c2-l2-mesi.expect
+5,332 −5,332 c2-l2-mirage.expect
+1,646 −1,646 c2-l2-remap.expect
+1,665 −1,665 c2-l2.expect
+73,932 −73,932 c4-l3-exc-mesi.expect
+57,853 −57,853 c4-l3-exc.expect
+55,925 −55,925 c4-l3-intel.expect
+68,026 −68,026 c4-l3.expect
54 changes: 27 additions & 27 deletions util/monitor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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<DLY>) 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<DLY>) 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<DLY>) timer->manage(addr, ai, s, w, hit, evict, writeback, delay);
}
Expand Down Expand Up @@ -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++;
Expand All @@ -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++;
}
Expand Down Expand Up @@ -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("]");
Expand All @@ -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("]");
Expand All @@ -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("]");
Expand Down Expand Up @@ -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("]");
Expand All @@ -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("]");
Expand All @@ -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("]");
Expand Down

0 comments on commit 1312011

Please sign in to comment.