Files
rocm-systems/src/rocprof_compute_analyze/analysis_cli.py
T

90 строки
3.7 KiB
Python
Исходник Обычный вид История

##############################################################################bl
# MIT License
#
2024-01-24 17:11:39 -06:00
# Copyright (c) 2021 - 2024 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
from rocprof_compute_analyze.analysis_base import OmniAnalyze_Base
2024-01-30 17:25:16 -06:00
from utils.utils import demarcate, console_error
from utils import file_io, parser, tty
from utils.kernel_name_shortener import kernel_name_shortener
2024-02-16 15:34:28 -06:00
class cli_analysis(OmniAnalyze_Base):
# -----------------------
# Required child methods
2024-02-16 15:34:28 -06:00
# -----------------------
@demarcate
def pre_processing(self):
2024-02-16 15:34:28 -06:00
"""Perform any pre-processing steps prior to analysis."""
2023-12-18 16:37:01 -06:00
super().pre_processing()
if self.get_args().random_port:
2024-01-30 17:25:16 -06:00
console_error("--gui flag is required to enable --random-port")
for d in self.get_args().path:
file_io.create_df_kernel_top_stats(
2023-12-18 16:37:01 -06:00
raw_data_dir=d[0],
filter_gpu_ids=self._runs[d[0]].filter_gpu_ids,
filter_dispatch_ids=self._runs[d[0]].filter_dispatch_ids,
2023-12-18 16:37:01 -06:00
time_unit=self.get_args().time_unit,
2024-02-16 15:34:28 -06:00
max_stat_num=self.get_args().max_stat_num,
2024-03-12 15:54:52 -05:00
kernel_verbose=self.get_args().kernel_verbose,
)
# create 'mega dataframe'
self._runs[d[0]].raw_pmc = file_io.create_df_pmc(
2024-03-12 15:54:52 -05:00
d[0], self.get_args().kernel_verbose, self.get_args().verbose
)
2024-03-12 15:54:52 -05:00
# demangle and overwrite original 'Kernel_Name'
kernel_name_shortener(
self._runs[d[0]].raw_pmc, self.get_args().kernel_verbose
)
2024-03-12 15:54:52 -05:00
# create the loaded table
parser.load_table_data(
workload=self._runs[d[0]],
2024-02-16 15:34:28 -06:00
dir=d[0],
2023-12-18 16:37:01 -06:00
is_gui=False,
2024-02-16 15:34:28 -06:00
debug=self.get_args().debug,
verbose=self.get_args().verbose,
)
@demarcate
def run_analysis(self):
2024-02-16 15:34:28 -06:00
"""Run CLI analysis."""
2023-12-18 16:37:01 -06:00
super().run_analysis()
if self.get_args().list_stats:
tty.show_kernel_stats(
self.get_args(),
self._runs,
self._arch_configs[
self._runs[self.get_args().path[0][0]].sys_info.iloc[0]["gpu_arch"]
],
2024-03-01 11:52:31 -06:00
self._output,
)
else:
tty.show_all(
self.get_args(),
self._runs,
self._arch_configs[
self._runs[self.get_args().path[0][0]].sys_info.iloc[0]["gpu_arch"]
],
2024-03-01 11:52:31 -06:00
self._output,
)