mem-cache: Isolate prefetching bit
authorDaniel R. Carvalho <odanrc@yahoo.com.br>
Tue, 6 Oct 2020 10:45:45 +0000 (12:45 +0200)
committerDaniel Carvalho <odanrc@yahoo.com.br>
Thu, 8 Oct 2020 18:32:00 +0000 (18:32 +0000)
Previously the prefetching bit was among the status bits;
yet, it has no correlation with the other bits. It has
been isolated as a single boolean, with a respective getter
and setter.

Change-Id: Ibe76e1196ca17a7c9ab9bda2216186707427cb64
Signed-off-by: Daniel R. Carvalho <odanrc@yahoo.com.br>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/35699
Reviewed-by: Jason Lowe-Power <power.jg@gmail.com>
Reviewed-by: Nikos Nikoleris <nikos.nikoleris@arm.com>
Maintainer: Nikos Nikoleris <nikos.nikoleris@arm.com>
Tested-by: kokoro <noreply+kokoro@google.com>
src/mem/cache/base.cc
src/mem/cache/cache.cc
src/mem/cache/cache_blk.hh
src/mem/cache/noncoherent_cache.cc

index fc2115a2a5d7a77f05055ca6df1e1b4adf754271..7b6b3c38d26f1619322d16a1ccdbbbe2c9e5e26d 100644 (file)
@@ -367,7 +367,7 @@ BaseCache::recvTimingReq(PacketPtr pkt)
         ppHit->notify(pkt);
 
         if (prefetcher && blk && blk->wasPrefetched()) {
-            blk->status &= ~BlkHWPrefetched;
+            blk->clearPrefetched();
         }
 
         handleTimingReqHit(pkt, blk, request_time);
index 8e45ea34748a605d7d0bb6052440567f984800bb..9e87c2adeac83a9c51eb2bd12c9c11d97a773889 100644 (file)
@@ -850,7 +850,7 @@ Cache::serviceMSHRTargets(MSHR *mshr, const PacketPtr pkt, CacheBlk *blk)
           case MSHR::Target::FromPrefetcher:
             assert(tgt_pkt->cmd == MemCmd::HardPFReq);
             if (blk)
-                blk->status |= BlkHWPrefetched;
+                blk->setPrefetched();
             delete tgt_pkt;
             break;
 
index b0d45af5548595fc7910cc31f4211cf1734ba882..4483fb134e40fdaf6ca84b22c31f4ffad790df69 100644 (file)
@@ -69,8 +69,6 @@ enum CacheBlkStatusBits : unsigned {
     BlkReadable =       0x04,
     /** dirty (modified) */
     BlkDirty =          0x08,
-    /** block was a hardware prefetch yet unaccessed*/
-    BlkHWPrefetched =   0x20,
     /** block holds compressed data */
     BlkCompressed =     0x80
 };
@@ -176,6 +174,7 @@ class CacheBlk : public TaggedEntry
     virtual void invalidate()
     {
         TaggedEntry::invalidate();
+        clearPrefetched();
         setTaskId(ContextSwitchTaskId::Unknown);
         status = 0;
         whenReady = MaxTick;
@@ -198,10 +197,16 @@ class CacheBlk : public TaggedEntry
      * be touched.
      * @return True if the block was a hardware prefetch, unaccesed.
      */
-    bool wasPrefetched() const
-    {
-        return (status & BlkHWPrefetched) != 0;
-    }
+    bool wasPrefetched() const { return _prefetched; }
+
+    /**
+     * Clear the prefetching bit. Either because it was recently used, or due
+     * to the block being invalidated.
+     */
+    void clearPrefetched() { _prefetched = false; }
+
+    /** Marks this blocks as a recently prefetched block. */
+    void setPrefetched() { _prefetched = false; }
 
     /**
      * Get tick at which block's data will be available for access.
@@ -423,6 +428,9 @@ class CacheBlk : public TaggedEntry
      * meaningful if the block is valid.
      */
     Tick _tickInserted;
+
+    /** Whether this block is an unaccessed hardware prefetch. */
+    bool _prefetched;
 };
 
 /**
index 5ca1da0cfd2a488b0944b9d902aa11dbd358b7ee..0cea4945e02879bcf3b911399a98ede3386d507e 100644 (file)
@@ -288,7 +288,7 @@ NoncoherentCache::serviceMSHRTargets(MSHR *mshr, const PacketPtr pkt,
             assert(tgt_pkt->cmd == MemCmd::HardPFReq);
 
             if (blk)
-                blk->status |= BlkHWPrefetched;
+                blk->setPrefetched();
 
             // We have filled the block and the prefetcher does not
             // require responses.