CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
71 lines
2.0 KiB
Python
71 lines
2.0 KiB
Python
# Copyright Advanced Micro Devices, Inc., or its affiliates.
|
|
# SPDX-License-Identifier: MIT
|
|
|
|
import os
|
|
import re
|
|
|
|
import gdb
|
|
|
|
FUNCTION = os.environ["KERNEL_NAME"]
|
|
|
|
gdb.execute("set pagination off")
|
|
gdb.execute("set breakpoint pending on")
|
|
|
|
gdb.Breakpoint(FUNCTION + "_exec_begin", temporary=True)
|
|
gdb.execute("run")
|
|
|
|
disasm = gdb.execute(f"disassemble {FUNCTION}", to_string=True)
|
|
|
|
ds_instructions = []
|
|
for line in disasm.splitlines():
|
|
# Match lines like: <+1156>: ds_write_b32 v3, v1
|
|
m = re.search(r"<\+(\d+)>:\s+(ds_\S+)\s+(.*)", line)
|
|
if not m:
|
|
continue
|
|
offset = int(m.group(1))
|
|
mnemonic = m.group(2)
|
|
operands = [op.strip().split()[0] for op in m.group(3).split(",")]
|
|
if mnemonic.startswith("ds_write"):
|
|
addr_reg = operands[0]
|
|
elif mnemonic.startswith("ds_read"):
|
|
addr_reg = operands[1]
|
|
else:
|
|
raise ValueError(f"Unhandled ds_ instruction: {mnemonic}")
|
|
ds_instructions.append({"offset": offset, "reg": addr_reg, "mnemonic": mnemonic})
|
|
|
|
|
|
class WG0Breakpoint(gdb.Breakpoint):
|
|
"""Breakpoint that only stops when the current wave is in workgroup (0,0,0)."""
|
|
|
|
def stop(self):
|
|
pos = str(gdb.parse_and_eval("$_dispatch_pos"))
|
|
return "(0,0,0)/" in pos
|
|
|
|
|
|
for instr in ds_instructions:
|
|
spec = f"*{FUNCTION}+{instr['offset']}"
|
|
print(f"# ${instr['reg']} ({instr['mnemonic']} @ +{instr['offset']})")
|
|
|
|
WG0Breakpoint(spec, temporary=True)
|
|
gdb.execute("continue")
|
|
|
|
# Discover the 4 wave threads of workgroup (0,0,0) by iterating all threads
|
|
# and checking $_dispatch_pos.
|
|
threads = []
|
|
current = gdb.selected_thread()
|
|
for t in gdb.inferiors()[0].threads():
|
|
t.switch()
|
|
if "(0,0,0)/" in str(gdb.parse_and_eval("$_dispatch_pos")):
|
|
threads.append(t.num)
|
|
if len(threads) == 4:
|
|
break
|
|
current.switch()
|
|
|
|
for t in sorted(threads):
|
|
gdb.execute(f"thread {t}")
|
|
gdb.execute("x/i $pc")
|
|
gdb.execute(f"p ${instr['reg']}")
|
|
|
|
gdb.execute("set confirm off")
|
|
gdb.execute("quit")
|