From 8e268d42e2260dfc6200cda723e269b6473ed8fb Mon Sep 17 00:00:00 2001 From: Jarvis Jia Date: Mon, 10 Jun 2024 20:56:08 -0500 Subject: [PATCH 1/4] gpu-compute: Provided m5ops support for gpu Adding m5 stat dump and reset into python script through different exit event Change-Id: I662233ae71e2987d90af1fd0100e29036b2ef1c6 --- configs/example/apu_se.py | 45 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/configs/example/apu_se.py b/configs/example/apu_se.py index 2d3a849df0..6f23565f28 100644 --- a/configs/example/apu_se.py +++ b/configs/example/apu_se.py @@ -707,7 +707,7 @@ render_driver = GPURenderDriver(filename=f"dri/renderD{renderDriNum}") gpu_hsapp = HSAPacketProcessor( pioAddr=hsapp_gpu_map_paddr, numHWQueues=args.num_hw_queues ) -dispatcher = GPUDispatcher() +dispatcher = GPUDispatcher(kernel_exit_events=True) gpu_cmd_proc = GPUCommandProcessor(hsapp=gpu_hsapp, dispatcher=dispatcher) gpu_driver.device = gpu_cmd_proc shader.dispatcher = dispatcher @@ -834,6 +834,8 @@ if fast_forward: # configure the TLB hierarchy GPUTLBConfig.config_tlb_hierarchy(args, system, shader_idx) +system.exit_on_work_items = True + # create Ruby system system.piobus = IOXBar( width=32, response_latency=0, frontend_latency=0, forward_latency=0 @@ -1008,6 +1010,47 @@ if args.fast_forward: exit_event = m5.simulate(maxtick) +while True: + if ( + exit_event.getCause() == "m5_exit instruction encountered" + or exit_event.getCause() == "user interrupt received" + or exit_event.getCause() == "simulate() limit reached" + or "exiting with last active thread context" in exit_event.getCause() + ): + print(f"breaking loop due to: {exit_event.getCause()}.") + break + elif "checkpoint" in exit_event.getCause(): + assert args.checkpoint_dir is not None + m5.checkpoint(args.checkpoint_dir) + print("breaking loop with checkpoint") + break + elif "GPU Kernel Completed" in exit_event.getCause(): + print("GPU Kernel Completed dump and reset") + m5.stats.dump() + m5.stats.reset() + elif "GPU Blit Kernel Completed" in exit_event.getCause(): + print("GPU Blit Kernel Completed dump and reset") + m5.stats.dump() + m5.stats.reset() + elif "Skipping GPU Kernel" in exit_event.getCause(): + print("Skipping GPU Kernel dump and reset") + m5.stats.dump() + m5.stats.reset() + elif "workbegin" in exit_event.getCause(): + print("m5 work begin dump and reset") + m5.stats.dump() + m5.stats.reset() + elif "workend" in exit_event.getCause(): + print("m5 work end dump and reset") + m5.stats.dump() + m5.stats.reset() + else: + print( + f"Unknown exit event: {exit_event.getCause()}. Continuing..." + ) + + exit_event = m5.simulate(maxtick - m5.curTick()) + if args.fast_forward: if exit_event.getCause() == "a thread reached the max instruction count": m5.switchCpus(system, switch_cpu_list) From 4fea51b598ab2810f8b12f0f61c5973b5a9ce0f0 Mon Sep 17 00:00:00 2001 From: Jarvis Jia Date: Mon, 10 Jun 2024 22:52:56 -0500 Subject: [PATCH 2/4] Black format change Change-Id: I95cbf5b97601ef3b6ca26bc1a1835305929ffcab --- configs/example/apu_se.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/configs/example/apu_se.py b/configs/example/apu_se.py index 6f23565f28..0319ad127e 100644 --- a/configs/example/apu_se.py +++ b/configs/example/apu_se.py @@ -894,9 +894,9 @@ gpu_port_idx = gpu_port_idx - args.num_cp * 2 token_port_idx = 0 for i in range(len(system.ruby._cpu_ports)): if isinstance(system.ruby._cpu_ports[i], VIPERCoalescer): - system.cpu[shader_idx].CUs[ - token_port_idx - ].gmTokenPort = system.ruby._cpu_ports[i].gmTokenPort + system.cpu[shader_idx].CUs[token_port_idx].gmTokenPort = ( + system.ruby._cpu_ports[i].gmTokenPort + ) token_port_idx += 1 wavefront_size = args.wf_size @@ -1015,7 +1015,7 @@ while True: exit_event.getCause() == "m5_exit instruction encountered" or exit_event.getCause() == "user interrupt received" or exit_event.getCause() == "simulate() limit reached" - or "exiting with last active thread context" in exit_event.getCause() + or "exiting with last active thread context" in exit_event.getCause() ): print(f"breaking loop due to: {exit_event.getCause()}.") break @@ -1045,9 +1045,7 @@ while True: m5.stats.dump() m5.stats.reset() else: - print( - f"Unknown exit event: {exit_event.getCause()}. Continuing..." - ) + print(f"Unknown exit event: {exit_event.getCause()}. Continuing...") exit_event = m5.simulate(maxtick - m5.curTick()) From 0ebcddea95a496388d76b348bc42ea106305ff3d Mon Sep 17 00:00:00 2001 From: Jarvis Jia Date: Wed, 12 Jun 2024 15:54:13 -0500 Subject: [PATCH 3/4] Update apu_se.py to remove part not needed Change-Id: I06df4e0a67ccd2b7a45296ff65bf26c2b465a934 --- configs/example/apu_se.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/configs/example/apu_se.py b/configs/example/apu_se.py index 0319ad127e..98f4502973 100644 --- a/configs/example/apu_se.py +++ b/configs/example/apu_se.py @@ -1032,10 +1032,6 @@ while True: print("GPU Blit Kernel Completed dump and reset") m5.stats.dump() m5.stats.reset() - elif "Skipping GPU Kernel" in exit_event.getCause(): - print("Skipping GPU Kernel dump and reset") - m5.stats.dump() - m5.stats.reset() elif "workbegin" in exit_event.getCause(): print("m5 work begin dump and reset") m5.stats.dump() From b6b2e8c6c506112841fe244b8da661c1630c1447 Mon Sep 17 00:00:00 2001 From: Jarvis Jia Date: Wed, 12 Jun 2024 15:57:04 -0500 Subject: [PATCH 4/4] Black format Change-Id: If224c106262bae25127675160ea78386eedace3b --- configs/example/apu_se.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/configs/example/apu_se.py b/configs/example/apu_se.py index 98f4502973..eb7c625cad 100644 --- a/configs/example/apu_se.py +++ b/configs/example/apu_se.py @@ -894,9 +894,9 @@ gpu_port_idx = gpu_port_idx - args.num_cp * 2 token_port_idx = 0 for i in range(len(system.ruby._cpu_ports)): if isinstance(system.ruby._cpu_ports[i], VIPERCoalescer): - system.cpu[shader_idx].CUs[token_port_idx].gmTokenPort = ( - system.ruby._cpu_ports[i].gmTokenPort - ) + system.cpu[shader_idx].CUs[ + token_port_idx + ].gmTokenPort = system.ruby._cpu_ports[i].gmTokenPort token_port_idx += 1 wavefront_size = args.wf_size