From: Daniel R. Carvalho Date: Fri, 15 Jun 2018 14:10:25 +0000 (+0200) Subject: mem-cache: Add block size to findVictim X-Git-Tag: v19.0.0.0~878 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=4b6b068aa0c64a50092966ff329c1d21635c4175;p=gem5.git 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 Maintainer: Nikos Nikoleris Reviewed-by: Mohammad Seyedzadeh Reviewed-by: Nikos Nikoleris --- 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 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 +#include #include #include @@ -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& 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 #include #include #include @@ -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& 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& 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& 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& 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 #include #include @@ -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& evict_blks) const override; /**