Remove hardware IP block based filtering (#820)

* Analysis report block based filtering is the default now

* Update documentation

* Update CHANGELOG

* Fix tests
    * Replace hardware block based filtering tests with report block
      based filtering tests
This commit is contained in:
vedithal-amd
2025-07-21 09:37:35 -04:00
committed by GitHub
parent 537a269e95
commit 98bb0f4237
15 changed files with 52 additions and 1190 deletions
+4 -30
View File
@@ -178,50 +178,24 @@ Examples:
help="\t\t\tDispatch ID filtering.",
)
class AggregateDict(argparse.Action):
def __call__(self, parser, namespace, values, option_string=None):
aggregated_dict = getattr(namespace, self.dest, {})
if aggregated_dict is None:
aggregated_dict = {}
for key, value in values:
aggregated_dict[key] = value
setattr(namespace, self.dest, aggregated_dict)
def validate_block(value):
# Metric id regex, for example, 10, 4, 4.3, 4.32
# Dont allow more than two digits after decimal point
metric_id_pattern = re.compile(r"^\d+$|^\d+\.\d$|^\d+\.\d\d$")
# Allow only the following hardware blocks
hardware_block_pattern = re.compile(r"^(SQ|SQC|TA|TD|TCP|TCC|SPI|CPC|CPF)$")
if metric_id_pattern.match(value):
return (str(value), "metric_id")
if hardware_block_pattern.match(value):
return (str(value), "hardware_block")
raise argparse.ArgumentTypeError(f"Invalid hardware block or metric id: {value}")
return value
raise argparse.ArgumentTypeError(f"Invalid metric id: {value}")
profile_group.add_argument(
"-b",
"--block",
type=validate_block,
action=AggregateDict,
dest="filter_blocks",
metavar="",
nargs="+",
required=False,
default={},
help="""\t\t\tSpecify metric id(s) from --list-metrics for filtering (e.g. 10, 4, 4.3).
\t\t\tCan provide multiple space separated arguments.
\t\t\tCan also accept Hardware blocks.
\t\t\tHardware block filtering (to be deprecated soon):
\t\t\t SQ
\t\t\t SQC
\t\t\t TA
\t\t\t TD
\t\t\t TCP
\t\t\t TCC
\t\t\t SPI
\t\t\t CPC
\t\t\t CPF""",
default=[],
help="""\t\t\tSpecify metric id(s) from --list-metrics for filtering (e.g. 10, 4, 4.3).\n\t\t\tCan provide multiple space separated arguments.""",
)
profile_group.add_argument(
"--list-metrics",
-8
View File
@@ -246,14 +246,6 @@ class RocProfCompute:
if self.__args.name.find("/") != -1:
console_error("'/' not permitted in profile name")
# Deprecation warning for hardware blocks
if [
name
for name, type in self.__args.filter_blocks.items()
if type == "hardware_block"
]:
console_warning("Hardware block based filtering will be deprecated soon")
# FIXME:
# Changing default path should be done at the end of arg parsing stage,
# unless there is a specific reason to do here.
+6 -23
View File
@@ -56,14 +56,6 @@ class RocProfCompute_Base:
self.__profiler = profiler_mode
self.__supported_archs = supported_archs
self._soc = soc # OmniSoC obj
self.__filter_hardware_blocks = [
name for name, type in args.filter_blocks.items() if type == "hardware_block"
]
self.__filter_metric_ids = [
name for name, type in args.filter_blocks.items() if type == "metric_id"
]
# Fixme: remove the hack code "21" after we could enable pc sampling as default
self.__pc_sampling = True if "21" in self.__filter_metric_ids else False
def get_args(self):
return self.__args
@@ -309,14 +301,8 @@ class RocProfCompute_Base:
gen_sysinfo(
workload_name=self.__args.name,
workload_dir=self.get_args().path,
ip_blocks=[
name
for name, type in self.__args.filter_blocks.items()
if type == "hardware_block"
],
app_cmd=self.__args.remaining,
skip_roof=self.__args.no_roof,
roof_only=self.__args.roof_only,
mspec=self._soc._mspec,
soc=self._soc,
)
@@ -336,14 +322,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.__filter_hardware_blocks == None:
console_log("Hardware Blocks: All")
else:
console_log("Hardware Blocks: " + str(self.__filter_hardware_blocks))
if self.__filter_metric_ids == None:
if self.get_args().filter_blocks is None:
console_log("Report Sections: All")
else:
console_log("Report Sections: " + str(self.__filter_metric_ids))
console_log("Report Sections: " + str(self.get_args().filter_blocks))
msg = "Collecting Performance Counters"
(
@@ -443,7 +425,8 @@ class RocProfCompute_Base:
else:
console_error("Profiler not supported")
total_profiling_time_so_far += actual_profiling_duration
if self.__pc_sampling == True and self.__profiler in (
# PC sampling data is only collected when block "21" is specified
if "21" in self.get_args().filter_blocks and self.__profiler in (
"rocprofv3",
"rocprofiler-sdk",
):
@@ -460,8 +443,8 @@ class RocProfCompute_Base:
pc_sampling_duration = end_run_prof - start_run_prof
console_debug(
"The time of pc sampling profiling is {} m {} sec".format(
int((end_run_prof - start_run_prof) / 60),
str((end_run_prof - start_run_prof) % 60),
int((pc_sampling_duration) / 60),
str((pc_sampling_duration) % 60),
)
)
+5 -21
View File
@@ -267,13 +267,8 @@ class OmniSoC_Base:
)
if filename.endswith(".yaml")
}
metric_ids = [
name
for name, type in self.get_args().filter_blocks.items()
if type == "metric_id"
]
file_ids = []
for section in metric_ids:
for section in self.get_args().filter_blocks:
section_num = convert_metric_id_to_panel_idx(section)
file_id = str(section_num // 100)
# Convert "4" to "04"
@@ -282,16 +277,17 @@ class OmniSoC_Base:
file_ids.append(file_id)
# Apply sub section filtering
for config_filename in config_filenames:
if config_filename.startswith(file_id) and section_num % 100:
# If first two characters of the config filename match the file_id
if config_filename[:2].startswith(file_id) and section_num % 100:
config_filenames[config_filename].append(section_num)
# Apply section filters only if metric ids have been provided for filtering
if metric_ids:
if self.get_args().filter_blocks:
# Identify yaml files corresponding to file_ids
config_filenames = {
filename: subsections
for filename, subsections in config_filenames.items()
if filename.startswith(tuple(file_ids))
if filename[:2].startswith(tuple(file_ids))
}
for config_filename, subsections in config_filenames.items():
@@ -362,18 +358,6 @@ class OmniSoC_Base:
counters = counters.union(set(m.group(1).split()))
else:
counters = self.detect_counters()
# Perfmon hardware block filtering
filter_hardware_blocks = [
name
for name, type in self.get_args().filter_blocks.items()
if type == "hardware_block"
]
if filter_hardware_blocks:
counters = {
counter_name
for counter_name in counters
if counter_name.startswith(tuple(filter_hardware_blocks))
}
if not using_v3():
# Counters not supported in rocprof v1 / v2
+7 -6
View File
@@ -306,13 +306,14 @@ def process_panels_to_dataframes(
"""
comparable_columns = build_comparable_columns(args.time_unit)
filter_panel_ids = [
convert_metric_id_to_panel_idx(section)
for section in [
name
for name, type in profiling_config.get("filter_blocks", {}).items()
if type == "metric_id"
filter_panel_ids = profiling_config.get("filter_blocks", [])
if isinstance(filter_panel_ids, dict):
# For backward compatibility
filter_panel_ids = [
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
]
# Initialize the result structure
+7 -6
View File
@@ -64,13 +64,14 @@ def show_all(args, runs, archConfigs, output, profiling_config, roof_plot=None):
Show all panels with their data in plain text mode.
"""
comparable_columns = parser.build_comparable_columns(args.time_unit)
filter_panel_ids = [
convert_metric_id_to_panel_idx(section)
for section in [
name
for name, type in profiling_config.get("filter_blocks", {}).items()
if type == "metric_id"
filter_panel_ids = profiling_config.get("filter_blocks", [])
if isinstance(filter_panel_ids, dict):
# For backward compatibility
filter_panel_ids = [
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
]
comparable_columns = parser.build_comparable_columns(args.time_unit)
+4 -12
View File
@@ -1142,9 +1142,7 @@ def replace_timestamps(workload_dir):
)
def gen_sysinfo(
workload_name, workload_dir, ip_blocks, app_cmd, skip_roof, roof_only, mspec, soc
):
def gen_sysinfo(workload_name, workload_dir, app_cmd, skip_roof, mspec, soc):
console_debug("[gen_sysinfo]")
df = mspec.get_class_members()
@@ -1152,12 +1150,7 @@ def gen_sysinfo(
df["command"] = app_cmd
df["workload_name"] = workload_name
blocks = []
if not ip_blocks:
t = ["SQ", "LDS", "SQC", "TA", "TD", "TCP", "TCC", "SPI", "CPC", "CPF"]
blocks += t
else:
blocks += ip_blocks
blocks = ["SQ", "LDS", "SQC", "TA", "TD", "TCP", "TCC", "SPI", "CPC", "CPF"]
if hasattr(soc, "roofline_obj") and (not skip_roof):
blocks.append("roofline")
df["ip_blocks"] = "|".join(blocks)
@@ -1550,10 +1543,9 @@ def convert_metric_id_to_panel_idx(metric_id):
tokens = metric_id.split(".")
if len(tokens) == 1:
return int(tokens[0]) * 100
elif len(tokens) == 2:
if len(tokens) == 2:
return int(tokens[0]) * 100 + int(tokens[1])
else:
raise Exception(f"Invalid metric id: {metric_id}")
raise Exception(f"Invalid metric id: {metric_id}")
def format_time(seconds):