From dfe74057c130dc1bcc84f5014c1f1274a4d2d052 Mon Sep 17 00:00:00 2001 From: "fei.zheng" Date: Wed, 3 May 2023 11:46:17 -0600 Subject: [PATCH 1/5] allow to specify the maximum number of kernels shown Signed-off-by: fei.zheng --- src/omniperf_analyze/omniperf_analyze.py | 6 ++---- src/omniperf_analyze/utils/file_io.py | 6 +++--- src/parser.py | 8 ++++++++ 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/omniperf_analyze/omniperf_analyze.py b/src/omniperf_analyze/omniperf_analyze.py index 7cb6b3bf62..e8b93edf0e 100644 --- a/src/omniperf_analyze/omniperf_analyze.py +++ b/src/omniperf_analyze/omniperf_analyze.py @@ -138,13 +138,12 @@ def run_gui(args, runs): app = dash.Dash(__name__, external_stylesheets=[dbc.themes.CYBORG]) if len(runs) == 1: - num_results = 10 file_io.create_df_kernel_top_stats( args.path[0][0], runs[args.path[0][0]].filter_gpu_ids, runs[args.path[0][0]].filter_dispatch_ids, args.time_unit, - num_results, + args.max_kernel_num, ) runs[args.path[0][0]].raw_pmc = file_io.create_df_pmc( args.path[0][0], args.verbose @@ -187,13 +186,12 @@ def run_cli(args, runs): # which archConfig passed into show_all function. # After decide to how to manage kernels display patterns, we can revisit it. for d in args.path: - num_results = 10 file_io.create_df_kernel_top_stats( d[0], runs[d[0]].filter_gpu_ids, runs[d[0]].filter_dispatch_ids, args.time_unit, - num_results, + args.max_kernel_num, ) runs[d[0]].raw_pmc = file_io.create_df_pmc( d[0], args.verbose diff --git a/src/omniperf_analyze/utils/file_io.py b/src/omniperf_analyze/utils/file_io.py index 05219dbcca..714d6016c3 100644 --- a/src/omniperf_analyze/utils/file_io.py +++ b/src/omniperf_analyze/utils/file_io.py @@ -111,7 +111,7 @@ def create_df_kernel_top_stats( filter_gpu_ids, filter_dispatch_ids, time_unit, - num_results, + max_kernel_num, sortby="sum", ): """ @@ -172,13 +172,13 @@ def create_df_kernel_top_stats( if sortby == "sum": grouped = grouped.sort_values(by=("Sum" + time_unit_str), ascending=False) - grouped = grouped.head(num_results) # Display only the top n results + grouped = grouped.head(max_kernel_num) # Display only the top n results grouped.to_csv(os.path.join(raw_data_dir, "pmc_kernel_top.csv"), index=False) elif sortby == "kernel": grouped = grouped.sort_values("KernelName") - grouped = grouped.head(num_results) # Display only the top n results + grouped = grouped.head(max_kernel_num) # Display only the top n results grouped.to_csv(os.path.join(raw_data_dir, "pmc_kernel_top.csv"), index=False) diff --git a/src/parser.py b/src/parser.py index a18ad5d22b..5a614d9652 100644 --- a/src/parser.py +++ b/src/parser.py @@ -445,6 +445,14 @@ def parse(my_parser): choices=["per_wave", "per_cycle", "per_second", "per_kernel"], help="\t\tSpecify the normalization unit: (DEFAULT: per_wave)\n\t\t per_wave\n\t\t per_cycle\n\t\t per_second\n\t\t per_kernel", ) + analyze_group.add_argument( + "--max-kernel-num", + dest="max_kernel_num", + metavar="", + type=int, + default=10, + help="\t\tSpecify the maximum number of kernels shown", + ) analyze_group.add_argument( "--config-dir", dest="config_dir", From c5c829fa1b12a76431ac3f1566d5b19fca211b85 Mon Sep 17 00:00:00 2001 From: Cole Ramos Date: Tue, 9 May 2023 12:42:12 -0500 Subject: [PATCH 2/5] Update src/parser.py Signed-off-by: Cole Ramos --- src/parser.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/parser.py b/src/parser.py index 5a614d9652..dd44d6a921 100644 --- a/src/parser.py +++ b/src/parser.py @@ -451,7 +451,7 @@ def parse(my_parser): metavar="", type=int, default=10, - help="\t\tSpecify the maximum number of kernels shown", + help="\t\tSpecify the maximum number of kernels shown (DEFAULT: 10)", ) analyze_group.add_argument( "--config-dir", From dbae98e2674303c8a6294277d63de39badb9ac58 Mon Sep 17 00:00:00 2001 From: Cole Ramos Date: Tue, 9 May 2023 14:04:33 -0500 Subject: [PATCH 3/5] Pass max_kernel_num to GUI Signed-off-by: colramos --- src/omniperf_analyze/omniperf_analyze.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/omniperf_analyze/omniperf_analyze.py b/src/omniperf_analyze/omniperf_analyze.py index e8b93edf0e..edea1d2d7c 100644 --- a/src/omniperf_analyze/omniperf_analyze.py +++ b/src/omniperf_analyze/omniperf_analyze.py @@ -155,6 +155,7 @@ def run_gui(args, runs): "gpu": runs[args.path[0][0]].filter_gpu_ids, "dispatch": runs[args.path[0][0]].filter_dispatch_ids, "normalization": args.normal_unit, + "top_n": args.max_kernel_num, } gui.build_layout( From 41affd6343161e811376e0a512ad3fa3c68c83d1 Mon Sep 17 00:00:00 2001 From: Cole Ramos Date: Tue, 9 May 2023 14:09:44 -0500 Subject: [PATCH 4/5] Add TopN to standalone GUI callback function Signed-off-by: colramos --- src/omniperf_analyze/utils/gui.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/omniperf_analyze/utils/gui.py b/src/omniperf_analyze/utils/gui.py index 69c4484507..ca05bd3ea8 100644 --- a/src/omniperf_analyze/utils/gui.py +++ b/src/omniperf_analyze/utils/gui.py @@ -423,10 +423,11 @@ def build_layout( [Input("kernel-filt", "value")], [Input("gcd-filt", "value")], [Input("norm-filt", "value")], + [Input("top-n-filt", "value")], [State("container", "children")], ) def generate_from_filter( - disp_filt, kernel_filter, gcd_filter, norm_filt, div_children + disp_filt, kernel_filter, gcd_filter, norm_filt, top_n_filt, div_children ): if verbose >= 1: print("normalization is ", norm_filt) @@ -438,18 +439,19 @@ def build_layout( if verbose >= 1: print("disp-filter is ", disp_filt) print("kernel-filter is ", kernel_filter) - print("gpu-filter is ", gcd_filter, "\n") + print("gpu-filter is ", gcd_filter) + print("top-n kernel filter is ", top_n_filter, "\n") base_data[base_run].filter_kernel_ids = kernel_filter base_data[base_run].filter_gpu_ids = gcd_filter base_data[base_run].filter_dispatch_ids = disp_filt + base_data[base_run].filter_top_n = top_n_filt # Reload the pmc_kernel_top.csv for Top Stats panel - num_results = 10 file_io.create_df_kernel_top_stats( path_to_dir, base_data[base_run].filter_gpu_ids, base_data[base_run].filter_dispatch_ids, time_unit, - num_results, + base_data[base_run].filter_top_n, ) is_gui = True # Only display basic metrics if no filters are applied From 8e9e8a42f3fdeb58d0fa6f5d961ca625ce175d6a Mon Sep 17 00:00:00 2001 From: Cole Ramos Date: Tue, 9 May 2023 14:12:19 -0500 Subject: [PATCH 5/5] Add TopN dropdown to GUI navbar Signed-off-by: colramos --- .../utils/gui_components/header.py | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/omniperf_analyze/utils/gui_components/header.py b/src/omniperf_analyze/utils/gui_components/header.py index 6723a26c43..3ace4451d1 100644 --- a/src/omniperf_analyze/utils/gui_components/header.py +++ b/src/omniperf_analyze/utils/gui_components/header.py @@ -234,6 +234,28 @@ def get_header(raw_pmc, input_filters, kernel_names): ) ], ), + html.Li( + className="filter", + children=[ + html.Div( + children=[ + html.A( + className="smoothscroll", + children=["Top N:"], + ), + dcc.Dropdown( + [1, 5, 10, 15, 20, 50, 100], + id="top-n-filt", + value=input_filters[ + "top_n" + ], # default to any dispatch filters passed as args + clearable=False, + style={"width": "50px"}, + ), + ] + ) + ], + ), html.Li( className="filter", children=[