viz/cli: select kernel events in -s DEV (#15909)

* simple test

* pass
This commit is contained in:
qazal 2026-04-24 15:03:34 +03:00 committed by GitHub
commit 5eb641395a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 2 deletions

View file

@ -2,7 +2,7 @@
import unittest, pickle
from typing import Iterator
from pathlib import Path
from tinygrad.helpers import DEBUG, getenv, temp, ansistrip
from tinygrad.helpers import DEBUG, getenv, temp, ansistrip, Context
from tinygrad.renderer.amd.sqtt import print_packets, map_insts
from tinygrad.runtime.autogen.amd.rdna3.ins import s_endpgm
from tinygrad.viz.serve import sqtt_timeline
@ -120,6 +120,9 @@ class TestSQTTMapBase(unittest.TestCase):
for r in lines[2:]:
parts = r.split()
self.assertTrue(parts[0].isdigit(), f"expected clock timestamp, got {parts[0]}")
with Context(DEBUG=2):
kernels = run_cli("--profile", "--profile-path", str(pkl_path), "-s", "AMD").split("\n")
self.assertEqual(len(kernels), len(self.examples[pkl_path.stem][1]))
class TestSQTTMapRDNA3(TestSQTTMapBase): target = "gfx1100"

View file

@ -139,7 +139,7 @@ def main(args) -> None:
# ** Profiler printer
else:
timelines = [(n,l) for n,l in profile["layout"].items() if l.get("event_type") == 0]
timelines = [(n,l) for n,l in profile["layout"].items() if isinstance(l, dict) and l.get("event_type") == 0]
def produce_top_kernels() -> Iterator[dict]:
tagged = ((n,e) for n,l in timelines for e in l["events"]) if args.src == "ALL" else ((args.src,e) for e in unwrap(data)["events"])
agg:dict[tuple[str,str], tuple[float, int, int|None]] = {} # map (device, kernel name) to (total time, count and ref)