Skip to content

Commit

Permalink
Fix code formatting
Browse files Browse the repository at this point in the history
Signed-off-by: benrichard-amd <ben.richard@amd.com>
  • Loading branch information
benrichard-amd committed Jul 17, 2024
1 parent eb83d74 commit 5eaed48
Showing 1 changed file with 20 additions and 17 deletions.
37 changes: 20 additions & 17 deletions src/omniperf_soc/soc_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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"""
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -430,19 +433,19 @@ 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")
fd.write("gpu:\n")
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()
fd.close()

0 comments on commit 5eaed48

Please sign in to comment.