Files
rocm-systems/src/rocprof_compute_profile/profiler_rocprof_v3.py
T
ywang103-amd 5ee37b3353 fix crash for running rocprofv3 on mi100 (#557)
* 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 <ywang@ywang-ubuntu.amd.com>
2025-02-10 17:59:03 -05:00

106 lines
3.9 KiB
Python

##############################################################################bl
# MIT License
#
# Copyright (c) 2021 - 2025 Advanced Micro Devices, Inc. All Rights Reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
##############################################################################el
import os
import shlex
from pathlib import Path
import config
from rocprof_compute_profile.profiler_base import RocProfCompute_Base
from utils.utils import console_error, console_log, demarcate, replace_timestamps
class rocprof_v3_profiler(RocProfCompute_Base):
def __init__(self, profiling_args, profiler_mode, soc):
super().__init__(profiling_args, profiler_mode, soc)
self.ready_to_profile = (
self.get_args().roof_only
and not Path(self.get_args().path).joinpath("pmc_perf.csv").is_file()
or not self.get_args().roof_only
)
def get_profiler_options(self, fname, soc):
app_cmd = shlex.split(self.get_args().remaining)
trace_option = "--kernel-trace"
rocprof_out_format = "json"
if self.get_args().format_rocprof_output == "csv":
rocprof_out_format = "csv"
if self.get_args().kokkos_trace:
trace_option = "--kokkos-trace"
if self.get_args().hip_trace:
trace_option = "--hip-trace"
args = [
"-E",
os.path.join(
str(config.rocprof_compute_home),
"rocprof_compute_soc",
"profile_configs",
"accum_counters.yaml",
),
# v3 requires output directory argument
"-d",
self.get_args().path + "/" + "out",
trace_option,
"--output-format",
rocprof_out_format,
"--",
]
args.extend(app_cmd)
return args
# -----------------------
# Required child methods
# -----------------------
@demarcate
def pre_processing(self):
"""Perform any pre-processing steps prior to profiling."""
super().pre_processing()
@demarcate
def run_profiling(self, version, prog):
"""Run profiling."""
if self.ready_to_profile:
if self.get_args().roof_only:
console_log(
"roofline", "Generating pmc_perf.csv (roofline counters only)."
)
# Log profiling options and setup filtering
super().run_profiling(version, prog)
else:
console_log("roofline", "Detected existing pmc_perf.csv")
@demarcate
def post_processing(self):
"""Perform any post-processing steps prior to profiling."""
super().post_processing()
if self.ready_to_profile:
# Manually join each pmc_perf*.csv output
self.join_prof()
# Replace timestamp data to solve a known rocprof bug
# replace_timestamps(self.get_args().path)