mem-cache: Move insertBlock functionality in FALRU
Block insertion is being done in the getCandidates function, while the insertBlock function does not do anything. Besides, BaseTags' stats weren't being updated. Change-Id: Iadab9c1ea61519214f66fa24c4b91c4fc95604c0 Reviewed-on: https://gem5-review.googlesource.com/8882 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
f7c6d86009
commit
affbf2a608
48
src/mem/cache/tags/base.cc
vendored
48
src/mem/cache/tags/base.cc
vendored
@@ -75,6 +75,54 @@ BaseTags::setCache(BaseCache *_cache)
|
||||
cache = _cache;
|
||||
}
|
||||
|
||||
void
|
||||
BaseTags::insertBlock(PacketPtr pkt, CacheBlk *blk)
|
||||
{
|
||||
// Get address
|
||||
Addr addr = pkt->getAddr();
|
||||
|
||||
// Update warmup data
|
||||
if (!blk->isTouched) {
|
||||
if (!warmedUp && tagsInUse.value() >= warmupBound) {
|
||||
warmedUp = true;
|
||||
warmupCycle = curTick();
|
||||
}
|
||||
}
|
||||
|
||||
// If we're replacing a block that was previously valid update
|
||||
// stats for it. This can't be done in findBlock() because a
|
||||
// found block might not actually be replaced there if the
|
||||
// coherence protocol says it can't be.
|
||||
if (blk->isValid()) {
|
||||
replacements[0]++;
|
||||
totalRefs += blk->refCount;
|
||||
++sampledRefs;
|
||||
|
||||
invalidate(blk);
|
||||
blk->invalidate();
|
||||
}
|
||||
|
||||
// Previous block, if existed, has been removed, and now we have
|
||||
// to insert the new one
|
||||
tagsInUse++;
|
||||
|
||||
// Set tag for new block. Caller is responsible for setting status.
|
||||
blk->tag = extractTag(addr);
|
||||
|
||||
// Deal with what we are bringing in
|
||||
MasterID master_id = pkt->req->masterId();
|
||||
assert(master_id < cache->system->maxMasters());
|
||||
occupancies[master_id]++;
|
||||
blk->srcMasterId = master_id;
|
||||
|
||||
// Set task id
|
||||
blk->task_id = pkt->req->taskId();
|
||||
|
||||
// We only need to write into one tag and one data block.
|
||||
tagAccesses += 1;
|
||||
dataAccesses += 1;
|
||||
}
|
||||
|
||||
void
|
||||
BaseTags::regStats()
|
||||
{
|
||||
|
||||
8
src/mem/cache/tags/base.hh
vendored
8
src/mem/cache/tags/base.hh
vendored
@@ -265,7 +265,13 @@ class BaseTags : public ClockedObject
|
||||
|
||||
virtual Addr extractTag(Addr addr) const = 0;
|
||||
|
||||
virtual void insertBlock(PacketPtr pkt, CacheBlk *blk) = 0;
|
||||
/**
|
||||
* Insert the new block into the cache and update stats.
|
||||
*
|
||||
* @param pkt Packet holding the address to update
|
||||
* @param blk The block to update.
|
||||
*/
|
||||
virtual void insertBlock(PacketPtr pkt, CacheBlk *blk);
|
||||
|
||||
/**
|
||||
* Regenerate the block address.
|
||||
|
||||
54
src/mem/cache/tags/base_set_assoc.hh
vendored
54
src/mem/cache/tags/base_set_assoc.hh
vendored
@@ -212,55 +212,19 @@ class BaseSetAssoc : public BaseTags
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert the new block into the cache.
|
||||
* Insert the new block into the cache and update replacement data.
|
||||
*
|
||||
* @param pkt Packet holding the address to update
|
||||
* @param blk The block to update.
|
||||
*/
|
||||
void insertBlock(PacketPtr pkt, CacheBlk *blk) override
|
||||
{
|
||||
Addr addr = pkt->getAddr();
|
||||
MasterID master_id = pkt->req->masterId();
|
||||
uint32_t task_id = pkt->req->taskId();
|
||||
void insertBlock(PacketPtr pkt, CacheBlk *blk) override
|
||||
{
|
||||
// Insert block
|
||||
BaseTags::insertBlock(pkt, blk);
|
||||
|
||||
if (!blk->isTouched) {
|
||||
if (!warmedUp && tagsInUse.value() >= warmupBound) {
|
||||
warmedUp = true;
|
||||
warmupCycle = curTick();
|
||||
}
|
||||
}
|
||||
|
||||
// If we're replacing a block that was previously valid update
|
||||
// stats for it. This can't be done in findBlock() because a
|
||||
// found block might not actually be replaced there if the
|
||||
// coherence protocol says it can't be.
|
||||
if (blk->isValid()) {
|
||||
replacements[0]++;
|
||||
totalRefs += blk->refCount;
|
||||
++sampledRefs;
|
||||
|
||||
invalidate(blk);
|
||||
blk->invalidate();
|
||||
}
|
||||
|
||||
// Previous block, if existed, has been removed, and now we have
|
||||
// to insert the new one
|
||||
tagsInUse++;
|
||||
|
||||
// Set tag for new block. Caller is responsible for setting status.
|
||||
blk->tag = extractTag(addr);
|
||||
|
||||
// deal with what we are bringing in
|
||||
assert(master_id < cache->system->maxMasters());
|
||||
occupancies[master_id]++;
|
||||
blk->srcMasterId = master_id;
|
||||
blk->task_id = task_id;
|
||||
|
||||
// We only need to write into one tag and one data block.
|
||||
tagAccesses += 1;
|
||||
dataAccesses += 1;
|
||||
|
||||
replacementPolicy->reset(blk);
|
||||
}
|
||||
// Update replacement policy
|
||||
replacementPolicy->reset(blk);
|
||||
}
|
||||
|
||||
/**
|
||||
* Limit the allocation for the cache ways.
|
||||
|
||||
36
src/mem/cache/tags/fa_lru.cc
vendored
36
src/mem/cache/tags/fa_lru.cc
vendored
@@ -169,6 +169,9 @@ FALRU::invalidate(CacheBlk *blk)
|
||||
{
|
||||
// TODO: We need to move the block to the tail to make it the next victim
|
||||
BaseTags::invalidate(blk);
|
||||
|
||||
// Erase block entry in the hash table
|
||||
tagHash.erase(blk->tag);
|
||||
}
|
||||
|
||||
CacheBlk*
|
||||
@@ -250,28 +253,27 @@ FALRU::findBlockBySetAndWay(int set, int way) const
|
||||
CacheBlk*
|
||||
FALRU::findVictim(Addr addr)
|
||||
{
|
||||
FALRUBlk * blk = tail;
|
||||
assert(blk->inCache == 0);
|
||||
moveToHead(blk);
|
||||
tagHash.erase(blk->tag);
|
||||
tagHash[blkAlign(addr)] = blk;
|
||||
if (blk->isValid()) {
|
||||
replacements[0]++;
|
||||
} else {
|
||||
tagsInUse++;
|
||||
if (!warmedUp && tagsInUse.value() >= warmupBound) {
|
||||
warmedUp = true;
|
||||
warmupCycle = curTick();
|
||||
}
|
||||
}
|
||||
//assert(check());
|
||||
|
||||
return blk;
|
||||
return tail;
|
||||
}
|
||||
|
||||
void
|
||||
FALRU::insertBlock(PacketPtr pkt, CacheBlk *blk)
|
||||
{
|
||||
FALRUBlk* falruBlk = static_cast<FALRUBlk*>(blk);
|
||||
|
||||
// Make sure block is not present in the cache
|
||||
assert(falruBlk->inCache == 0);
|
||||
|
||||
// Do common block insertion functionality
|
||||
BaseTags::insertBlock(pkt, blk);
|
||||
|
||||
// New block is the MRU
|
||||
moveToHead(falruBlk);
|
||||
|
||||
// Insert new block in the hash table
|
||||
tagHash[falruBlk->tag] = falruBlk;
|
||||
|
||||
//assert(check());
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
12
src/mem/cache/tags/fa_lru.hh
vendored
12
src/mem/cache/tags/fa_lru.hh
vendored
@@ -62,7 +62,7 @@
|
||||
*/
|
||||
class FALRUBlk : public CacheBlk
|
||||
{
|
||||
public:
|
||||
public:
|
||||
/** The previous block in LRU order. */
|
||||
FALRUBlk *prev;
|
||||
/** The next block in LRU order. */
|
||||
@@ -151,8 +151,7 @@ class FALRU : public BaseTags
|
||||
* @}
|
||||
*/
|
||||
|
||||
public:
|
||||
|
||||
public:
|
||||
typedef FALRUParams Params;
|
||||
|
||||
/**
|
||||
@@ -209,6 +208,12 @@ public:
|
||||
*/
|
||||
CacheBlk* findVictim(Addr addr) override;
|
||||
|
||||
/**
|
||||
* Insert the new block into the cache and update replacement data.
|
||||
*
|
||||
* @param pkt Packet holding the address to update
|
||||
* @param blk The block to update.
|
||||
*/
|
||||
void insertBlock(PacketPtr pkt, CacheBlk *blk) override;
|
||||
|
||||
/**
|
||||
@@ -274,7 +279,6 @@ public:
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif // __MEM_CACHE_TAGS_FA_LRU_HH__
|
||||
|
||||
Reference in New Issue
Block a user