Enable rocpd output format with rocprofiler sdk (#790)

* Add `rocpd` choice for `--format-rocprof-output` option
* Add rocpd_data.py which defines SQL queries to extract data from rocpd database
* Use sqlite3 package to read the database
* Add `--retain-rocpd-output` option in profile mode to retain raw
  rocpd database
* Add warning notice to say `--format-rocprof-output rocpd` will be
  default in future release

For rocpd output:
* Use only `pmc_perf.csv` instead of reading individual coll_level results csv files
* Post process csv files using pandas in analysis mode instead of profile mode
* Use ACCUM counters instead of SQ_ACCUM_PREV_HIRES

* Add test cases for rocpd output format
* Fix code formatting issues
* Update CHANGELOG

[ROCm/rocprofiler-compute commit: 03d27c0ba0]
このコミットが含まれているのは:
vedithal-amd
2025-07-28 11:02:28 -04:00
committed by GitHub
コミット 17e5892614
39個のファイルの変更19428行の追加37行の削除
+16 -7
ファイルの表示
@@ -271,7 +271,7 @@ class CodeTransformer(ast.NodeTransformer):
return node
def build_eval_string(equation, coll_level):
def build_eval_string(equation, coll_level, config):
"""
Convert user defined equation string to eval executable string
For example,
@@ -314,7 +314,14 @@ def build_eval_string(equation, coll_level):
# use .get() to catch any potential KeyErrors
s = re.sub(r"raw_pmc_df\['(.*?)']", r'raw_pmc_df.get("\1")', s)
# apply coll_level
s = re.sub(r"raw_pmc_df", "raw_pmc_df.get('" + coll_level + "')", s)
if config.get("format_rocprof_output") == "rocpd":
# Replace SQ_ACCUM_PREV_HIRES with coll_level_ACCUM then ignore coll_level df
s = re.sub(f"SQ_ACCUM_PREV_HIRES", f"{coll_level}_ACCUM", s)
s = re.sub(
r"raw_pmc_df", "raw_pmc_df.get('" + schema.pmc_perf_file_prefix + "')", s
)
else:
s = re.sub(r"raw_pmc_df", "raw_pmc_df.get('" + coll_level + "')", s)
# print("--- build_eval_string, return: ", s)
return s
@@ -653,7 +660,7 @@ def build_dfs(archConfigs, filter_metrics, sys_info):
setattr(archConfigs, "metric_counters", metric_counters)
def build_metric_value_string(dfs, dfs_type, normal_unit):
def build_metric_value_string(dfs, dfs_type, normal_unit, profiling_config):
"""
Apply the real eval string to its field in the metric_table df.
"""
@@ -674,6 +681,7 @@ def build_metric_value_string(dfs, dfs_type, normal_unit):
df.at[row_idx_label, expr] = build_eval_string(
df.at[row_idx_label, expr],
df.at[row_idx_label, "coll_level"],
profiling_config,
)
elif expr.lower() == "unit" or expr.lower() == "units":
@@ -683,7 +691,7 @@ def build_metric_value_string(dfs, dfs_type, normal_unit):
@demarcate
def eval_metric(dfs, dfs_type, sys_info, raw_pmc_df, debug):
def eval_metric(dfs, dfs_type, sys_info, raw_pmc_df, debug, config):
"""
Execute the expr string for each metric in the df.
"""
@@ -784,7 +792,7 @@ def eval_metric(dfs, dfs_type, sys_info, raw_pmc_df, debug):
if "PER_XCD" not in key:
continue
# NB: assume all built-in vars from pmc_perf.csv for now
s = build_eval_string(value, schema.pmc_perf_file_prefix)
s = build_eval_string(value, schema.pmc_perf_file_prefix, config)
try:
ammolite__build_in[key] = eval(compile(s, "<string>", "eval"))
except TypeError:
@@ -801,7 +809,7 @@ def eval_metric(dfs, dfs_type, sys_info, raw_pmc_df, debug):
if "PER_XCD" in key:
continue
# NB: assume all built-in vars from pmc_perf.csv for now
s = build_eval_string(value, schema.pmc_perf_file_prefix)
s = build_eval_string(value, schema.pmc_perf_file_prefix, config)
try:
ammolite__build_in[key] = eval(compile(s, "<string>", "eval"))
except TypeError:
@@ -1437,7 +1445,7 @@ def load_kernel_top(workload, dir, args):
@demarcate
def load_table_data(workload, dir, is_gui, args, skipKernelTop=False):
def load_table_data(workload, dir, is_gui, args, config, skipKernelTop=False):
"""
- Load data for all "raw_csv_table"
- Load dat for "pc_sampling_table"
@@ -1452,6 +1460,7 @@ def load_table_data(workload, dir, is_gui, args, skipKernelTop=False):
workload.sys_info.iloc[0],
apply_filters(workload, dir, is_gui, args.debug),
args.debug,
config,
)