gpu-compute: Dropping fetchs when no entry is reserved in the buffer
authorOnur Kayiran <onur.kayiran@amd.com>
Mon, 14 May 2018 17:51:35 +0000 (13:51 -0400)
committerAnthony Gutierrez <anthony.gutierrez@amd.com>
Mon, 13 Jul 2020 19:47:26 +0000 (19:47 +0000)
This changeset drops fetches if there is no entry reserved in the
fetch buffer for that instruction. This can happen due to a fetch
attempted to be issued in the same cycle where a branch instruction
flushed the fetch buffer, while an ITLB or I-cache request is still
pending.

Change-Id: I3b80dbd71af27ccf790b543bd5c034bb9b02624a
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/29932
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Anthony Gutierrez <anthony.gutierrez@amd.com>
Reviewed-by: Onur Kayıran <onur.kayiran@amd.com>
Maintainer: Anthony Gutierrez <anthony.gutierrez@amd.com>

src/gpu-compute/fetch_unit.cc
src/gpu-compute/fetch_unit.hh

index fb04cd27e0a5f48e5d2ea36fb533f7a81f2d743f..447ff12faa6150c63f0b1db4fdf770a003ed9bd8 100644 (file)
@@ -234,6 +234,16 @@ FetchUnit::fetch(PacketPtr pkt, Wavefront *wavefront)
     pkt = new Packet(oldPkt->req, oldPkt->cmd);
     delete oldPkt;
 
+    /**
+     * if we have not reserved an entry in the fetch buffer,
+     * stop fetching. this can happen due to a branch instruction
+     * flushing the fetch buffer while an ITLB or I-cache request is still
+     * pending, in the same cycle another instruction is trying to fetch.
+     */
+    if (!fetchBuf.at(wavefront->wfSlotId).isReserved(pkt->req->getVaddr())) {
+        return;
+    }
+
     /**
      * we should have reserved an entry in the fetch buffer
      * for this cache line. here we get the pointer to the
index 2cfe3f0feeb3d57671b1643e0d1e4955ecdbb204..798c26465521613f7de7035d3bd3a100f6a0f09b 100644 (file)
@@ -120,6 +120,18 @@ class FetchUnit
             return reserved_pc->second;
         }
 
+        /**
+         * returns true if there is an entry reserved for this address,
+         * and false otherwise
+         */
+        bool
+        isReserved(Addr vaddr) const
+        {
+            auto reserved_pc = reservedPCs.find(vaddr);
+            bool is_reserved = (reserved_pc != reservedPCs.end());
+            return is_reserved;
+        }
+
         void fetchDone(Addr vaddr);
 
         /**