diff --git a/src/rocprof_compute_soc/soc_base.py b/src/rocprof_compute_soc/soc_base.py index 9598d26d2..c8bea1ad4 100644 --- a/src/rocprof_compute_soc/soc_base.py +++ b/src/rocprof_compute_soc/soc_base.py @@ -240,9 +240,7 @@ def perfmon_filter(self, roofline_perfmon_only: bool): pmc_files_list = ref_pmc_files_list # Coalesce and writeback workload specific perfmon - perfmon_coalesce( - pmc_files_list, self.__perfmon_config, self.__workload_dir - ) + perfmon_coalesce(pmc_files_list, self.__perfmon_config, self.__workload_dir) # ---------------------------------------------------- # Required methods to be implemented by child classes @@ -262,8 +260,10 @@ def analysis_setup(self): """Perform any SoC-specific setup prior to analysis.""" console_debug("analysis", "perform SoC analysis setup for %s" % self.__arch) + def getblock(counter): - return counter.split('_')[0] + return counter.split("_")[0] + # Set with limited size class LimitedSet: @@ -282,6 +282,7 @@ def add(self, e) -> None: return True + # Represents a file that lists PMC counters. Number of counters for each # block limited according to perfmon config. class CounterFile: @@ -291,10 +292,10 @@ def __init__(self, name, perfmon_config) -> None: def add(self, counter) -> bool: block = getblock(counter) - + # SQ and SQC belong to the same IP block - if block == 'SQC': - block = 'SQ' + if block == "SQC": + block = "SQ" return self.blocks[block].add(counter) @@ -370,18 +371,18 @@ def perfmon_coalesce(pmc_files_list, perfmon_config, workload_dir): if "SQ_ACCUM_PREV_HIRES" in counters: # Accumulate counters accumulate_counters.append(counters.copy()) - else: + else: # Normal counters for ctr in counters: - + # Channel counter e.g. TCC_ATOMIC[0] - if '[' in ctr: + if "[" in ctr: # Remove channel number, append "_expand" so we know # add the channel numbers back later - channel = int(ctr.split('[')[1].split(']')[0]) + channel = int(ctr.split("[")[1].split("]")[0]) if channel == 0: - counter_name = ctr.split('[')[0] + "_expand" + counter_name = ctr.split("[")[0] + "_expand" try: normal_counters[counter_name] += 1 except: @@ -421,11 +422,12 @@ def perfmon_coalesce(pmc_files_list, perfmon_config, workload_dir): # All files are full, create a new file if not added: - output_files.append(CounterFile("pmc_perf_{}.txt".format(file_count), perfmon_config)) + output_files.append( + CounterFile("pmc_perf_{}.txt".format(file_count), perfmon_config) + ) file_count += 1 output_files[-1].add(ctr) - # Output to files for f in output_files: file_name = os.path.join(workload_perfmon_dir, f.file_name) @@ -454,7 +456,7 @@ def perfmon_coalesce(pmc_files_list, perfmon_config, workload_dir): pmc.append(ctr) stext = "pmc: " + " ".join(pmc) - + # Write counters to file fd = open(file_name, "w") fd.write(stext + "\n\n") @@ -462,11 +464,11 @@ def perfmon_coalesce(pmc_files_list, perfmon_config, workload_dir): fd.write("range:\n") fd.write("kernel:\n") fd.close() - + # Add a timestamp file fd = open(os.path.join(workload_perfmon_dir, "timestamps.txt"), "w") fd.write("pmc:\n\n") fd.write("gpu:\n") fd.write("range:\n") fd.write("kernel:\n") - fd.close() \ No newline at end of file + fd.close()