From fa02efc962463a0161f3e4aee45f2783e34b5824 Mon Sep 17 00:00:00 2001 From: Cole Ramos Date: Fri, 29 Mar 2024 10:43:06 -0500 Subject: [PATCH] Revert #333 deterministic ordering (#337) * Revert "formatting" This reverts commit e387561791898467371b6219921f10447d3486b3. * Revert "Implement deterministic ordering of perfmon" This reverts commit 2a24600a37c8002838145962a957cea447555b0c. [ROCm/rocprofiler-compute commit: f7394bf272179e8eed1975f2e62ba619baa7a8d1] --- .../src/omniperf_profile/profiler_base.py | 5 -- .../src/omniperf_soc/soc_base.py | 55 +++++-------------- .../rocprofiler-compute/src/utils/logger.py | 1 + 3 files changed, 16 insertions(+), 45 deletions(-) diff --git a/projects/rocprofiler-compute/src/omniperf_profile/profiler_base.py b/projects/rocprofiler-compute/src/omniperf_profile/profiler_base.py index e841c13f96..18fdd02d20 100644 --- a/projects/rocprofiler-compute/src/omniperf_profile/profiler_base.py +++ b/projects/rocprofiler-compute/src/omniperf_profile/profiler_base.py @@ -106,10 +106,7 @@ class OmniProfiler_Base: if type(self.__args.path) == str: if out is None: out = self.__args.path + "/pmc_perf.csv" - # we sort so that we have a consistent ordering of files between runs - # regardless of the file-system, etc. files = glob.glob(self.__args.path + "/" + "pmc_perf_*.csv") - file.sort() elif type(self.__args.path) == list: files = self.__args.path else: @@ -342,8 +339,6 @@ class OmniProfiler_Base: disable_tqdm = False # Run profiling on each input file - # we sort so that we have a consistent ordering of files between runs - # regardless of the file-system, etc. input_files = glob.glob(self.get_args().path + "/perfmon/*.txt") input_files.sort() diff --git a/projects/rocprofiler-compute/src/omniperf_soc/soc_base.py b/projects/rocprofiler-compute/src/omniperf_soc/soc_base.py index 74ab059346..1e007035a7 100644 --- a/projects/rocprofiler-compute/src/omniperf_soc/soc_base.py +++ b/projects/rocprofiler-compute/src/omniperf_soc/soc_base.py @@ -23,7 +23,6 @@ ##############################################################################el from abc import ABC, abstractmethod -from collections import OrderedDict import os import math import shutil @@ -213,13 +212,9 @@ class OmniSoC_Base: os.makedirs(workload_perfmon_dir) if not roofline_perfmon_only: - # we sort so that we have a consistent ordering of files between runs - # regardless of the file-system, etc. - ref_pmc_files_list = sorted( - glob.glob(self.__perfmon_dir + "/" + "pmc_*perf*.txt") - ) - ref_pmc_files_list += sorted( - glob.glob(self.__perfmon_dir + "/" + self.__arch + "/pmc_*_perf*.txt") + ref_pmc_files_list = glob.glob(self.__perfmon_dir + "/" + "pmc_*perf*.txt") + ref_pmc_files_list += glob.glob( + self.__perfmon_dir + "/" + self.__arch + "/pmc_*_perf*.txt" ) # Perfmon list filtering @@ -242,11 +237,7 @@ class OmniSoC_Base: # default: take all perfmons pmc_files_list = ref_pmc_files_list else: - # we sort so that we have a consistent ordering of files between runs - # regardless of the file-system, etc. - ref_pmc_files_list = sorted( - glob.glob(self.__perfmon_dir + "/" + "pmc_roof_perf.txt") - ) + ref_pmc_files_list = glob.glob(self.__perfmon_dir + "/" + "pmc_roof_perf.txt") pmc_files_list = ref_pmc_files_list # Coalesce and writeback workload specific perfmon @@ -281,8 +272,7 @@ def perfmon_coalesce(pmc_files_list, perfmon_config, workload_dir): # match pattern for pmc counters mpattern = r"^pmc:(.*)" - # ordered dict again to ensure consistent ordering between runs - pmc_list = OrderedDict( + pmc_list = dict( [ ("SQ", []), ("GRBM", []), @@ -294,7 +284,7 @@ def perfmon_coalesce(pmc_files_list, perfmon_config, workload_dir): ("CPC", []), ("CPF", []), ("GDS", []), - ("TCC2", OrderedDict()), # per-channel TCC perfmon + ("TCC2", {}), # per-channel TCC perfmon ] ) for ch in range(perfmon_config["TCC_channels"]): @@ -358,8 +348,7 @@ def update_pmc_bucket( ) if pmc_list is None: detected_external_call = True - # ordered dict again to ensure consistent ordering between runs - pmc_list = OrderedDict( + pmc_list = dict( [ ("SQ", []), ("GRBM", []), @@ -371,7 +360,7 @@ def update_pmc_bucket( ("CPC", []), ("CPF", []), ("GDS", []), - ("TCC2", OrderedDict()), # per-channel TCC perfmon + ("TCC2", {}), # per-channel TCC perfmon ] ) for ch in range(perfmon_config["TCC_channels"]): @@ -402,25 +391,16 @@ def update_pmc_bucket( if IP_block != "TCC": # Insert unique pmc counters into its bucket - # NOTE: we specifically do _not_ exclude multiple versions of - # the same counter, because some counters are particularly - # sensitive to run-to-run variation (e.g., SQ_WAVE_CYCLES). - # Often, the resulting metrics do not make sense if they - # are taken from different runs, see: - # https://github.com/ROCm/omniperf/issues/332 - pmc_list[IP_block].append(counter) + if counter not in pmc_list[IP_block]: + pmc_list[IP_block].append(counter) + else: # TCC counters processing m = re.match(r"[\s\S]+\[(\d+)\]", counter) if m is None: # Aggregated TCC counters - # NOTE: we specifically do _not_ exclude multiple versions of - # the same counter, because some counters are particularly - # sensitive to run-to-run variation (e.g., SQ_WAVE_CYCLES). - # Often, the resulting metrics do not make sense if they - # are taken from different runs, see: - # https://github.com/ROCm/omniperf/issues/332 - pmc_list[IP_block].append(counter) + if counter not in pmc_list[IP_block]: + pmc_list[IP_block].append(counter) else: # TCC channel ID @@ -429,13 +409,8 @@ def update_pmc_bucket( # fake IP block for per channel TCC if str(ch) in pmc_list["TCC2"]: # append unique counter into the channel - # NOTE: we specifically do _not_ exclude multiple versions of - # the same counter, because some counters are particularly - # sensitive to run-to-run variation (e.g., SQ_WAVE_CYCLES). - # Often, the resulting metrics do not make sense if they - # are taken from different runs, see: - # https://github.com/ROCm/omniperf/issues/332 - pmc_list["TCC2"][str(ch)].append(counter) + if counter not in pmc_list["TCC2"][str(ch)]: + pmc_list["TCC2"][str(ch)].append(counter) else: # initial counter in this channel pmc_list["TCC2"][str(ch)] = [counter] diff --git a/projects/rocprofiler-compute/src/utils/logger.py b/projects/rocprofiler-compute/src/utils/logger.py index af7364f4e4..05bec4c18b 100644 --- a/projects/rocprofiler-compute/src/utils/logger.py +++ b/projects/rocprofiler-compute/src/utils/logger.py @@ -64,6 +64,7 @@ class PlainFormatter(logging.Formatter): # Setup console handler - provided as separate function to be called # prior to argument parsing def setup_console_handler(): + color_setting = 0 if "OMNIPERF_COLOR" in os.environ.keys(): color_setting = int(os.environ["OMNIPERF_COLOR"])