gem5-dev@gem5.org

The gem5 Developer List

View all threads

[S] Change in gem5/gem5[develop]: configs,gpu-compute: Kernel dispatch-based exit events

MP
Matthew Poremba (Gerrit)
Thu, Jun 8, 2023 3:56 PM

Matthew Poremba has uploaded this change for review. (
https://gem5-review.googlesource.com/c/public/gem5/+/71418?usp=email )

Change subject: configs,gpu-compute: Kernel dispatch-based exit events
......................................................................

configs,gpu-compute: Kernel dispatch-based exit events

Add two kernel dispatch-based exit events that are useful for limiting
the simulation and enabling debug flags at specific GPU kernels. Since
the KVM CPU typically used with GPUFS is not deterministic, this help
with enabling debug flags when the Tick number may vary. The exit at GPU
kernel option can also limit simulation by only simulating a few hundred
kernels, for example, and exit at a determined point.

Change-Id: I81bae92a80c25fc38c41e999aa662e1417b7a20d

M configs/example/gpufs/runfs.py
M src/gpu-compute/dispatcher.cc
2 files changed, 30 insertions(+), 0 deletions(-)

diff --git a/configs/example/gpufs/runfs.py b/configs/example/gpufs/runfs.py
index f8ef70d..01203bb 100644
--- a/configs/example/gpufs/runfs.py
+++ b/configs/example/gpufs/runfs.py
@@ -137,6 +137,20 @@
"MI200 (gfx90a)",
)

  • parser.add_argument(
  •    "--debug-at-gpu-kernel",
    
  •    type=int,
    
  •    default=-1,
    
  •    help="Turn on debug flags starting with this kernel",
    
  • )
  • parser.add_argument(
  •    "--exit-at-gpu-kernel",
    
  •    type=int,
    
  •    default=-1,
    
  •    help="Exit simulation after running this many kernels",
    
  • )

