2
0

Fix code formatting

Signed-off-by: benrichard-amd <ben.richard@amd.com>


[ROCm/rocprofiler-compute commit: 96803e327c]
Este cometimento está contido em:
benrichard-amd
2024-07-17 15:25:27 -05:00
cometido por David Galiffi
ascendente 79fcef1a45
cometimento ddbc208489
+20 -17
Ver ficheiro
@@ -257,9 +257,7 @@ class OmniSoC_Base:
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 @@ class OmniSoC_Base:
"""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 @@ class LimitedSet:
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 @@ class CounterFile:
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()
fd.close()