Skip to content

Commit

Permalink
fix crash for running rocprofv3 on mi100 (#557)
Browse files Browse the repository at this point in the history
* initial hack to fix for v3 stucking on mi100 becasue of -m parameter and missing counter csv file

* proper formating

* refactored profiler option function to take soc arch

* resolve missing step that casued error for profiler option

* fix typo of arch name

* change method of putting soc info into profiler option

* isort and black format

* add comment for the part that handles missing counter csv file

* remove unncecessary import

---------

Co-authored-by: YANG WANG <[email protected]>
  • Loading branch information
ywang103-amd and YANG WANG authored Feb 10, 2025
1 parent 6391b3c commit 5ee37b3
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 21 deletions.
6 changes: 2 additions & 4 deletions src/rocprof_compute_profile/profiler_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def __init__(self, args, profiler_mode, soc):
def get_args(self):
return self.__args

def get_profiler_options(self, fname):
def get_profiler_options(self, fname, soc):
"""Fetch any version specific arguments required by profiler"""
# assume no SoC specific options and return empty list by default
return []
Expand Down Expand Up @@ -361,9 +361,7 @@ def run_profiling(self, version: str, prog: str):
console_debug(output)
console_log("profiling", "Current input file: %s" % fname)

# Fetch any SoC/profiler specific profiling options
options = self._soc.get_profiler_options()
options += self.get_profiler_options(fname)
options = self.get_profiler_options(fname, self._soc)
if (
self.__profiler == "rocprofv1"
or self.__profiler == "rocprofv2"
Expand Down
10 changes: 8 additions & 2 deletions src/rocprof_compute_profile/profiler_rocprof_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,16 @@ def __init__(self, profiling_args, profiler_mode, soc):
or not self.get_args().roof_only
)

def get_profiler_options(self, fname):
def get_profiler_options(self, fname, soc):
fbase = Path(fname).stem
app_cmd = self.get_args().remaining
args = [

args = []
# can be removed in the future. It supports gfx908 + v1
if soc.get_arch() == "gfx908":
args += ["-m", soc.get_workload_perfmon_dir() + "/" + "metrics.xml"]

args += [
# v1 requires request for timestamps
"--timestamp",
"on",
Expand Down
10 changes: 8 additions & 2 deletions src/rocprof_compute_profile/profiler_rocprof_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,16 @@ def __init__(self, profiling_args, profiler_mode, soc):
or not self.get_args().roof_only
)

def get_profiler_options(self, fname):
def get_profiler_options(self, fname, soc):
fbase = Path(fname).stem
app_cmd = shlex.split(self.get_args().remaining)
args = [

args = []
# can be removed in the future. It supports gfx908 + v2
if soc.get_arch() == "gfx908":
args += ["-m", soc.get_workload_perfmon_dir() + "/" + "metrics.xml"]

args += [
# v2 requires output directory argument
"-d",
self.get_args().path + "/" + "out",
Expand Down
2 changes: 1 addition & 1 deletion src/rocprof_compute_profile/profiler_rocprof_v3.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def __init__(self, profiling_args, profiler_mode, soc):
or not self.get_args().roof_only
)

def get_profiler_options(self, fname):
def get_profiler_options(self, fname, soc):
app_cmd = shlex.split(self.get_args().remaining)
trace_option = "--kernel-trace"
rocprof_out_format = "json"
Expand Down
6 changes: 0 additions & 6 deletions src/rocprof_compute_soc/soc_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,6 @@ def set_compatible_profilers(self, profiler_names: list):
def get_compatible_profilers(self):
return self.__compatible_profilers

@demarcate
def get_profiler_options(self):
"""Fetch any SoC specific arguments required by the profiler"""
# assume no SoC specific options and return empty list by default
return []

@demarcate
def populate_mspec(self):
from utils.specs import run, search, total_sqc, total_xcds
Expand Down
5 changes: 0 additions & 5 deletions src/rocprof_compute_soc/soc_gfx908.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,6 @@ def __init__(self, args, mspec):
self._mspec.max_mclk = 1200
self._mspec.cur_mclk = 1200

@demarcate
def get_profiler_options(self):
# Mi100 requires a custom xml config
return ["-m", self.get_workload_perfmon_dir() + "/" + "metrics.xml"]

# -----------------------
# Required child methods
# -----------------------
Expand Down
9 changes: 8 additions & 1 deletion src/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,9 @@ def run_prof(
new_env = os.environ.copy()
new_env["ROCPROFILER_INDIVIDUAL_XCC_MODE"] = "1"

is_timestamps = False
if path(fname).name == "timestamps.txt":
is_timestamps = True
time_1 = time.time()

# profile the app
Expand Down Expand Up @@ -686,10 +689,14 @@ def run_prof(
results_files_csv = glob.glob(
workload_dir + "/out/pmc_1/*/*_converted.csv"
)
else:
elif is_timestamps:
# when the input is timestamps, we know counter csv file is not generated and will instead parse kernel trace file
results_files_csv = glob.glob(
workload_dir + "/out/pmc_1/*/*_kernel_trace.csv"
)
else:
# when the input is not for timestamps, and counter csv file is not generated, we assume failed rocprof run and will completely bypass the file generation and merging for current pmc
return

else:
console_error("The output file of rocprofv3 can only support json or csv!!!")
Expand Down

0 comments on commit 5ee37b3

Please sign in to comment.