def runGpuFSSystem(args):
"""
@@ -184,6 +198,9 @@

  print("Running the simulation")
  sim_ticks = args.abs_max_tick
  • kernels_launched = 0
  • if args.debug_at_gpu_kernel != -1:
  •    m5.trace.disable()
    
    exit_event = m5.simulate(sim_ticks)
    

@@ -199,11 +216,21 @@
assert args.checkpoint_dir is not None
m5.checkpoint(args.checkpoint_dir)
break

  •    elif "GPU Kernel Completed" in exit_event.getCause():
    
  •        kernels_launched += 1
        else:
            print(
                f"Unknown exit event: {exit_event.getCause()}.  
    

Continuing..."
)

  •    if kernels_launched == args.debug_at_gpu_kernel:
    
  •        m5.trace.enable()
    
  •    if kernels_launched == args.exit_at_gpu_kernel:
    
  •        print(f"Exiting @ GPU kernel {kernels_launched}")
    
  •        break
    
  •    exit_event = m5.simulate(sim_ticks - m5.curTick())
    
  • print(
        "Exiting @ tick %i because %s" % (m5.curTick(),  
    

exit_event.getCause())
)
diff --git a/src/gpu-compute/dispatcher.cc b/src/gpu-compute/dispatcher.cc
index a76ba7c..b19bccc 100644
--- a/src/gpu-compute/dispatcher.cc
+++ b/src/gpu-compute/dispatcher.cc
@@ -40,6 +40,7 @@
#include "gpu-compute/hsa_queue_entry.hh"
#include "gpu-compute/shader.hh"
#include "gpu-compute/wavefront.hh"
+#include "sim/sim_exit.hh"
#include "sim/syscall_emul_buf.hh"
#include "sim/system.hh"

@@ -330,6 +331,8 @@
DPRINTF(GPUWgLatency, "Kernel Complete ticks:%d kernel:%d\n",
curTick(), kern_id);
DPRINTF(GPUKernelInfo, "Completed kernel %d\n", kern_id);
+

  •    exitSimLoop("GPU Kernel Completed");
    }
    
    if (!tickEvent.scheduled()) {
    

--
To view, visit
https://gem5-review.googlesource.com/c/public/gem5/+/71418?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings?usp=email

Gerrit-MessageType: newchange
Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I81bae92a80c25fc38c41e999aa662e1417b7a20d
Gerrit-Change-Number: 71418
Gerrit-PatchSet: 1
Gerrit-Owner: Matthew Poremba matthew.poremba@amd.com

Matthew Poremba has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/71418?usp=email ) Change subject: configs,gpu-compute: Kernel dispatch-based exit events ...................................................................... configs,gpu-compute: Kernel dispatch-based exit events Add two kernel dispatch-based exit events that are useful for limiting the simulation and enabling debug flags at specific GPU kernels. Since the KVM CPU typically used with GPUFS is not deterministic, this help with enabling debug flags when the Tick number may vary. The exit at GPU kernel option can also limit simulation by only simulating a few hundred kernels, for example, and exit at a determined point. Change-Id: I81bae92a80c25fc38c41e999aa662e1417b7a20d --- M configs/example/gpufs/runfs.py M src/gpu-compute/dispatcher.cc 2 files changed, 30 insertions(+), 0 deletions(-) diff --git a/configs/example/gpufs/runfs.py b/configs/example/gpufs/runfs.py index f8ef70d..01203bb 100644 --- a/configs/example/gpufs/runfs.py +++ b/configs/example/gpufs/runfs.py @@ -137,6 +137,20 @@ "MI200 (gfx90a)", ) + parser.add_argument( + "--debug-at-gpu-kernel", + type=int, + default=-1, + help="Turn on debug flags starting with this kernel", + ) + + parser.add_argument( + "--exit-at-gpu-kernel", + type=int, + default=-1, + help="Exit simulation after running this many kernels", + ) + def runGpuFSSystem(args): """ @@ -184,6 +198,9 @@ print("Running the simulation") sim_ticks = args.abs_max_tick + kernels_launched = 0 + if args.debug_at_gpu_kernel != -1: + m5.trace.disable() exit_event = m5.simulate(sim_ticks) @@ -199,11 +216,21 @@ assert args.checkpoint_dir is not None m5.checkpoint(args.checkpoint_dir) break + elif "GPU Kernel Completed" in exit_event.getCause(): + kernels_launched += 1 else: print( f"Unknown exit event: {exit_event.getCause()}. Continuing..." ) + if kernels_launched == args.debug_at_gpu_kernel: + m5.trace.enable() + if kernels_launched == args.exit_at_gpu_kernel: + print(f"Exiting @ GPU kernel {kernels_launched}") + break + + exit_event = m5.simulate(sim_ticks - m5.curTick()) + print( "Exiting @ tick %i because %s" % (m5.curTick(), exit_event.getCause()) ) diff --git a/src/gpu-compute/dispatcher.cc b/src/gpu-compute/dispatcher.cc index a76ba7c..b19bccc 100644 --- a/src/gpu-compute/dispatcher.cc +++ b/src/gpu-compute/dispatcher.cc @@ -40,6 +40,7 @@ #include "gpu-compute/hsa_queue_entry.hh" #include "gpu-compute/shader.hh" #include "gpu-compute/wavefront.hh" +#include "sim/sim_exit.hh" #include "sim/syscall_emul_buf.hh" #include "sim/system.hh" @@ -330,6 +331,8 @@ DPRINTF(GPUWgLatency, "Kernel Complete ticks:%d kernel:%d\n", curTick(), kern_id); DPRINTF(GPUKernelInfo, "Completed kernel %d\n", kern_id); + + exitSimLoop("GPU Kernel Completed"); } if (!tickEvent.scheduled()) { -- To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/71418?usp=email To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings?usp=email Gerrit-MessageType: newchange Gerrit-Project: public/gem5 Gerrit-Branch: develop Gerrit-Change-Id: I81bae92a80c25fc38c41e999aa662e1417b7a20d Gerrit-Change-Number: 71418 Gerrit-PatchSet: 1 Gerrit-Owner: Matthew Poremba <matthew.poremba@amd.com>