From ec4359658bdd8956525da213344e08d687a85b8b Mon Sep 17 00:00:00 2001 From: vedithal-amd Date: Tue, 18 Mar 2025 11:26:45 -0400 Subject: [PATCH] Fix kernel filtering when using rocprofv3 (#615) When using rocprof v3: * Use --kernel-include-regex for kernel name filtering * Use --kernel-iteration-range for kernel dispatch filtering Update changelog [ROCm/rocprofiler-compute commit: 45b8937d5d1884112f8f100cee41142136e18932] --- projects/rocprofiler-compute/CHANGELOG.md | 5 +++++ .../profiler_rocprof_v3.py | 19 ++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/projects/rocprofiler-compute/CHANGELOG.md b/projects/rocprofiler-compute/CHANGELOG.md index 4b874b464f..558a605c7e 100644 --- a/projects/rocprofiler-compute/CHANGELOG.md +++ b/projects/rocprofiler-compute/CHANGELOG.md @@ -21,6 +21,11 @@ Full documentation for ROCm Compute Profiler is available at [https://rocm.docs. ### Resolved issues * Fixed option specs-correction +* Fixed kernel name and kernel dispatch filtering when using rocprof v3 + +### Known issues + +* gpu id filtering is not supported when using rocprof v3 ## (Unreleased) ROCm Compute Profiler 3.1.0 for ROCm 6.4.0 diff --git a/projects/rocprofiler-compute/src/rocprof_compute_profile/profiler_rocprof_v3.py b/projects/rocprofiler-compute/src/rocprof_compute_profile/profiler_rocprof_v3.py index da14ff2e5c..5344f89f91 100644 --- a/projects/rocprofiler-compute/src/rocprof_compute_profile/profiler_rocprof_v3.py +++ b/projects/rocprofiler-compute/src/rocprof_compute_profile/profiler_rocprof_v3.py @@ -71,8 +71,25 @@ class rocprof_v3_profiler(RocProfCompute_Base): trace_option, "--output-format", rocprof_out_format, - "--", ] + # Kernel filtering + if self.get_args().kernel: + args.extend(["--kernel-include-regex", "|".join(self.get_args().kernel)]) + # Dispatch filtering + dispatch = [] + # rocprofv3 dispatch indexing is inclusive and starts from 1 + if self.get_args().dispatch: + for dispatch_id in self.get_args().dispatch: + if ":" in dispatch_id: + tokens = dispatch_id.split(":") + # 4:7 -> 5-7 + dispatch.append(f"{int(tokens[0]) + 1}-{tokens[1]}") + else: + # 4 -> 5 + dispatch.append(f"{int(dispatch_id) + 1}") + if dispatch: + args.extend(["--kernel-iteration-range", f"[{','.join(dispatch)}]"]) + args.append("--") args.extend(app_cmd) return args