diff options
-rw-r--r-- | src/mem/cache/base.cc | 2 | ||||
-rw-r--r-- | src/mem/cache/tags/base.hh | 12 | ||||
-rw-r--r-- | src/mem/cache/tags/base_set_assoc.cc | 8 | ||||
-rw-r--r-- | src/mem/cache/tags/base_set_assoc.hh | 7 | ||||
-rw-r--r-- | src/mem/cache/tags/fa_lru.cc | 17 | ||||
-rw-r--r-- | src/mem/cache/tags/fa_lru.hh | 8 | ||||
-rw-r--r-- | src/mem/cache/tags/sector_tags.cc | 7 | ||||
-rw-r--r-- | src/mem/cache/tags/sector_tags.hh | 8 |
8 files changed, 61 insertions, 8 deletions
diff --git a/src/mem/cache/base.cc b/src/mem/cache/base.cc index 6c79fd683..736f16761 100644 --- a/src/mem/cache/base.cc +++ b/src/mem/cache/base.cc @@ -115,7 +115,7 @@ BaseCache::BaseCache(const BaseCacheParams *p, unsigned blk_size) tempBlock = new TempCacheBlk(blkSize); - tags->setCache(this); + tags->init(this); if (prefetcher) prefetcher->setCache(this); } diff --git a/src/mem/cache/tags/base.hh b/src/mem/cache/tags/base.hh index 30a7af72c..385d25c9f 100644 --- a/src/mem/cache/tags/base.hh +++ b/src/mem/cache/tags/base.hh @@ -154,6 +154,13 @@ class BaseTags : public ClockedObject * @} */ + /** + * Set the parent cache back pointer. + * + * @param _cache Pointer to parent cache. + */ + void setCache(BaseCache *_cache); + public: typedef BaseTagsParams Params; BaseTags(const Params *p); @@ -164,10 +171,11 @@ class BaseTags : public ClockedObject virtual ~BaseTags() {} /** - * Set the parent cache back pointer. + * Initialize blocks and set the parent cache back pointer. + * * @param _cache Pointer to parent cache. */ - void setCache(BaseCache *_cache); + virtual void init(BaseCache *_cache) = 0; /** * Register local statistics. diff --git a/src/mem/cache/tags/base_set_assoc.cc b/src/mem/cache/tags/base_set_assoc.cc index 18da53273..8bd65e03b 100644 --- a/src/mem/cache/tags/base_set_assoc.cc +++ b/src/mem/cache/tags/base_set_assoc.cc @@ -73,7 +73,15 @@ BaseSetAssoc::BaseSetAssoc(const Params *p) setShift = floorLog2(blkSize); setMask = numSets - 1; tagShift = setShift + floorLog2(numSets); +} + +void +BaseSetAssoc::init(BaseCache* cache) +{ + // Set parent cache + setCache(cache); + // Initialize blocks unsigned blkIndex = 0; // index into blks array for (unsigned i = 0; i < numSets; ++i) { sets[i].assoc = assoc; diff --git a/src/mem/cache/tags/base_set_assoc.hh b/src/mem/cache/tags/base_set_assoc.hh index dc0e04275..a3826499f 100644 --- a/src/mem/cache/tags/base_set_assoc.hh +++ b/src/mem/cache/tags/base_set_assoc.hh @@ -121,6 +121,13 @@ class BaseSetAssoc : public BaseTags virtual ~BaseSetAssoc() {}; /** + * Initialize blocks and set the parent cache back pointer. + * + * @param _cache Pointer to parent cache. + */ + void init(BaseCache *_cache) override; + + /** * This function updates the tags when a block is invalidated. It also * updates the replacement data. * diff --git a/src/mem/cache/tags/fa_lru.cc b/src/mem/cache/tags/fa_lru.cc index 1b43e9892..d35e37c7b 100644 --- a/src/mem/cache/tags/fa_lru.cc +++ b/src/mem/cache/tags/fa_lru.cc @@ -69,6 +69,18 @@ FALRU::FALRU(const Params *p) fatal("Cache Size must be power of 2 for now"); blks = new FALRUBlk[numBlocks]; +} + +FALRU::~FALRU() +{ + delete[] blks; +} + +void +FALRU::init(BaseCache* cache) +{ + // Set parent cache + setCache(cache); head = &(blks[0]); head->prev = nullptr; @@ -97,11 +109,6 @@ FALRU::FALRU(const Params *p) cacheTracking.init(head, tail); } -FALRU::~FALRU() -{ - delete[] blks; -} - void FALRU::regStats() { diff --git a/src/mem/cache/tags/fa_lru.hh b/src/mem/cache/tags/fa_lru.hh index c8ccc66f3..0d9a8d440 100644 --- a/src/mem/cache/tags/fa_lru.hh +++ b/src/mem/cache/tags/fa_lru.hh @@ -68,6 +68,7 @@ // TrackedCaches class //#define FALRU_DEBUG +class BaseCache; class ReplaceableEntry; // A bitmask of the caches we are keeping track of. Currently the @@ -151,6 +152,13 @@ class FALRU : public BaseTags ~FALRU(); /** + * Initialize blocks and set the parent cache back pointer. + * + * @param _cache Pointer to parent cache. + */ + void init(BaseCache *_cache) override; + + /** * Register the stats for this object. */ void regStats() override; diff --git a/src/mem/cache/tags/sector_tags.cc b/src/mem/cache/tags/sector_tags.cc index 76034e1ea..988fda540 100644 --- a/src/mem/cache/tags/sector_tags.cc +++ b/src/mem/cache/tags/sector_tags.cc @@ -67,6 +67,13 @@ SectorTags::SectorTags(const SectorTagsParams *p) fatal_if(!isPowerOf2(numBlocksPerSector), "# of blocks per sector must be non-zero and a power of 2"); fatal_if(assoc <= 0, "associativity must be greater than zero"); +} + +void +SectorTags::init(BaseCache* cache) +{ + // Set parent cache + setCache(cache); // Initialize all sets unsigned sec_blk_index = 0; // index into sector blks array diff --git a/src/mem/cache/tags/sector_tags.hh b/src/mem/cache/tags/sector_tags.hh index 109b9832b..7a2cddae9 100644 --- a/src/mem/cache/tags/sector_tags.hh +++ b/src/mem/cache/tags/sector_tags.hh @@ -43,6 +43,7 @@ #include "mem/cache/tags/base.hh" #include "params/SectorTags.hh" +class BaseCache; class BaseReplacementPolicy; class ReplaceableEntry; @@ -114,6 +115,13 @@ class SectorTags : public BaseTags virtual ~SectorTags() {}; /** + * Initialize blocks and set the parent cache back pointer. + * + * @param _cache Pointer to parent cache. + */ + void init(BaseCache *_cache) override; + + /** * This function updates the tags when a block is invalidated but does * not invalidate the block itself. It also updates the replacement data. * |