gpu-compute: Fix deadlock in fetch_unit after branch instruction
authorKyle Roarty <kyleroarty1716@gmail.com>
Tue, 15 Sep 2020 13:57:39 +0000 (08:57 -0500)
committerKyle Roarty <kyleroarty1716@gmail.com>
Thu, 17 Sep 2020 21:24:19 +0000 (21:24 +0000)
The following deadlock was occuring in fetch_unit w/timingSim:
1. exec() is called, a wave is ready to fetch, so it sets pendingFetch
2. A packet is sent to ITLB to fetch for that wave
3. The wave executes a branch, causing the fetch buffer to be cleared
4. The packet is handled, and fetch() is called. However, because the
fetch buffer was cleared, it returns doing nothing.
5. exec() gets called again, but the wave will never be scheduled to
fetch, as pendingFetch is still set to true.

This patch clears pendingFetch (and dropFetch) before returning in fetch()
when the fetch buffer has been cleared.

dropFetch needed to be cleared otherwise gem5 would crash.

Change-Id: Iccbac7defc4849c19e8b17aa2492da641defb772
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/34555
Reviewed-by: Jason Lowe-Power <power.jg@gmail.com>
Reviewed-by: Matt Sinclair <mattdsinclair@gmail.com>
Reviewed-by: Anthony Gutierrez <anthony.gutierrez@amd.com>
Maintainer: Anthony Gutierrez <anthony.gutierrez@amd.com>
Tested-by: kokoro <noreply+kokoro@google.com>
src/gpu-compute/fetch_unit.cc

index 4e4259e74214ec30e12857f55bcc7bfd1dccf898..098b783a937a5dd837e0ad40ee4cf13f3fd10fbb 100644 (file)
@@ -240,6 +240,8 @@ FetchUnit::fetch(PacketPtr pkt, Wavefront *wavefront)
      * pending, in the same cycle another instruction is trying to fetch.
      */
     if (!fetchBuf.at(wavefront->wfSlotId).isReserved(pkt->req->getVaddr())) {
+        wavefront->dropFetch = false;
+        wavefront->pendingFetch = false;
         return;
     }