From 6ca9f52cfb60abfe6356409bdd091096ff60de2d Mon Sep 17 00:00:00 2001 From: colramos425 Date: Fri, 13 Jan 2023 13:57:31 -0600 Subject: [PATCH] Update logic in CLI baseline comparison Signed-off-by: colramos425 [ROCm/rocprofiler-compute commit: 03b93fb06b905f449a26d86985bc37ad1ad8b58a] --- .../src/omniperf_analyze/omniperf_analyze.py | 6 ++++-- .../src/omniperf_analyze/utils/file_io.py | 6 +++--- .../src/omniperf_analyze/utils/gui.py | 2 +- .../src/omniperf_analyze/utils/tty.py | 16 ++++++++++------ 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/projects/rocprofiler-compute/src/omniperf_analyze/omniperf_analyze.py b/projects/rocprofiler-compute/src/omniperf_analyze/omniperf_analyze.py index 1d9c18028e..fc7b52a1bb 100644 --- a/projects/rocprofiler-compute/src/omniperf_analyze/omniperf_analyze.py +++ b/projects/rocprofiler-compute/src/omniperf_analyze/omniperf_analyze.py @@ -143,7 +143,8 @@ def run_gui(args, runs): num_results, ) runs[args.path[0][0]].raw_pmc = file_io.create_df_pmc( - args.path[0][0] + args.path[0][0], + args.verbose ) # create mega df parser.load_kernel_top(runs[args.path[0][0]], args.path[0][0]) @@ -188,7 +189,7 @@ def run_cli(args, runs): args.time_unit, num_results, ) - runs[d[0]].raw_pmc = file_io.create_df_pmc(d[0]) # creates mega dataframe + runs[d[0]].raw_pmc = file_io.create_df_pmc(d[0], args.verbose) # creates mega dataframe is_gui = False parser.load_table_data( runs[d[0]], d[0], is_gui, args.g, args.verbose @@ -203,6 +204,7 @@ def run_cli(args, runs): args.decimal, args.time_unit, args.cols, + args.verbose, ) diff --git a/projects/rocprofiler-compute/src/omniperf_analyze/utils/file_io.py b/projects/rocprofiler-compute/src/omniperf_analyze/utils/file_io.py index 802dd82bf0..9b57bbf7d4 100644 --- a/projects/rocprofiler-compute/src/omniperf_analyze/utils/file_io.py +++ b/projects/rocprofiler-compute/src/omniperf_analyze/utils/file_io.py @@ -180,7 +180,7 @@ def create_df_kernel_top_stats( grouped.to_csv(os.path.join(raw_data_dir, "pmc_kernel_top.csv"), index=False) -def create_df_pmc(raw_data_dir): +def create_df_pmc(raw_data_dir, verbose): """ Load all raw pmc counters and join into one df. """ @@ -200,8 +200,8 @@ def create_df_pmc(raw_data_dir): coll_levels.append(f[:-4]) final_df = pd.concat(dfs, keys=coll_levels, axis=1, copy=False) # TODO: join instead of concat! - - # print("pmc_raw_data final_df ", final_df.info()) + if verbose >= 2: + print("pmc_raw_data final_df ", final_df.info()) return final_df diff --git a/projects/rocprofiler-compute/src/omniperf_analyze/utils/gui.py b/projects/rocprofiler-compute/src/omniperf_analyze/utils/gui.py index 181cacbd75..07be15e421 100644 --- a/projects/rocprofiler-compute/src/omniperf_analyze/utils/gui.py +++ b/projects/rocprofiler-compute/src/omniperf_analyze/utils/gui.py @@ -422,7 +422,7 @@ def build_layout( base_data = initialize_run(args, norm_filt) # Re-initalize everything panel_configs = copy.deepcopy(archConfigs.panel_configs) # Generate original raw df - base_data[base_run].raw_pmc = file_io.create_df_pmc(path_to_dir) + base_data[base_run].raw_pmc = file_io.create_df_pmc(path_to_dir, verbose) if verbose >= 1: print("disp-filter is ", disp_filt) print("kernel-filter is ", kernel_filter) diff --git a/projects/rocprofiler-compute/src/omniperf_analyze/utils/tty.py b/projects/rocprofiler-compute/src/omniperf_analyze/utils/tty.py index 0a8befbb98..b84487975b 100644 --- a/projects/rocprofiler-compute/src/omniperf_analyze/utils/tty.py +++ b/projects/rocprofiler-compute/src/omniperf_analyze/utils/tty.py @@ -44,19 +44,20 @@ def string_multiple_lines(source, width, max_rows): return "\n".join(lines) -def show_all(runs, archConfigs, output, decimal, time_unit, selected_cols): +def show_all(runs, archConfigs, output, decimal, time_unit, selected_cols, verbose): """ Show all panels with their data in plain text mode. """ comparable_columns = parser.build_comparable_columns(time_unit) for panel_id, panel in archConfigs.panel_configs.items(): - + # Skip panels that don't support baseline comparison + if panel_id == 1900: + continue ss = "" # store content of all data_source from one pannel for data_source in panel["data source"]: for type, table_config in data_source.items(): - # take the 1st run as baseline base_run, base_data = next(iter(runs.items())) base_df = base_data.dfs[table_config["id"]] @@ -102,18 +103,21 @@ def show_all(runs, archConfigs, output, decimal, time_unit, selected_cols): ): if run != base_run: # calc percentage over the baseline + base_df[header]=[float(x) if x != '' else float(0) for x in base_df[header]] + cur_df[header]=[float(x) if x != '' else float(0) for x in cur_df[header]] t_df = ( pd.concat( [ - base_df[header].astype("double"), - cur_df[header].astype("double"), + base_df[header], + cur_df[header], ], axis=1, ) .pct_change(axis="columns") .iloc[:, 1] ) - # print("---------", header, t_df) + if verbose >= 2: + print("---------", header, t_df) # show value + percentage # TODO: better alignment