Enable single pass counter collection (#833)

[ROCm/rocprofiler-compute commit: 6a77d241ed]
This commit is contained in:
xuchen-amd authored and GitHub committed 2025-08-06 10:35:05 -04:00
1 parent 5084aad00b
commit 34dd26fb07
18 files changed
+778 -56

No files matched your search

+14 -2
View File
@@ -27,12 +27,11 @@
import argparse
import os
import re
import shutil
from pathlib import Path
def print_avail_arch(avail_arch: list):
ret_str = "\t\tList all available metrics for analysis on specified arch:"
ret_str = "\t\t\tList all available metrics for analysis on specified arch:"
for arch in avail_arch:
ret_str += "\n\t\t\t {}".format(arch)
return ret_str
@@ -207,6 +206,19 @@ Examples:
choices=[""] + list(supported_archs.keys()), # ["gfx908", "gfx90a"],
help=print_avail_arch(supported_archs.keys()),
)
profile_group.add_argument(
"--list-sets",
action="store_true",
help="\t\t\tDisplay available metric sets and their descriptions",
)
profile_group.add_argument(
"--set",
default=None,
dest="set_selected",
help="\t\t\tProfile a set of metrics of topic of interest by collecting counters in a single pass.\n\t\t\tFor available sets, see --list-sets",
)
profile_group.add_argument(
"--config-dir",
dest="config_dir",
@@ -27,7 +27,6 @@
import argparse
import importlib
import os
import shutil
import socket
import sys
import time
@@ -55,6 +54,7 @@ from utils.utils import (
get_submodules,
get_version,
get_version_display,
parse_sets_yaml,
set_locale_encoding,
)
@@ -243,6 +243,53 @@ class RocProfCompute:
else:
console_error("Unsupported arch")
@demarcate
def list_sets(self):
sets_info = parse_sets_yaml(self.__mspec.gpu_arch)
if not sets_info:
console_error("No sets configuration found.")
print("\nAvailable Sets:")
print("=" * 115)
# Print header
print(
f"{'Set Option':<35} {'Set Title':<35} {'Metric Name':<30} {'Metric ID':<10}"
)
print("-" * 115)
# Print data grouped by set
for set_option, set_data in sets_info.items():
title = set_data.get("title", set_option)
metrics = set_data.get("metric", [])
first_row = True
for metric in metrics:
if isinstance(metric, dict) and metric:
metric_id = next(iter(metric.keys()))
metric_name = next(iter(metric.values()))
# Only show set info on first row of each set
set_display = set_option if first_row else ""
title_display = title if first_row else ""
print(
f"{set_display:<35} {title_display:<35} {metric_name:<30} {metric_id:<10}"
)
first_row = False
# Empty line between sets
print()
print("Usage Examples:")
if sets_info:
first_set = next(iter(sets_info.keys()))
print(f" rocprof-compute profile --set {first_set} # Profile this set")
print(f" rocprof-compute profile --list-sets # Show this help")
print()
sys.exit(0)
@demarcate
def run_profiler(self):
self.print_graphic()
@@ -250,6 +297,8 @@ class RocProfCompute:
if self.__args.list_metrics is not None:
self.list_metrics()
elif self.__args.list_sets:
self.list_sets()
elif self.__args.name is None:
sys.exit("Either --list-name or --name is required")
@@ -26,13 +26,12 @@
import csv
import glob
import logging
import os
import re
import shlex
import shutil
import time
from abc import ABC, abstractmethod
from abc import abstractmethod
from pathlib import Path
import pandas as pd
@@ -350,6 +349,10 @@ class RocProfCompute_Base:
console_log("Command: " + str(self.__args.remaining))
console_log("Kernel Selection: " + str(self.__args.kernel))
console_log("Dispatch Selection: " + str(self.__args.dispatch))
if self.get_args().set_selected:
console_log("Set Selection: " + str(self.__args.set_selected))
if self.get_args().filter_blocks is None:
console_log("Report Sections: All")
else:
@@ -0,0 +1,37 @@
# AUTOGENERATED FILE. Only edit for testing purposes, not for development. Generated from utils/unified_sets.yaml. Generated by utils/split_config.py
sets:
- title: Compute Throughput Utilization
set_option: compute_thruput_util
description: Placeholder
metric:
- 11.2.2: SALU Utilization
- 11.2.3: VALU Utilization
- title: Compute Throughput FLOPS
set_option: compute_thruput_flops
description: Placeholder
metric:
- 2.1.2: MFMA FLOPs (BF16)
- 2.1.3: MFMA FLOPs (F16)
- 2.1.4: MFMA FLOPs (F32)
- 2.1.5: MFMA FLOPs (F64)
- 2.1.6: MFMA IOPs (Int8)
- title: Memory Throughput
set_option: mem_thruput
description: Placeholder
metric:
- 2.1.16: Theoretical LDS Bandwidth
- 2.1.17: LDS Bank Conflicts/Access
- 16.1.2: Utilization
- 17.1.0: Utilization
- title: Launch Stats
set_option: launch_stats
description: Placeholder
metric:
- 7.1.0: Grid Size
- 7.1.1: Workgroup Size
- 7.1.2: Total Wavefronts
- 7.1.5: VGPRs
- 7.1.6: AGPRs
- 7.1.7: SGPRs
- 7.1.8: LDS Allocation
- 7.1.9: Scratch Allocation
@@ -0,0 +1,39 @@
# AUTOGENERATED FILE. Only edit for testing purposes, not for development. Generated from utils/unified_sets.yaml. Generated by utils/split_config.py
sets:
- title: Compute Throughput Utilization
set_option: compute_thruput_util
description: Placeholder
metric:
- 11.2.3: VALU Utilization
- 11.2.4: VMEM Utilization
- 11.2.5: Branch Utilization
- 11.2.6: VALU Active Threads
- title: Compute Throughput FLOPS
set_option: compute_thruput_flops
description: Placeholder
metric:
- 2.1.2: MFMA FLOPs (BF16)
- 2.1.3: MFMA FLOPs (F16)
- 2.1.4: MFMA FLOPs (F32)
- 2.1.5: MFMA FLOPs (F64)
- 2.1.6: MFMA IOPs (Int8)
- title: Memory Throughput
set_option: mem_thruput
description: Placeholder
metric:
- 2.1.16: Theoretical LDS Bandwidth
- 2.1.17: LDS Bank Conflicts/Access
- 16.1.2: Utilization
- 17.1.0: Utilization
- title: Launch Stats
set_option: launch_stats
description: Placeholder
metric:
- 7.1.0: Grid Size
- 7.1.1: Workgroup Size
- 7.1.2: Total Wavefronts
- 7.1.5: VGPRs
- 7.1.6: AGPRs
- 7.1.7: SGPRs
- 7.1.8: LDS Allocation
- 7.1.9: Scratch Allocation
@@ -0,0 +1,40 @@
# AUTOGENERATED FILE. Only edit for testing purposes, not for development. Generated from utils/unified_sets.yaml. Generated by utils/split_config.py
sets:
- title: Compute Throughput Utilization
set_option: compute_thruput_util
description: Placeholder
metric:
- 11.2.2: SALU Utilization
- 11.2.3: VALU Utilization
- 11.2.4: VMEM Utilization
- 11.2.5: Branch Utilization
- title: Compute Throughput FLOPS
set_option: compute_thruput_flops
description: Placeholder
metric:
- 2.1.2: MFMA FLOPs (F8)
- 2.1.3: MFMA FLOPs (BF16)
- 2.1.4: MFMA FLOPs (F16)
- 2.1.5: MFMA FLOPs (F32)
- 2.1.6: MFMA FLOPs (F64)
- 2.1.7: MFMA IOPs (Int8)
- title: Memory Throughput
set_option: mem_thruput
description: Placeholder
metric:
- 2.1.17: Theoretical LDS Bandwidth
- 2.1.18: LDS Bank Conflicts/Access
- 16.1.2: Utilization
- 17.1.0: Utilization
- title: Launch Stats
set_option: launch_stats
description: Placeholder
metric:
- 7.1.0: Grid Size
- 7.1.1: Workgroup Size
- 7.1.2: Total Wavefronts
- 7.1.5: VGPRs
- 7.1.6: AGPRs
- 7.1.7: SGPRs
- 7.1.8: LDS Allocation
- 7.1.9: Scratch Allocation
@@ -0,0 +1,40 @@
# AUTOGENERATED FILE. Only edit for testing purposes, not for development. Generated from utils/unified_sets.yaml. Generated by utils/split_config.py
sets:
- title: Compute Throughput Utilization
set_option: compute_thruput_util
description: Placeholder
metric:
- 11.2.2: SALU Utilization
- 11.2.3: VALU Utilization
- 11.2.4: VMEM Utilization
- 11.2.5: Branch Utilization
- title: Compute Throughput FLOPS
set_option: compute_thruput_flops
description: Placeholder
metric:
- 2.1.2: MFMA FLOPs (F8)
- 2.1.3: MFMA FLOPs (BF16)
- 2.1.4: MFMA FLOPs (F16)
- 2.1.5: MFMA FLOPs (F32)
- 2.1.6: MFMA FLOPs (F64)
- 2.1.7: MFMA IOPs (Int8)
- title: Memory Throughput
set_option: mem_thruput
description: Placeholder
metric:
- 2.1.17: Theoretical LDS Bandwidth
- 2.1.18: LDS Bank Conflicts/Access
- 16.1.2: Utilization
- 17.1.0: Utilization
- title: Launch Stats
set_option: launch_stats
description: Placeholder
metric:
- 7.1.0: Grid Size
- 7.1.1: Workgroup Size
- 7.1.2: Total Wavefronts
- 7.1.5: VGPRs
- 7.1.6: AGPRs
- 7.1.7: SGPRs
- 7.1.8: LDS Allocation
- 7.1.9: Scratch Allocation
@@ -0,0 +1,40 @@
# AUTOGENERATED FILE. Only edit for testing purposes, not for development. Generated from utils/unified_sets.yaml. Generated by utils/split_config.py
sets:
- title: Compute Throughput Utilization
set_option: compute_thruput_util
description: Placeholder
metric:
- 11.2.2: SALU Utilization
- 11.2.3: VALU Utilization
- 11.2.4: VMEM Utilization
- 11.2.5: Branch Utilization
- title: Compute Throughput FLOPS
set_option: compute_thruput_flops
description: Placeholder
metric:
- 2.1.2: MFMA FLOPs (F8)
- 2.1.3: MFMA FLOPs (BF16)
- 2.1.4: MFMA FLOPs (F16)
- 2.1.5: MFMA FLOPs (F32)
- 2.1.6: MFMA FLOPs (F64)
- 2.1.7: MFMA IOPs (Int8)
- title: Memory Throughput
set_option: mem_thruput
description: Placeholder
metric:
- 2.1.17: Theoretical LDS Bandwidth
- 2.1.18: LDS Bank Conflicts/Access
- 16.1.2: Utilization
- 17.1.0: Utilization
- title: Launch Stats
set_option: launch_stats
description: Placeholder
metric:
- 7.1.0: Grid Size
- 7.1.1: Workgroup Size
- 7.1.2: Total Wavefronts
- 7.1.5: VGPRs
- 7.1.6: AGPRs
- 7.1.7: SGPRs
- 7.1.8: LDS Allocation
- 7.1.9: Scratch Allocation
@@ -0,0 +1,40 @@
# AUTOGENERATED FILE. Only edit for testing purposes, not for development. Generated from utils/unified_sets.yaml. Generated by utils/split_config.py
sets:
- title: Compute Throughput Utilization
set_option: compute_thruput_util
description: Placeholder
metric:
- 11.2.2: SALU Utilization
- 11.2.3: VALU Utilization
- 11.2.5: VMEM Utilization
- 11.2.6: Branch Utilization
- title: Compute Throughput FLOPS
set_option: compute_thruput_flops
description: Placeholder
metric:
- 2.1.2: MFMA FLOPs (F8)
- 2.1.3: MFMA FLOPs (BF16)
- 2.1.4: MFMA FLOPs (F16)
- 2.1.5: MFMA FLOPs (F32)
- 2.1.6: MFMA FLOPs (F64)
- 2.1.8: MFMA IOPs (Int8)
- title: Memory Throughput
set_option: mem_thruput
description: Placeholder
metric:
- 2.1.18: Theoretical LDS Bandwidth
- 2.1.19: LDS Bank Conflicts/Access
- 16.1.2: Utilization
- 17.1.0: Utilization
- title: Launch Stats
set_option: launch_stats
description: Placeholder
metric:
- 7.1.0: Grid Size
- 7.1.1: Workgroup Size
- 7.1.2: Total Wavefronts
- 7.1.5: VGPRs
- 7.1.6: AGPRs
- 7.1.7: SGPRs
- 7.1.8: LDS Allocation
- 7.1.9: Scratch Allocation
@@ -24,7 +24,6 @@
##############################################################################
import ctypes
import glob
import json
import math
@@ -32,7 +31,6 @@ import os
import re
import shutil
import sys
import threading
from abc import abstractmethod
from pathlib import Path
@@ -56,6 +54,7 @@ from utils.utils import (
detect_rocprof,
get_submodules,
is_tcc_channel_counter,
parse_sets_yaml,
using_v3,
)
@@ -277,10 +276,26 @@ class OmniSoC_Base:
Path(filename).name.split("_")[0]: filename
for filename in glob.glob(f"{config_root_dir}/*.yaml")
}
texts = list()
set_selected = self.get_args().set_selected
if set_selected:
# NOTE: --blocks and --set are mutually exclusive
if self.get_args().filter_blocks:
console_error("--block and --set are exclusive options.")
sets_info = parse_sets_yaml(self.__arch)
if set_selected not in set(sets_info.keys()):
console_error(
f"argument --set: invalid choice: '{set_selected}' (choose from {sets_info.keys()})"
)
self.__args.filter_blocks = [
next(iter(metric.keys())) for metric in sets_info[set_selected]["metric"]
]
if not self.get_args().filter_blocks:
# Read all config files if no filter_blocks are specified
for filename in config_filename_dict.values():
with open(filename, "r") as stream:
texts.append(stream.read())
@@ -35,11 +35,8 @@ import re
import selectors
import shutil
import subprocess
import sys
import tempfile
import time
from collections import OrderedDict
from itertools import product
from pathlib import Path as path
from typing import Optional
@@ -1616,3 +1613,25 @@ def format_time(seconds):
if secs > 0 or not parts:
parts.append(f"{secs} second{'s' if secs != 1 else ''}")
return ", ".join(parts[:-1]) + (" and " if len(parts) > 1 else "") + parts[-1]
def parse_sets_yaml(arch):
filename = (
config.rocprof_compute_home
/ "rocprof_compute_soc"
/ "profile_configs"
/ "sets"
/ f"{arch}_sets.yaml"
)
with open(filename, "r") as file:
content = file.read()
data = yaml.safe_load(content)
sets_data = data.get("sets", [])
sets_info = {}
for set_item in sets_data:
set_option = set_item.get("set_option", "")
if set_option:
sets_info[set_option] = set_item
return sets_info