summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLisa Hsu <hsul@eecs.umich.edu>2008-11-04 11:35:58 -0500
committerLisa Hsu <hsul@eecs.umich.edu>2008-11-04 11:35:58 -0500
commitc68032ddcbf0aad10123710e7c7c932bf52061a0 (patch)
tree1bbeeb7adc7012716bf51c6546d7a52a3267226d /src
parent4ab52cb986962f7c0fb0fa07de10d8cdfb51458a (diff)
downloadgem5-c68032ddcbf0aad10123710e7c7c932bf52061a0.tar.xz
decouple eviction from insertion in the cache.
Diffstat (limited to 'src')
-rw-r--r--src/mem/cache/cache_impl.hh8
-rw-r--r--src/mem/cache/tags/fa_lru.cc7
-rw-r--r--src/mem/cache/tags/fa_lru.hh4
-rw-r--r--src/mem/cache/tags/iic.cc7
-rw-r--r--src/mem/cache/tags/iic.hh4
-rw-r--r--src/mem/cache/tags/lru.cc18
-rw-r--r--src/mem/cache/tags/lru.hh16
7 files changed, 49 insertions, 15 deletions
diff --git a/src/mem/cache/cache_impl.hh b/src/mem/cache/cache_impl.hh
index af179ff91..40d1c9c2f 100644
--- a/src/mem/cache/cache_impl.hh
+++ b/src/mem/cache/cache_impl.hh
@@ -319,6 +319,7 @@ Cache<TagStore>::access(PacketPtr pkt, BlkType *&blk,
incMissCount(pkt);
return false;
}
+ tags->insertBlock(pkt->getAddr(), blk);
blk->status = BlkValid | BlkReadable;
}
std::memcpy(blk->data, pkt->getPtr<uint8_t>(), blkSize);
@@ -879,7 +880,7 @@ template<class TagStore>
typename Cache<TagStore>::BlkType*
Cache<TagStore>::allocateBlock(Addr addr, PacketList &writebacks)
{
- BlkType *blk = tags->findReplacement(addr, writebacks);
+ BlkType *blk = tags->findVictim(addr, writebacks);
if (blk->isValid()) {
Addr repl_addr = tags->regenerateBlkAddr(blk->tag, blk->set);
@@ -890,6 +891,7 @@ Cache<TagStore>::allocateBlock(Addr addr, PacketList &writebacks)
assert(!blk->isWritable());
assert(repl_mshr->needsExclusive());
// too hard to replace block with transient state
+ // allocation failed, block not inserted
return NULL;
} else {
DPRINTF(Cache, "replacement: replacing %x with %x: %s\n",
@@ -903,8 +905,6 @@ Cache<TagStore>::allocateBlock(Addr addr, PacketList &writebacks)
}
}
- // Set tag for new block. Caller is responsible for setting status.
- blk->tag = tags->extractTag(addr);
return blk;
}
@@ -937,6 +937,8 @@ Cache<TagStore>::handleFill(PacketPtr pkt, BlkType *blk,
tempBlock->set = tags->extractSet(addr);
tempBlock->tag = tags->extractTag(addr);
DPRINTF(Cache, "using temp block for %x\n", addr);
+ } else {
+ tags->insertBlock(addr, blk);
}
} else {
// existing block... probably an upgrade
diff --git a/src/mem/cache/tags/fa_lru.cc b/src/mem/cache/tags/fa_lru.cc
index aeb20aa4d..f92d4cb37 100644
--- a/src/mem/cache/tags/fa_lru.cc
+++ b/src/mem/cache/tags/fa_lru.cc
@@ -207,7 +207,7 @@ FALRU::findBlock(Addr addr) const
}
FALRUBlk*
-FALRU::findReplacement(Addr addr, PacketList &writebacks)
+FALRU::findVictim(Addr addr, PacketList &writebacks)
{
FALRUBlk * blk = tail;
assert(blk->inCache == 0);
@@ -229,6 +229,11 @@ FALRU::findReplacement(Addr addr, PacketList &writebacks)
}
void
+FALRU::insertBlock(Addr addr, FALRU::BlkType *blk)
+{
+}
+
+void
FALRU::moveToHead(FALRUBlk *blk)
{
int updateMask = blk->inCache ^ cacheMask;
diff --git a/src/mem/cache/tags/fa_lru.hh b/src/mem/cache/tags/fa_lru.hh
index dfb21c08f..a740d962f 100644
--- a/src/mem/cache/tags/fa_lru.hh
+++ b/src/mem/cache/tags/fa_lru.hh
@@ -197,7 +197,9 @@ public:
* @param writebacks List for any writebacks to be performed.
* @return The block to place the replacement in.
*/
- FALRUBlk* findReplacement(Addr addr, PacketList & writebacks);
+ FALRUBlk* findVictim(Addr addr, PacketList & writebacks);
+
+ void insertBlock(Addr addr, BlkType *blk);
/**
* Return the hit latency of this cache.
diff --git a/src/mem/cache/tags/iic.cc b/src/mem/cache/tags/iic.cc
index 6abc0facf..2b34634ab 100644
--- a/src/mem/cache/tags/iic.cc
+++ b/src/mem/cache/tags/iic.cc
@@ -297,7 +297,7 @@ IIC::findBlock(Addr addr) const
IICTag*
-IIC::findReplacement(Addr addr, PacketList &writebacks)
+IIC::findVictim(Addr addr, PacketList &writebacks)
{
DPRINTF(IIC, "Finding Replacement for %x\n", addr);
unsigned set = hash(addr);
@@ -340,6 +340,11 @@ IIC::findReplacement(Addr addr, PacketList &writebacks)
}
void
+IIC::insertBlock(Addr addr, BlkType* blk)
+{
+}
+
+void
IIC::freeReplacementBlock(PacketList & writebacks)
{
IICTag *tag_ptr;
diff --git a/src/mem/cache/tags/iic.hh b/src/mem/cache/tags/iic.hh
index 26f9858c4..984506a93 100644
--- a/src/mem/cache/tags/iic.hh
+++ b/src/mem/cache/tags/iic.hh
@@ -435,7 +435,9 @@ class IIC : public BaseTags
* @param writebacks List for any writebacks to be performed.
* @return The block to place the replacement in.
*/
- IICTag* findReplacement(Addr addr, PacketList &writebacks);
+ IICTag* findVictim(Addr addr, PacketList &writebacks);
+
+ void insertBlock(Addr addr, BlkType *blk);
/**
* Read the data from the internal storage of the given cache block.
diff --git a/src/mem/cache/tags/lru.cc b/src/mem/cache/tags/lru.cc
index f5cf33696..ff353ff6a 100644
--- a/src/mem/cache/tags/lru.cc
+++ b/src/mem/cache/tags/lru.cc
@@ -183,12 +183,11 @@ LRU::findBlock(Addr addr) const
}
LRUBlk*
-LRU::findReplacement(Addr addr, PacketList &writebacks)
+LRU::findVictim(Addr addr, PacketList &writebacks)
{
unsigned set = extractSet(addr);
// grab a replacement candidate
LRUBlk *blk = sets[set].blks[assoc-1];
- sets[set].moveToHead(blk);
if (blk->isValid()) {
replacements[0]++;
totalRefs += blk->refCount;
@@ -197,7 +196,14 @@ LRU::findReplacement(Addr addr, PacketList &writebacks)
DPRINTF(CacheRepl, "set %x: selecting blk %x for replacement\n",
set, regenerateBlkAddr(blk->tag, set));
- } else if (!blk->isTouched) {
+ }
+ return blk;
+}
+
+void
+LRU::insertBlock(Addr addr, LRU::BlkType *blk)
+{
+ if (!blk->isTouched) {
tagsInUse++;
blk->isTouched = true;
if (!warmedUp && tagsInUse.value() >= warmupBound) {
@@ -206,7 +212,11 @@ LRU::findReplacement(Addr addr, PacketList &writebacks)
}
}
- return blk;
+ // Set tag for new block. Caller is responsible for setting status.
+ blk->tag = extractTag(addr);
+
+ unsigned set = extractSet(addr);
+ sets[set].moveToHead(blk);
}
void
diff --git a/src/mem/cache/tags/lru.hh b/src/mem/cache/tags/lru.hh
index 4f4c495f3..79af973a0 100644
--- a/src/mem/cache/tags/lru.hh
+++ b/src/mem/cache/tags/lru.hh
@@ -180,12 +180,20 @@ public:
LRUBlk* findBlock(Addr addr) const;
/**
- * Find a replacement block for the address provided.
- * @param pkt The request to a find a replacement candidate for.
+ * Find a block to evict for the address provided.
+ * @param addr The addr to a find a replacement candidate for.
* @param writebacks List for any writebacks to be performed.
- * @return The block to place the replacement in.
+ * @return The candidate block.
*/
- LRUBlk* findReplacement(Addr addr, PacketList &writebacks);
+ LRUBlk* findVictim(Addr addr, PacketList &writebacks);
+
+ /**
+ * Insert the new block into the cache. For LRU this means inserting into
+ * the MRU position of the set.
+ * @param addr The address to update.
+ * @param blk The block to update.
+ */
+ void insertBlock(Addr addr, BlkType *blk);
/**
* Generate the tag from the given address.