diff --git a/src/omniperf_soc/soc_base.py b/src/omniperf_soc/soc_base.py index ff0af8d65..446c6a82a 100644 --- a/src/omniperf_soc/soc_base.py +++ b/src/omniperf_soc/soc_base.py @@ -257,9 +257,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 @@ -279,8 +277,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: @@ -299,6 +299,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: @@ -308,13 +309,14 @@ 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) + @demarcate def perfmon_coalesce(pmc_files_list, perfmon_config, workload_dir): """Sort and bucket all related performance counters to minimize required application passes""" @@ -346,18 +348,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: @@ -397,11 +399,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) @@ -430,7 +433,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") @@ -438,11 +441,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()