Skip to content

Commit

Permalink
Revert #333 deterministic ordering (#337)
Browse files Browse the repository at this point in the history
* Revert "formatting"

This reverts commit e387561.

* Revert "Implement deterministic ordering of perfmon"

This reverts commit 2a24600.
  • Loading branch information
coleramos425 authored Mar 29, 2024
1 parent e387561 commit f3e0056
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 45 deletions.
5 changes: 0 additions & 5 deletions src/omniperf_profile/profiler_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,7 @@ def join_prof(self, out=None):
if type(self.__args.path) == str:
if out is None:
out = self.__args.path + "/pmc_perf.csv"
# we sort so that we have a consistent ordering of files between runs
# regardless of the file-system, etc.
files = glob.glob(self.__args.path + "/" + "pmc_perf_*.csv")
file.sort()
elif type(self.__args.path) == list:
files = self.__args.path
else:
Expand Down Expand Up @@ -342,8 +339,6 @@ def run_profiling(self, version: str, prog: str):
disable_tqdm = False

# Run profiling on each input file
# we sort so that we have a consistent ordering of files between runs
# regardless of the file-system, etc.
input_files = glob.glob(self.get_args().path + "/perfmon/*.txt")
input_files.sort()

Expand Down
55 changes: 15 additions & 40 deletions src/omniperf_soc/soc_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
##############################################################################el

from abc import ABC, abstractmethod
from collections import OrderedDict
import os
import math
import shutil
Expand Down Expand Up @@ -213,13 +212,9 @@ def perfmon_filter(self, roofline_perfmon_only: bool):
os.makedirs(workload_perfmon_dir)

if not roofline_perfmon_only:
# we sort so that we have a consistent ordering of files between runs
# regardless of the file-system, etc.
ref_pmc_files_list = sorted(
glob.glob(self.__perfmon_dir + "/" + "pmc_*perf*.txt")
)
ref_pmc_files_list += sorted(
glob.glob(self.__perfmon_dir + "/" + self.__arch + "/pmc_*_perf*.txt")
ref_pmc_files_list = glob.glob(self.__perfmon_dir + "/" + "pmc_*perf*.txt")
ref_pmc_files_list += glob.glob(
self.__perfmon_dir + "/" + self.__arch + "/pmc_*_perf*.txt"
)

# Perfmon list filtering
Expand All @@ -242,11 +237,7 @@ def perfmon_filter(self, roofline_perfmon_only: bool):
# default: take all perfmons
pmc_files_list = ref_pmc_files_list
else:
# we sort so that we have a consistent ordering of files between runs
# regardless of the file-system, etc.
ref_pmc_files_list = sorted(
glob.glob(self.__perfmon_dir + "/" + "pmc_roof_perf.txt")
)
ref_pmc_files_list = glob.glob(self.__perfmon_dir + "/" + "pmc_roof_perf.txt")
pmc_files_list = ref_pmc_files_list

# Coalesce and writeback workload specific perfmon
Expand Down Expand Up @@ -281,8 +272,7 @@ def perfmon_coalesce(pmc_files_list, perfmon_config, workload_dir):

# match pattern for pmc counters
mpattern = r"^pmc:(.*)"
# ordered dict again to ensure consistent ordering between runs
pmc_list = OrderedDict(
pmc_list = dict(
[
("SQ", []),
("GRBM", []),
Expand All @@ -294,7 +284,7 @@ def perfmon_coalesce(pmc_files_list, perfmon_config, workload_dir):
("CPC", []),
("CPF", []),
("GDS", []),
("TCC2", OrderedDict()), # per-channel TCC perfmon
("TCC2", {}), # per-channel TCC perfmon
]
)
for ch in range(perfmon_config["TCC_channels"]):
Expand Down Expand Up @@ -358,8 +348,7 @@ def update_pmc_bucket(
)
if pmc_list is None:
detected_external_call = True
# ordered dict again to ensure consistent ordering between runs
pmc_list = OrderedDict(
pmc_list = dict(
[
("SQ", []),
("GRBM", []),
Expand All @@ -371,7 +360,7 @@ def update_pmc_bucket(
("CPC", []),
("CPF", []),
("GDS", []),
("TCC2", OrderedDict()), # per-channel TCC perfmon
("TCC2", {}), # per-channel TCC perfmon
]
)
for ch in range(perfmon_config["TCC_channels"]):
Expand Down Expand Up @@ -402,25 +391,16 @@ def update_pmc_bucket(

if IP_block != "TCC":
# Insert unique pmc counters into its bucket
# NOTE: we specifically do _not_ exclude multiple versions of
# the same counter, because some counters are particularly
# sensitive to run-to-run variation (e.g., SQ_WAVE_CYCLES).
# Often, the resulting metrics do not make sense if they
# are taken from different runs, see:
# https://github.com/ROCm/omniperf/issues/332
pmc_list[IP_block].append(counter)
if counter not in pmc_list[IP_block]:
pmc_list[IP_block].append(counter)

else:
# TCC counters processing
m = re.match(r"[\s\S]+\[(\d+)\]", counter)
if m is None:
# Aggregated TCC counters
# NOTE: we specifically do _not_ exclude multiple versions of
# the same counter, because some counters are particularly
# sensitive to run-to-run variation (e.g., SQ_WAVE_CYCLES).
# Often, the resulting metrics do not make sense if they
# are taken from different runs, see:
# https://github.com/ROCm/omniperf/issues/332
pmc_list[IP_block].append(counter)
if counter not in pmc_list[IP_block]:
pmc_list[IP_block].append(counter)

else:
# TCC channel ID
Expand All @@ -429,13 +409,8 @@ def update_pmc_bucket(
# fake IP block for per channel TCC
if str(ch) in pmc_list["TCC2"]:
# append unique counter into the channel
# NOTE: we specifically do _not_ exclude multiple versions of
# the same counter, because some counters are particularly
# sensitive to run-to-run variation (e.g., SQ_WAVE_CYCLES).
# Often, the resulting metrics do not make sense if they
# are taken from different runs, see:
# https://github.com/ROCm/omniperf/issues/332
pmc_list["TCC2"][str(ch)].append(counter)
if counter not in pmc_list["TCC2"][str(ch)]:
pmc_list["TCC2"][str(ch)].append(counter)
else:
# initial counter in this channel
pmc_list["TCC2"][str(ch)] = [counter]
Expand Down
1 change: 1 addition & 0 deletions src/utils/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ def format(self, record):
# Setup console handler - provided as separate function to be called
# prior to argument parsing
def setup_console_handler():

color_setting = 0
if "OMNIPERF_COLOR" in os.environ.keys():
color_setting = int(os.environ["OMNIPERF_COLOR"])
Expand Down

0 comments on commit f3e0056

Please sign in to comment.