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>
This commit is contained in:
committed by
Daniel Carvalho
parent
c6e0d8f54f
commit
d8bc7899a9
2
src/mem/cache/base.cc
vendored
2
src/mem/cache/base.cc
vendored
@@ -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);
|
||||
}
|
||||
|
||||
4
src/mem/cache/tags/Tags.py
vendored
4
src/mem/cache/tags/Tags.py
vendored
@@ -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")
|
||||
|
||||
|
||||
22
src/mem/cache/tags/base.cc
vendored
22
src/mem/cache/tags/base.cc
vendored
@@ -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);
|
||||
|
||||
21
src/mem/cache/tags/base.hh
vendored
21
src/mem/cache/tags/base.hh
vendored
@@ -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.
|
||||
|
||||
5
src/mem/cache/tags/base_set_assoc.cc
vendored
5
src/mem/cache/tags/base_set_assoc.cc
vendored
@@ -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
|
||||
|
||||
6
src/mem/cache/tags/base_set_assoc.hh
vendored
6
src/mem/cache/tags/base_set_assoc.hh
vendored
@@ -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
|
||||
|
||||
5
src/mem/cache/tags/fa_lru.cc
vendored
5
src/mem/cache/tags/fa_lru.cc
vendored
@@ -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]);
|
||||
|
||||
6
src/mem/cache/tags/fa_lru.hh
vendored
6
src/mem/cache/tags/fa_lru.hh
vendored
@@ -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.
|
||||
|
||||
5
src/mem/cache/tags/sector_tags.cc
vendored
5
src/mem/cache/tags/sector_tags.cc
vendored
@@ -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;
|
||||
|
||||
6
src/mem/cache/tags/sector_tags.hh
vendored
6
src/mem/cache/tags/sector_tags.hh
vendored
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user