Skip to content

Commit

Permalink
Fix code formatting
Browse files Browse the repository at this point in the history
Signed-off-by: benrichard-amd <[email protected]>
Signed-off-by: xuchen-amd <[email protected]>
  • Loading branch information
benrichard-amd authored and xuchen-amd committed Oct 29, 2024
1 parent 6ae70d1 commit 579d758
Showing 1 changed file with 19 additions and 17 deletions.
36 changes: 19 additions & 17 deletions src/rocprof_compute_soc/soc_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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)

Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -454,19 +456,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 579d758

Please sign in to comment.