Daniel Carvalho has uploaded this change for review. ( https://gem5-review.googlesource.com/11098

Change subject: mem-cache: Use PacketPtr in findVictim
......................................................................

mem-cache: Use PacketPtr in findVictim

Packet data will be compressed within findVictim, and as other
fields of packet ptr are already being used, we pass the whole
pointer instead.

Change-Id: I5c58f7c17de3255beee531f72a3fd25a30d74c90
---
M src/mem/cache/base.cc
M src/mem/cache/tags/base.hh
M src/mem/cache/tags/base_set_assoc.hh
M src/mem/cache/tags/fa_lru.cc
M src/mem/cache/tags/fa_lru.hh
M src/mem/cache/tags/sector_tags.cc
M src/mem/cache/tags/sector_tags.hh
7 files changed, 20 insertions(+), 23 deletions(-)



diff --git a/src/mem/cache/base.cc b/src/mem/cache/base.cc
index d3dc980..bbfb26f 100644
--- a/src/mem/cache/base.cc
+++ b/src/mem/cache/base.cc
@@ -1202,12 +1202,6 @@
 CacheBlk*
 BaseCache::allocateBlock(const PacketPtr pkt, PacketList &writebacks)
 {
-    // Get address
-    const Addr addr = pkt->getAddr();
-
-    // Get secure bit
-    const bool is_secure = pkt->isSecure();
-
     // Allocation latency
     // @todo When evicting compressed blocks they must be decompressed
     //       first, so the latency to do so must be taken into account.
@@ -1218,7 +1212,7 @@

     // Find replacement victim
     std::vector<CacheBlk*> evict_blks;
-    CacheBlk *victim = tags->findVictim(addr, is_secure, lat, evict_blks);
+    CacheBlk *victim = tags->findVictim(pkt, lat, evict_blks);

     // It is valid to return nullptr if there is no victim
     if (!victim)
@@ -1249,7 +1243,7 @@
         DPRINTF(Cache, "replacement: replacing %#llx (%s) with %#llx "
                 "(%s): %s\n", regenerateBlkAddr(victim),
                 victim->isSecure() ? "s" : "ns",
-                addr, is_secure ? "s" : "ns",
+                pkt->getAddr(), pkt->isSecure() ? "s" : "ns",
                 victim->isDirty() ? "writeback" : "clean");

         replacements++;
diff --git a/src/mem/cache/tags/base.hh b/src/mem/cache/tags/base.hh
index 4819bd0..5e7a417 100644
--- a/src/mem/cache/tags/base.hh
+++ b/src/mem/cache/tags/base.hh
@@ -270,13 +270,12 @@
      * be assigned to the newly allocated block associated to this address.
      * @sa insertBlock
      *
-     * @param addr Address to find a victim for.
-     * @param is_secure True if the target memory space is secure.
+     * @param pkt Packet holding the address to find a victim for.
      * @param lat The access latency (i.e., decompression).
      * @param evict_blks Cache blocks to be evicted.
      * @return Cache block to be replaced.
      */
- virtual CacheBlk* findVictim(Addr addr, const bool is_secure, Cycles &lat,
+    virtual CacheBlk* findVictim(const PacketPtr pkt, Cycles &lat,
std::vector<CacheBlk*>& evict_blks) const = 0;

virtual CacheBlk* accessBlock(Addr addr, bool is_secure, Cycles &lat) = 0; diff --git a/src/mem/cache/tags/base_set_assoc.hh b/src/mem/cache/tags/base_set_assoc.hh
index 0335ead..c6f9e18 100644
--- a/src/mem/cache/tags/base_set_assoc.hh
+++ b/src/mem/cache/tags/base_set_assoc.hh
@@ -203,17 +203,17 @@
      * Find replacement victim based on address. The list of evicted blocks
      * only contains the victim.
      *
-     * @param addr Address to find a victim for.
-     * @param is_secure True if the target memory space is secure.
+     * @param pkt Packet holding the address to find a victim for.
      * @param lat The access latency (i.e., decompression).
      * @param evict_blks Cache blocks to be evicted.
      * @return Cache block to be replaced.
      */
-    CacheBlk* findVictim(Addr addr, const bool is_secure, Cycles& lat,
+    CacheBlk* findVictim(const PacketPtr pkt, Cycles& lat,
                          std::vector<CacheBlk*>& evict_blks) const override
     {
         // Get possible locations for the victim block
-        std::vector<CacheBlk*> locations = getPossibleLocations(addr);
+        std::vector<CacheBlk*> locations = getPossibleLocations(
+                                               pkt->getAddr());

         // Choose replacement victim from replacement candidates
CacheBlk* victim = static_cast<CacheBlk*>(replacementPolicy->getVictim(
diff --git a/src/mem/cache/tags/fa_lru.cc b/src/mem/cache/tags/fa_lru.cc
index 2d8c692..85a5b5b 100644
--- a/src/mem/cache/tags/fa_lru.cc
+++ b/src/mem/cache/tags/fa_lru.cc
@@ -195,7 +195,7 @@
 }

 CacheBlk*
-FALRU::findVictim(Addr addr, const bool is_secure, Cycles& lat,
+FALRU::findVictim(const PacketPtr pkt, Cycles& lat,
                   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 1edc318..931ab7c 100644
--- a/src/mem/cache/tags/fa_lru.hh
+++ b/src/mem/cache/tags/fa_lru.hh
@@ -200,13 +200,12 @@
      * Find replacement victim based on address. The list of evicted blocks
      * only contains the victim.
      *
-     * @param addr Address to find a victim for.
-     * @param is_secure True if the target memory space is secure.
+     * @param pkt Packet holding the address to find a victim for.
      * @param lat The access latency (i.e., decompression).
      * @param evict_blks Cache blocks to be evicted.
      * @return Cache block to be replaced.
      */
-    CacheBlk* findVictim(Addr addr, const bool is_secure, Cycles &lat,
+    CacheBlk* findVictim(const PacketPtr pkt, Cycles &lat,
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 aa88df2..0a33d27 100644
--- a/src/mem/cache/tags/sector_tags.cc
+++ b/src/mem/cache/tags/sector_tags.cc
@@ -255,9 +255,15 @@
 }

 CacheBlk*
-SectorTags::findVictim(Addr addr, const bool is_secure, Cycles& lat,
+SectorTags::findVictim(const PacketPtr pkt, Cycles& lat,
                        std::vector<CacheBlk*>& evict_blks) const
 {
+    // Get address to search a victim for
+    Addr addr = pkt->getAddr();
+
+    // Get secure bit
+    bool is_secure = pkt->isSecure();
+
     // Get all possible locations of this sector
     const std::vector<SectorBlk*> sector_locations =
         getPossibleLocations(addr);
diff --git a/src/mem/cache/tags/sector_tags.hh b/src/mem/cache/tags/sector_tags.hh
index d97333e..6315ae3 100644
--- a/src/mem/cache/tags/sector_tags.hh
+++ b/src/mem/cache/tags/sector_tags.hh
@@ -177,13 +177,12 @@
     /**
      * Find replacement victim based on address.
      *
-     * @param addr Address to find a victim for.
-     * @param is_secure True if the target memory space is secure.
+     * @param pkt Packet holding the address to find a victim for.
      * @param lat The access latency (i.e., decompression).
      * @param evict_blks Cache blocks to be evicted.
      * @return Cache block to be replaced.
      */
-    CacheBlk* findVictim(Addr addr, const bool is_secure, Cycles& lat,
+    CacheBlk* findVictim(const PacketPtr pkt, Cycles& lat,
std::vector<CacheBlk*>& evict_blks) const override;

     /**

--
To view, visit https://gem5-review.googlesource.com/11098
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-Change-Id: I5c58f7c17de3255beee531f72a3fd25a30d74c90
Gerrit-Change-Number: 11098
Gerrit-PatchSet: 1
Gerrit-Owner: Daniel Carvalho <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to