From 7ed3ab41dc729bbd3177675c8f2ac50ffed7e5d7 Mon Sep 17 00:00:00 2001 From: Mark Jeffrey Date: Sat, 21 May 2016 14:43:31 -0400 Subject: [PATCH 1/2] [coherence_ctrls] Label const methods as such --- src/coherence_ctrls.cpp | 2 +- src/coherence_ctrls.h | 22 +++++++++++----------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/coherence_ctrls.cpp b/src/coherence_ctrls.cpp index 426f80a35..f6276411a 100644 --- a/src/coherence_ctrls.cpp +++ b/src/coherence_ctrls.cpp @@ -31,7 +31,7 @@ * should probably have a class that deals with this with a real hash function * (TODO) */ -uint32_t MESIBottomCC::getParentId(Address lineAddr) { +uint32_t MESIBottomCC::getParentId(Address lineAddr) const { //Hash things a bit uint32_t res = 0; uint64_t tmp = lineAddr; diff --git a/src/coherence_ctrls.h b/src/coherence_ctrls.h index 2d2a1d026..e986edc20 100644 --- a/src/coherence_ctrls.h +++ b/src/coherence_ctrls.h @@ -57,8 +57,8 @@ class CC : public GlobAlloc { virtual uint64_t processInv(const InvReq& req, int32_t lineId, uint64_t startCycle) = 0; //Repl policy interface - virtual uint32_t numSharers(uint32_t lineId) = 0; - virtual bool isValid(uint32_t lineId) = 0; + virtual uint32_t numSharers(uint32_t lineId) const = 0; + virtual bool isValid(uint32_t lineId) const = 0; }; @@ -163,14 +163,14 @@ class MESIBottomCC : public GlobAlloc { } /* Replacement policy query interface */ - inline bool isValid(uint32_t lineId) { + inline bool isValid(uint32_t lineId) const { return array[lineId] != I; } //Could extend with isExclusive, isDirty, etc, but not needed for now. private: - uint32_t getParentId(Address lineAddr); + uint32_t getParentId(Address lineAddr) const; }; @@ -188,11 +188,11 @@ class MESITopCC : public GlobAlloc { sharers.reset(); } - bool isEmpty() { + bool isEmpty() const { return numSharers == 0; } - bool isExclusive() { + bool isExclusive() const { return (numSharers == 1) && (exclusive); } }; @@ -236,7 +236,7 @@ class MESITopCC : public GlobAlloc { } /* Replacement policy query interface */ - inline uint32_t numSharers(uint32_t lineId) { + inline uint32_t numSharers(uint32_t lineId) const { return array[lineId].numSharers; } @@ -403,8 +403,8 @@ class MESICC : public CC { } //Repl policy interface - uint32_t numSharers(uint32_t lineId) {return tcc->numSharers(lineId);} - bool isValid(uint32_t lineId) {return bcc->isValid(lineId);} + uint32_t numSharers(uint32_t lineId) const {return tcc->numSharers(lineId);} + bool isValid(uint32_t lineId) const {return bcc->isValid(lineId);} }; // Terminal CC, i.e., without children --- accepts GETS/X, but not PUTS/X @@ -491,8 +491,8 @@ class MESITerminalCC : public CC { } //Repl policy interface - uint32_t numSharers(uint32_t lineId) {return 0;} //no sharers - bool isValid(uint32_t lineId) {return bcc->isValid(lineId);} + uint32_t numSharers(uint32_t lineId) const {return 0;} //no sharers + bool isValid(uint32_t lineId) const {return bcc->isValid(lineId);} }; #endif // COHERENCE_CTRLS_H_ From 911e167a6412f624227132b79b08a98dd519e953 Mon Sep 17 00:00:00 2001 From: Mark Jeffrey Date: Sat, 21 May 2016 14:52:49 -0400 Subject: [PATCH 2/2] [memory] Make MemObject::getName a const method --- src/cache.cpp | 2 +- src/cache.h | 2 +- src/ddr_mem.h | 2 +- src/detailed_mem.h | 2 +- src/dramsim_mem_ctrl.h | 4 ++-- src/mem_ctrls.h | 4 ++-- src/memory_hierarchy.h | 2 +- src/prefetcher.h | 2 +- src/trace_driver.h | 2 +- 9 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/cache.cpp b/src/cache.cpp index 315e6bf29..5474df0bc 100644 --- a/src/cache.cpp +++ b/src/cache.cpp @@ -33,7 +33,7 @@ Cache::Cache(uint32_t _numLines, CC* _cc, CacheArray* _array, ReplPolicy* _rp, uint32_t _accLat, uint32_t _invLat, const g_string& _name) : cc(_cc), array(_array), rp(_rp), numLines(_numLines), accLat(_accLat), invLat(_invLat), name(_name) {} -const char* Cache::getName() { +const char* Cache::getName() const { return name.c_str(); } diff --git a/src/cache.h b/src/cache.h index cf2fcef6a..639ba5720 100644 --- a/src/cache.h +++ b/src/cache.h @@ -58,7 +58,7 @@ class Cache : public BaseCache { public: Cache(uint32_t _numLines, CC* _cc, CacheArray* _array, ReplPolicy* _rp, uint32_t _accLat, uint32_t _invLat, const g_string& _name); - const char* getName(); + const char* getName() const; void setParents(uint32_t _childId, const g_vector& parents, Network* network); void setChildren(const g_vector& children, Network* network); void initStats(AggregateStat* parentStat); diff --git a/src/ddr_mem.h b/src/ddr_mem.h index 1268a2ee7..4a4cdf854 100644 --- a/src/ddr_mem.h +++ b/src/ddr_mem.h @@ -264,7 +264,7 @@ class DDRMemory : public MemObject { uint32_t _domain, g_string& _name); void initStats(AggregateStat* parentStat); - const char* getName() {return name.c_str();} + const char* getName() const {return name.c_str();} // Bound phase interface uint64_t access(MemReq& req); diff --git a/src/detailed_mem.h b/src/detailed_mem.h index caced27f1..0ec6f27ce 100644 --- a/src/detailed_mem.h +++ b/src/detailed_mem.h @@ -320,7 +320,7 @@ class MemControllerBase : public MemObject { MemControllerBase(g_string _memCfg, uint32_t _cacheLineSize, uint32_t _sysFreqMHz, uint32_t _domain, g_string& _name); virtual ~MemControllerBase(); - const char* getName() { return name.c_str(); } + const char* getName() const { return name.c_str(); } void enqueue(MemAccessEventBase* ev, uint64_t cycle); uint64_t access(MemReq& req); uint32_t tick(uint64_t sysCycle); diff --git a/src/dramsim_mem_ctrl.h b/src/dramsim_mem_ctrl.h index 49ef96858..7a96891d7 100644 --- a/src/dramsim_mem_ctrl.h +++ b/src/dramsim_mem_ctrl.h @@ -63,7 +63,7 @@ class DRAMSimMemory : public MemObject { //one DRAMSim controller DRAMSimMemory(std::string& dramTechIni, std::string& dramSystemIni, std::string& outputDir, std::string& traceName, uint32_t capacityMB, uint64_t cpuFreqHz, uint32_t _minLatency, uint32_t _domain, const g_string& _name); - const char* getName() {return name.c_str();} + const char* getName() const {return name.c_str();} void initStats(AggregateStat* parentStat); @@ -99,7 +99,7 @@ class SplitAddrMemory : public MemObject { return respCycle; } - const char* getName() { + const char* getName() const { return name.c_str(); } diff --git a/src/mem_ctrls.h b/src/mem_ctrls.h index 641e626ee..996174ed6 100644 --- a/src/mem_ctrls.h +++ b/src/mem_ctrls.h @@ -40,7 +40,7 @@ class SimpleMemory : public MemObject { public: uint64_t access(MemReq& req); - const char* getName() {return name.c_str();} + const char* getName() const {return name.c_str();} SimpleMemory(uint32_t _latency, g_string& _name) : name(_name), latency(_latency) {} }; @@ -91,7 +91,7 @@ class MD1Memory : public MemObject { //uint32_t access(Address lineAddr, AccessType type, uint32_t childId, MESIState* state /*both input and output*/, MESIState initialState, lock_t* childLock); uint64_t access(MemReq& req); - const char* getName() {return name.c_str();} + const char* getName() const {return name.c_str();} private: void updateLatency(); diff --git a/src/memory_hierarchy.h b/src/memory_hierarchy.h index a399bf692..3d2fae740 100644 --- a/src/memory_hierarchy.h +++ b/src/memory_hierarchy.h @@ -125,7 +125,7 @@ class MemObject : public GlobAlloc { //Returns response cycle virtual uint64_t access(MemReq& req) = 0; virtual void initStats(AggregateStat* parentStat) {} - virtual const char* getName() = 0; + virtual const char* getName() const = 0; }; /* Base class for all cache objects */ diff --git a/src/prefetcher.h b/src/prefetcher.h index 18a9c30f4..6475024ac 100644 --- a/src/prefetcher.h +++ b/src/prefetcher.h @@ -105,7 +105,7 @@ class StreamPrefetcher : public BaseCache { public: explicit StreamPrefetcher(const g_string& _name) : timestamp(0), name(_name) {} void initStats(AggregateStat* parentStat); - const char* getName() { return name.c_str();} + const char* getName() const { return name.c_str();} void setParents(uint32_t _childId, const g_vector& parents, Network* network); void setChildren(const g_vector& children, Network* network); diff --git a/src/trace_driver.h b/src/trace_driver.h index f0e081e56..87f92f0c2 100644 --- a/src/trace_driver.h +++ b/src/trace_driver.h @@ -87,7 +87,7 @@ class TraceDriverProxyCache : public BaseCache { MemObject* parent; public: TraceDriverProxyCache(g_string& _name) : drv(nullptr), id(-1), name(_name) {} - const char* getName() {return name.c_str();} + const char* getName() const {return name.c_str();} void setParents(uint32_t _childId, const g_vector& parents, Network* network) {id = _childId; assert(parents.size() == 1); parent = parents[0];}; //FIXME: Support multi-banked caches... void setChildren(const g_vector& children, Network* network) {panic("Should not be called, this must be terminal");};