From c45e20f325ac17710b8db88b36da433054964fdd Mon Sep 17 00:00:00 2001 From: cfallows-amd Date: Mon, 7 Apr 2025 12:10:37 -0400 Subject: [PATCH] Fixes for roofline datatype plot outputs (#659) Profile mode: Fix roofline plots for datatypes that have peakVALU only. Check for highest roofline to plot the bandwidth lines to proper height, don't rely on existence of peakMFMA for every datatype. Analyze mode: Add roofline-data-type option for viewing pdfs in standalone gui. Default is same as profile mode, FP32. --------- Signed-off-by: Carrie Fallows --- docs/how-to/analyze/standalone-gui.rst | 5 +++++ src/argparser.py | 15 ++++++++++++++- src/rocprof_compute_analyze/analysis_webui.py | 4 ++++ src/roofline.py | 2 +- src/utils/roofline_calc.py | 18 +++++++++++++----- 5 files changed, 37 insertions(+), 7 deletions(-) diff --git a/docs/how-to/analyze/standalone-gui.rst b/docs/how-to/analyze/standalone-gui.rst index f138c1124f..2e83e3f09e 100644 --- a/docs/how-to/analyze/standalone-gui.rst +++ b/docs/how-to/analyze/standalone-gui.rst @@ -75,6 +75,11 @@ application's profiling data: #. Memory Chart Analysis #. Empirical Roofline Analysis + + Use ``--roofline-data-type`` option to specify which datatype(s) you would like displayed on the roofline PDFs in the standalone analysis GUI. + Datatypes can be stacked- for example, "--roofline-data-type FP32 FP64 I32" would display one PDF with FP32 and FP64 stacked, and one PDF with INT32. + Default roofline datatype plotted is FP32. + #. Top Stats (Top Kernel Statistics) #. System Info #. System Speed-of-Light diff --git a/src/argparser.py b/src/argparser.py index ed17d68790..8ed1c3bdbc 100644 --- a/src/argparser.py +++ b/src/argparser.py @@ -386,7 +386,7 @@ Examples: nargs="+", type=str, default=["FP32"], - help="\t\t\tChoose datatypes to generate plotted roofline PDFs for: (DEFAULT: FP32)\n\t\t\t FP8\n\t\t\t FP16\n\t\t\t BF16\n\t\t\t FP32\n\t\t\t FP64\n\t\t\t I8", + help="\t\t\tChoose datatypes to view roofline PDFs for: (DEFAULT: FP32)\n\t\t\t FP8\n\t\t\t FP16\n\t\t\t BF16\n\t\t\t FP32\n\t\t\t FP64\n\t\t\t I8\n\t\t\t I32\n\t\t\t I64\n\t\t\t ", ) # roofline_group.add_argument('-w', '--workgroups', required=False, default=-1, type=int, help="\t\t\tNumber of kernel workgroups (DEFAULT: 1024)") @@ -591,6 +591,19 @@ Examples: const=8050, help="\t\tActivate a GUI to interate with rocprofiler-compute metrics.\n\t\tOptionally, specify port to launch application (DEFAULT: 8050)", ) + + analyze_group.add_argument( + "-R", + "--roofline-data-type", + required=False, + choices=["FP8", "FP16", "BF16", "FP32", "FP64", "I8", "I32", "I64"], + metavar="", + nargs="+", + type=str, + default=["FP32"], + help="\t\t\tChoose datatypes to view roofline PDFs for: (DEFAULT: FP32)\n\t\t\t FP8\n\t\t\t FP16\n\t\t\t BF16\n\t\t\t FP32\n\t\t\t FP64\n\t\t\t I8\n\t\t\t I32\n\t\t\t I64\n\t\t\t ", + ) + analyze_advanced_group.add_argument( "--random-port", action="store_true", diff --git a/src/rocprof_compute_analyze/analysis_webui.py b/src/rocprof_compute_analyze/analysis_webui.py index 15747df5f1..b124b0d16f 100644 --- a/src/rocprof_compute_analyze/analysis_webui.py +++ b/src/rocprof_compute_analyze/analysis_webui.py @@ -61,6 +61,9 @@ class webui_analysis(OmniAnalyze_Base): # define any elements which will have full width self.__full_width_elements = {1801} + if hasattr(args, "roofline_data_type") and args.roofline_data_type != ["FP32"]: + self.__roofline_data_type = args.roofline_data_type + @demarcate def build_layout(self, input_filters, arch_configs): """ @@ -186,6 +189,7 @@ class webui_analysis(OmniAnalyze_Base): "mem_level": "ALL", "include_kernel_names": False, "is_standalone": False, + "roofline_data_type": self.__roofline_data_type, } ) roof_obj = self.get_socs()[self.arch].roofline_obj diff --git a/src/roofline.py b/src/roofline.py index 0ee7f7d2c1..3293e870d1 100644 --- a/src/roofline.py +++ b/src/roofline.py @@ -302,7 +302,7 @@ class Roofline: None if self.__run_parameters["is_standalone"] else "{} G{}/s".format( - to_int(self.__ceiling_data["valu"][2], ops_flops) + to_int(self.__ceiling_data["valu"][2]), ops_flops ) ), "{} G{}/s".format( diff --git a/src/utils/roofline_calc.py b/src/utils/roofline_calc.py index c957265c61..089eed0e1c 100644 --- a/src/utils/roofline_calc.py +++ b/src/utils/roofline_calc.py @@ -153,13 +153,21 @@ def calc_ceilings(roofline_parameters, dtype, benchmark_data): x2_mfma = peakMFMA / peakBw y2_mfma = peakMFMA + # Check which peak is higher for formatting bandwidth lines + if y2_mfma > y1_mfma: # peakMFMA + peakX = x2_mfma + peakY = y2_mfma + else: # peakVALU + peakX = x1_mfma + peakY = y1_mfma + # These are the points to use: console_debug("roofline", "coordinate points:") - console_debug("x = [{}, {}]".format(x1, x2_mfma)) - console_debug("y = [{}, {}]".format(y1, y2_mfma)) + console_debug("x = [{}, {}]".format(x1, peakX)) + console_debug("y = [{}, {}]".format(y1, peakY)) - graphPoints[cacheHierarchy[i].lower()].append([x1, x2_mfma]) - graphPoints[cacheHierarchy[i].lower()].append([y1, y2_mfma]) + graphPoints[cacheHierarchy[i].lower()].append([x1, peakX]) + graphPoints[cacheHierarchy[i].lower()].append([y1, peakY]) graphPoints[cacheHierarchy[i].lower()].append(peakBw) # ------------------------------------------------------------------------------------- @@ -177,7 +185,7 @@ def calc_ceilings(roofline_parameters, dtype, benchmark_data): graphPoints["valu"].append(peakOps) # Plot MFMA roof - if x1_mfma != -1 and (dtype in MFMA_DATATYPES): # assert that mfma has been assigned + if dtype in MFMA_DATATYPES: # assert that mfma has been assigned x0_mfma = XMAX if x2_mfma < x0_mfma: x0_mfma = x2_mfma