Improve block filtering to accept metric ids (#821)

* Fix tests
* Update CHANGELOG and documentation

[ROCm/rocprofiler-compute commit: a70ae40ddc]
This commit is contained in:
vedithal-amd authored and GitHub committed 2025-07-23 16:16:29 -04:00
1 parent f6f3a6ed3e
commit d9da3feadf
8 files changed
+226 -127

No files matched your search

@@ -31,7 +31,7 @@ from tabulate import tabulate
from config import HIDDEN_COLUMNS, HIDDEN_SECTIONS
from utils import mem_chart, parser
from utils.logger import console_error, console_log, console_warning
from utils.utils import convert_metric_id_to_panel_idx
from utils.utils import convert_metric_id_to_panel_info
def string_multiple_lines(source, width, max_rows):
@@ -71,9 +71,9 @@ def show_all(args, runs, archConfigs, output, profiling_config, roof_plot=None):
name for name, type in filter_panel_ids.items() if type == "metric_id"
]
filter_panel_ids = [
convert_metric_id_to_panel_idx(section) for section in filter_panel_ids
int(convert_metric_id_to_panel_info(metric_id)[0])
for metric_id in filter_panel_ids
]
comparable_columns = parser.build_comparable_columns(args.time_unit)
for panel_id, panel in archConfigs.panel_configs.items():
# Skip panels that don't support baseline comparison
@@ -1536,16 +1536,50 @@ def merge_counters_spatial_multiplex(df_multi_index):
return final_df
def convert_metric_id_to_panel_idx(metric_id):
# "4.02" -> 402
# "4.23" -> 423
# "4" -> 400
def convert_metric_id_to_panel_info(metric_id):
"""
Convert metric id into panel information.
Output is a tuples of the form (file_id, panel_id, metric_id).
For example:
Input: "2"
Output: ("0200", None, None)
Input: "11"
Output: ("1100", None, None)
Input: "11.1"
Output: ("1100", 1101, None)
Input: "11.1.1"
Output: ("1100", 1101, 1)
Raises exception for invalid metric id.
"""
tokens = metric_id.split(".")
if len(tokens) == 1:
return int(tokens[0]) * 100
if len(tokens) == 2:
return int(tokens[0]) * 100 + int(tokens[1])
raise Exception(f"Invalid metric id: {metric_id}")
if 0 < len(tokens) < 4:
# File id
file_id = str(int(tokens[0]))
# 4 -> 04
if len(file_id) == 1:
file_id = f"0{file_id}"
# Multiply integer by 100
file_id = f"{file_id}00"
# Panel id
if len(tokens) > 1:
panel_id = int(tokens[0]) * 100
panel_id += int(tokens[1])
else:
panel_id = None
# Metric id
if len(tokens) > 2:
metric_id = int(tokens[2])
else:
metric_id = None
return (file_id, panel_id, metric_id)
else:
raise Exception(f"Invalid metric id: {metric_id}")
def format_time(seconds):