diff options
author | Daniel R. Carvalho <odanrc@yahoo.com.br> | 2018-11-14 12:04:38 +0100 |
---|---|---|
committer | Daniel Carvalho <odanrc@yahoo.com.br> | 2018-11-14 21:02:08 +0000 |
commit | d8bc7899a97b85600e2e7ba12f2aec3d42fefc66 (patch) | |
tree | 1056a0061212c7dc712cdfb01289b4c1760c92b5 /src/mem/cache | |
parent | c6e0d8f54f1ce90933f95a7a3a875fed53b8ee3e (diff) | |
download | gem5-d8bc7899a97b85600e2e7ba12f2aec3d42fefc66.tar.xz |
mem-cache: Remove Cache dependency from Tags
Tags do not need to be aware of caches.
Change-Id: Ib6a082b74dcd9b2f10852651634b59512732fb2a
Signed-off-by: Daniel R. Carvalho <odanrc@yahoo.com.br>
Reviewed-on: https://gem5-review.googlesource.com/c/14296
Reviewed-by: Nikos Nikoleris <nikos.nikoleris@arm.com>
Maintainer: Nikos Nikoleris <nikos.nikoleris@arm.com>
Diffstat (limited to 'src/mem/cache')
-rw-r--r-- | src/mem/cache/base.cc | 2 | ||||
-rw-r--r-- | src/mem/cache/tags/Tags.py | 4 | ||||
-rw-r--r-- | src/mem/cache/tags/base.cc | 22 | ||||
-rw-r--r-- | src/mem/cache/tags/base.hh | 21 | ||||
-rw-r--r-- | src/mem/cache/tags/base_set_assoc.cc | 5 | ||||
-rw-r--r-- | src/mem/cache/tags/base_set_assoc.hh | 6 | ||||
-rw-r--r-- | src/mem/cache/tags/fa_lru.cc | 5 | ||||
-rw-r--r-- | src/mem/cache/tags/fa_lru.hh | 6 | ||||
-rw-r--r-- | src/mem/cache/tags/sector_tags.cc | 5 | ||||
-rw-r--r-- | src/mem/cache/tags/sector_tags.hh | 6 |
10 files changed, 28 insertions, 54 deletions
diff --git a/src/mem/cache/base.cc b/src/mem/cache/base.cc index 980aa91f8..497f75c88 100644 --- a/src/mem/cache/base.cc +++ b/src/mem/cache/base.cc @@ -118,7 +118,7 @@ BaseCache::BaseCache(const BaseCacheParams *p, unsigned blk_size) tempBlock = new TempCacheBlk(blkSize); - tags->tagsInit(this); + tags->tagsInit(); if (prefetcher) prefetcher->setCache(this); } diff --git a/src/mem/cache/tags/Tags.py b/src/mem/cache/tags/Tags.py index b34779eef..f2658f4f8 100644 --- a/src/mem/cache/tags/Tags.py +++ b/src/mem/cache/tags/Tags.py @@ -44,6 +44,10 @@ class BaseTags(ClockedObject): type = 'BaseTags' abstract = True cxx_header = "mem/cache/tags/base.hh" + + # Get system to which it belongs + system = Param.System(Parent.any, "System we belong to") + # Get the size from the parent (cache) size = Param.MemorySize(Parent.size, "capacity in bytes") diff --git a/src/mem/cache/tags/base.cc b/src/mem/cache/tags/base.cc index 5fbbdc194..7237f1821 100644 --- a/src/mem/cache/tags/base.cc +++ b/src/mem/cache/tags/base.cc @@ -51,7 +51,6 @@ #include <cassert> #include "base/types.hh" -#include "mem/cache/base.hh" #include "mem/cache/replacement_policies/replaceable_entry.hh" #include "mem/cache/tags/indexing_policies/base.hh" #include "mem/request.hh" @@ -62,20 +61,13 @@ BaseTags::BaseTags(const Params *p) : ClockedObject(p), blkSize(p->block_size), blkMask(blkSize - 1), size(p->size), lookupLatency(p->tag_latency), - cache(nullptr), indexingPolicy(p->indexing_policy), + system(p->system), indexingPolicy(p->indexing_policy), warmupBound((p->warmup_percentage/100.0) * (p->size / p->block_size)), warmedUp(false), numBlocks(p->size / p->block_size), dataBlks(new uint8_t[p->size]) // Allocate data storage in one big chunk { } -void -BaseTags::setCache(BaseCache *_cache) -{ - assert(!cache); - cache = _cache; -} - ReplaceableEntry* BaseTags::findBlockBySetAndWay(int set, int way) const { @@ -115,7 +107,7 @@ BaseTags::insertBlock(const Addr addr, const bool is_secure, // Previous block, if existed, has been removed, and now we have // to insert the new one // Deal with what we are bringing in - assert(src_master_ID < cache->system->maxMasters()); + assert(src_master_ID < system->maxMasters()); occupancies[src_master_ID]++; // Insert block with tag, src master id and task id @@ -243,13 +235,13 @@ BaseTags::regStats() ; occupancies - .init(cache->system->maxMasters()) + .init(system->maxMasters()) .name(name() + ".occ_blocks") .desc("Average occupied blocks per requestor") .flags(nozero | nonan) ; - for (int i = 0; i < cache->system->maxMasters(); i++) { - occupancies.subname(i, cache->system->getMasterName(i)); + for (int i = 0; i < system->maxMasters(); i++) { + occupancies.subname(i, system->getMasterName(i)); } avgOccs @@ -257,8 +249,8 @@ BaseTags::regStats() .desc("Average percentage of cache occupancy") .flags(nozero | total) ; - for (int i = 0; i < cache->system->maxMasters(); i++) { - avgOccs.subname(i, cache->system->getMasterName(i)); + for (int i = 0; i < system->maxMasters(); i++) { + avgOccs.subname(i, system->getMasterName(i)); } avgOccs = occupancies / Stats::constant(numBlocks); diff --git a/src/mem/cache/tags/base.hh b/src/mem/cache/tags/base.hh index 273abf5dc..840193b7a 100644 --- a/src/mem/cache/tags/base.hh +++ b/src/mem/cache/tags/base.hh @@ -61,7 +61,7 @@ #include "params/BaseTags.hh" #include "sim/clocked_object.hh" -class BaseCache; +class System; class IndexingPolicy; class ReplaceableEntry; @@ -80,8 +80,8 @@ class BaseTags : public ClockedObject /** The tag lookup latency of the cache. */ const Cycles lookupLatency; - /** Pointer to the parent cache. */ - BaseCache *cache; + /** System we are currently operating in. */ + System *system; /** Indexing policy */ BaseIndexingPolicy *indexingPolicy; @@ -153,13 +153,6 @@ 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); @@ -170,11 +163,11 @@ class BaseTags : public ClockedObject virtual ~BaseTags() {} /** - * Initialize blocks and set the parent cache back pointer. - * - * @param _cache Pointer to parent cache. + * Initialize blocks. Must be overriden by every subclass that uses + * a block type different from its parent's, as the current Python + * code generation does not allow templates. */ - virtual void tagsInit(BaseCache *_cache) = 0; + virtual void tagsInit() = 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 b3b773106..1b53ef050 100644 --- a/src/mem/cache/tags/base_set_assoc.cc +++ b/src/mem/cache/tags/base_set_assoc.cc @@ -63,11 +63,8 @@ BaseSetAssoc::BaseSetAssoc(const Params *p) } void -BaseSetAssoc::tagsInit(BaseCache* cache) +BaseSetAssoc::tagsInit() { - // Set parent cache - setCache(cache); - // Initialize all blocks for (unsigned blk_index = 0; blk_index < numBlocks; blk_index++) { // Locate next cache block diff --git a/src/mem/cache/tags/base_set_assoc.hh b/src/mem/cache/tags/base_set_assoc.hh index bc98afa5e..b1fa88464 100644 --- a/src/mem/cache/tags/base_set_assoc.hh +++ b/src/mem/cache/tags/base_set_assoc.hh @@ -99,11 +99,9 @@ class BaseSetAssoc : public BaseTags virtual ~BaseSetAssoc() {}; /** - * Initialize blocks and set the parent cache back pointer. - * - * @param _cache Pointer to parent cache. + * Initialize blocks as CacheBlk instances. */ - void tagsInit(BaseCache *_cache) override; + void tagsInit() override; /** * This function updates the tags when a block is invalidated. It also diff --git a/src/mem/cache/tags/fa_lru.cc b/src/mem/cache/tags/fa_lru.cc index 964846871..b1f9bbc92 100644 --- a/src/mem/cache/tags/fa_lru.cc +++ b/src/mem/cache/tags/fa_lru.cc @@ -84,11 +84,8 @@ FALRU::~FALRU() } void -FALRU::tagsInit(BaseCache* cache) +FALRU::tagsInit() { - // Set parent cache - setCache(cache); - head = &(blks[0]); head->prev = nullptr; head->next = &(blks[1]); diff --git a/src/mem/cache/tags/fa_lru.hh b/src/mem/cache/tags/fa_lru.hh index 1de6de400..0cae1dea6 100644 --- a/src/mem/cache/tags/fa_lru.hh +++ b/src/mem/cache/tags/fa_lru.hh @@ -159,11 +159,9 @@ class FALRU : public BaseTags ~FALRU(); /** - * Initialize blocks and set the parent cache back pointer. - * - * @param _cache Pointer to parent cache. + * Initialize blocks as FALRUBlk instances. */ - void tagsInit(BaseCache *_cache) override; + void tagsInit() override; /** * Register the stats for this object. diff --git a/src/mem/cache/tags/sector_tags.cc b/src/mem/cache/tags/sector_tags.cc index 02649cc40..68440c2f2 100644 --- a/src/mem/cache/tags/sector_tags.cc +++ b/src/mem/cache/tags/sector_tags.cc @@ -64,11 +64,8 @@ SectorTags::SectorTags(const SectorTagsParams *p) } void -SectorTags::tagsInit(BaseCache* cache) +SectorTags::tagsInit() { - // Set parent cache - setCache(cache); - // Initialize all blocks unsigned blk_index = 0; // index into blks array for (unsigned sec_blk_index = 0; sec_blk_index < numSectors; diff --git a/src/mem/cache/tags/sector_tags.hh b/src/mem/cache/tags/sector_tags.hh index f9d47f3c4..e3c0fa447 100644 --- a/src/mem/cache/tags/sector_tags.hh +++ b/src/mem/cache/tags/sector_tags.hh @@ -101,11 +101,9 @@ class SectorTags : public BaseTags virtual ~SectorTags() {}; /** - * Initialize blocks and set the parent cache back pointer. - * - * @param _cache Pointer to parent cache. + * Initialize blocks as SectorBlk and SectorSubBlk instances. */ - void tagsInit(BaseCache *_cache) override; + void tagsInit() override; /** * This function updates the tags when a block is invalidated but does |