summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel R. Carvalho <odanrc@yahoo.com.br>2018-06-15 16:10:25 +0200
committerDaniel Carvalho <odanrc@yahoo.com.br>2019-05-08 17:41:09 +0000
commit4b6b068aa0c64a50092966ff329c1d21635c4175 (patch)
treeb418ff546e0bc65a7e58720bf6919ec325cda0fb /src
parent784642b4312c3366cae727b4fef1ea763ace2c87 (diff)
downloadgem5-4b6b068aa0c64a50092966ff329c1d21635c4175.tar.xz
mem-cache: Add block size to findVictim
Add block size to findVictim. For standard caches it will not be used. Compressed caches, however, need to know the size of the compressed block to decide whether a block is co-allocatable or not. Change-Id: Id07f79763687b29f75d707c080fa9bd978a408aa Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/11198 Tested-by: kokoro <noreply+kokoro@google.com> Maintainer: Nikos Nikoleris <nikos.nikoleris@arm.com> Reviewed-by: Mohammad Seyedzadeh <sm.seyedzade@gmail.com> Reviewed-by: Nikos Nikoleris <nikos.nikoleris@arm.com>
Diffstat (limited to 'src')
-rw-r--r--src/mem/cache/base.cc6
-rw-r--r--src/mem/cache/tags/base.hh3
-rw-r--r--src/mem/cache/tags/base_set_assoc.hh3
-rw-r--r--src/mem/cache/tags/fa_lru.cc2
-rw-r--r--src/mem/cache/tags/fa_lru.hh2
-rw-r--r--src/mem/cache/tags/sector_tags.cc2
-rw-r--r--src/mem/cache/tags/sector_tags.hh3
7 files changed, 18 insertions, 3 deletions
diff --git a/src/mem/cache/base.cc b/src/mem/cache/base.cc
index f31fbaf03..36968a18d 100644
--- a/src/mem/cache/base.cc
+++ b/src/mem/cache/base.cc
@@ -1319,9 +1319,13 @@ BaseCache::allocateBlock(const PacketPtr pkt, PacketList &writebacks)
// Get secure bit
const bool is_secure = pkt->isSecure();
+ // @todo Compress and get compression related data
+ std::size_t blk_size_bits = blkSize*8;
+
// Find replacement victim
std::vector<CacheBlk*> evict_blks;
- CacheBlk *victim = tags->findVictim(addr, is_secure, evict_blks);
+ CacheBlk *victim = tags->findVictim(addr, is_secure, blk_size_bits,
+ evict_blks);
// It is valid to return nullptr if there is no victim
if (!victim)
diff --git a/src/mem/cache/tags/base.hh b/src/mem/cache/tags/base.hh
index 296837e50..ae9cab87e 100644
--- a/src/mem/cache/tags/base.hh
+++ b/src/mem/cache/tags/base.hh
@@ -50,6 +50,7 @@
#define __MEM_CACHE_TAGS_BASE_HH__
#include <cassert>
+#include <cstdint>
#include <functional>
#include <string>
@@ -276,10 +277,12 @@ class BaseTags : public ClockedObject
*
* @param addr Address to find a victim for.
* @param is_secure True if the target memory space is secure.
+ * @param size Size, in bits, of new block to allocate.
* @param evict_blks Cache blocks to be evicted.
* @return Cache block to be replaced.
*/
virtual CacheBlk* findVictim(Addr addr, const bool is_secure,
+ const std::size_t size,
std::vector<CacheBlk*>& evict_blks) const = 0;
/**
diff --git a/src/mem/cache/tags/base_set_assoc.hh b/src/mem/cache/tags/base_set_assoc.hh
index c39a81335..f58f93951 100644
--- a/src/mem/cache/tags/base_set_assoc.hh
+++ b/src/mem/cache/tags/base_set_assoc.hh
@@ -48,6 +48,7 @@
#ifndef __MEM_CACHE_TAGS_BASE_SET_ASSOC_HH__
#define __MEM_CACHE_TAGS_BASE_SET_ASSOC_HH__
+#include <cstdint>
#include <functional>
#include <string>
#include <vector>
@@ -160,10 +161,12 @@ class BaseSetAssoc : public BaseTags
*
* @param addr Address to find a victim for.
* @param is_secure True if the target memory space is secure.
+ * @param size Size, in bits, of new block to allocate.
* @param evict_blks Cache blocks to be evicted.
* @return Cache block to be replaced.
*/
CacheBlk* findVictim(Addr addr, const bool is_secure,
+ const std::size_t size,
std::vector<CacheBlk*>& evict_blks) const override
{
// Get possible entries to be victimized
diff --git a/src/mem/cache/tags/fa_lru.cc b/src/mem/cache/tags/fa_lru.cc
index 4cdac0ac0..0ebef4be7 100644
--- a/src/mem/cache/tags/fa_lru.cc
+++ b/src/mem/cache/tags/fa_lru.cc
@@ -196,7 +196,7 @@ FALRU::findBlockBySetAndWay(int set, int way) const
}
CacheBlk*
-FALRU::findVictim(Addr addr, const bool is_secure,
+FALRU::findVictim(Addr addr, const bool is_secure, const std::size_t size,
std::vector<CacheBlk*>& evict_blks) const
{
// The victim is always stored on the tail for the FALRU
diff --git a/src/mem/cache/tags/fa_lru.hh b/src/mem/cache/tags/fa_lru.hh
index 346ff60c7..2ca9f4da4 100644
--- a/src/mem/cache/tags/fa_lru.hh
+++ b/src/mem/cache/tags/fa_lru.hh
@@ -219,10 +219,12 @@ class FALRU : public BaseTags
*
* @param addr Address to find a victim for.
* @param is_secure True if the target memory space is secure.
+ * @param size Size, in bits, of new block to allocate.
* @param evict_blks Cache blocks to be evicted.
* @return Cache block to be replaced.
*/
CacheBlk* findVictim(Addr addr, const bool is_secure,
+ const std::size_t size,
std::vector<CacheBlk*>& evict_blks) const override;
/**
diff --git a/src/mem/cache/tags/sector_tags.cc b/src/mem/cache/tags/sector_tags.cc
index 06093e997..535badb8d 100644
--- a/src/mem/cache/tags/sector_tags.cc
+++ b/src/mem/cache/tags/sector_tags.cc
@@ -221,7 +221,7 @@ SectorTags::findBlock(Addr addr, bool is_secure) const
}
CacheBlk*
-SectorTags::findVictim(Addr addr, const bool is_secure,
+SectorTags::findVictim(Addr addr, const bool is_secure, const std::size_t size,
std::vector<CacheBlk*>& evict_blks) const
{
// Get possible entries to be victimized
diff --git a/src/mem/cache/tags/sector_tags.hh b/src/mem/cache/tags/sector_tags.hh
index 84c721ef7..13638b4a5 100644
--- a/src/mem/cache/tags/sector_tags.hh
+++ b/src/mem/cache/tags/sector_tags.hh
@@ -36,6 +36,7 @@
#ifndef __MEM_CACHE_TAGS_SECTOR_TAGS_HH__
#define __MEM_CACHE_TAGS_SECTOR_TAGS_HH__
+#include <cstdint>
#include <string>
#include <vector>
@@ -150,10 +151,12 @@ class SectorTags : public BaseTags
*
* @param addr Address to find a victim for.
* @param is_secure True if the target memory space is secure.
+ * @param size Size, in bits, of new block to allocate.
* @param evict_blks Cache blocks to be evicted.
* @return Cache block to be replaced.
*/
CacheBlk* findVictim(Addr addr, const bool is_secure,
+ const std::size_t size,
std::vector<CacheBlk*>& evict_blks) const override;
/**