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>
tempBlock = new TempCacheBlk(blkSize);
- tags->tagsInit(this);
+ tags->tagsInit();
if (prefetcher)
prefetcher->setCache(this);
}
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")
#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"
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
{
// 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
;
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
.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);
#include "params/BaseTags.hh"
#include "sim/clocked_object.hh"
-class BaseCache;
+class System;
class IndexingPolicy;
class ReplaceableEntry;
/** 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;
* @}
*/
- /**
- * Set the parent cache back pointer.
- *
- * @param _cache Pointer to parent cache.
- */
- void setCache(BaseCache *_cache);
-
public:
typedef BaseTagsParams Params;
BaseTags(const Params *p);
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.
}
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
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
}
void
-FALRU::tagsInit(BaseCache* cache)
+FALRU::tagsInit()
{
- // Set parent cache
- setCache(cache);
-
head = &(blks[0]);
head->prev = nullptr;
head->next = &(blks[1]);
~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.
}
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;
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