added progress printout in rocprof-compute profile (#727)

* added progress printout for profiler

* added comments and fixed readability

* removed redundant newlines

* moved format_time helper function to utils

* removed tqdm and redundant time calc

[ROCm/rocprofiler-compute commit: 036866fc12]
Этот коммит содержится в:
jamessiddeley-amd
2025-06-18 14:09:09 -04:00
коммит произвёл GitHub
родитель 9d50115bd7
Коммит 979c59fadc
2 изменённых файлов: 32 добавлений и 8 удалений
+19 -8
Просмотреть файл
@@ -32,7 +32,6 @@ from abc import ABC, abstractmethod
from pathlib import Path
import pandas as pd
from tqdm import tqdm
import config
from utils.logger import (
@@ -44,6 +43,7 @@ from utils.logger import (
)
from utils.utils import (
capture_subprocess_output,
format_time,
gen_sysinfo,
pc_sampling_prof,
print_status,
@@ -353,16 +353,24 @@ class RocProfCompute_Base:
else print_status(msg + " (Roofline Only)")
)
# show status bar in error-only mode
disable_tqdm = True
if self.__args.loglevel >= logging.ERROR:
disable_tqdm = False
# Run profiling on each input file
input_files = glob.glob(self.get_args().path + "/perfmon/*.txt")
input_files.sort()
for fname in tqdm(input_files, disable=disable_tqdm):
total_runs = len(input_files)
total_profiling_time_so_far = 0
avg_profiling_time = 0
for i, fname in enumerate(input_files):
run_number = i + 1
if i > 0:
avg_profiling_time = total_profiling_time_so_far / i
time_left_seconds = (total_runs - run_number) * avg_profiling_time
time_left = format_time(time_left_seconds)
console_log(f"[Run {run_number}/{total_runs}][Approximate profiling time left: {time_left}]...")
else:
console_log(f"[Run {run_number}/{total_runs}][Approximate profiling time left: pending first measurement...]")
# Kernel filtering (in-place replacement)
if not self.__args.kernel == None:
success, output = capture_subprocess_output(
@@ -421,6 +429,7 @@ class RocProfCompute_Base:
format_rocprof_output=self.get_args().format_rocprof_output,
)
end_run_prof = time.time()
actual_profiling_duration = end_run_prof - start_run_prof
console_debug(
"The time of run_prof of {} is {} m {} sec".format(
fname,
@@ -430,11 +439,12 @@ class RocProfCompute_Base:
)
else:
console_error("Profiler not supported")
total_profiling_time_so_far += actual_profiling_duration
if self.__pc_sampling == True and self.__profiler in (
"rocprofv3",
"rocprofiler-sdk",
):
console_log(f"[Run {total_runs+1}/{total_runs+1}][PC sampling profile run]")
start_run_prof = time.time()
pc_sampling_prof(
method=self.get_args().pc_sampling_method,
@@ -444,6 +454,7 @@ class RocProfCompute_Base:
rocprofiler_sdk_library_path=self.get_args().rocprofiler_sdk_library_path,
)
end_run_prof = time.time()
pc_sampling_duration = end_run_prof - start_run_prof
console_debug(
"The time of pc sampling profiling is {} m {} sec".format(
int((end_run_prof - start_run_prof) / 60),
+13
Просмотреть файл
@@ -1552,3 +1552,16 @@ def convert_metric_id_to_panel_idx(metric_id):
return int(tokens[0]) * 100 + int(tokens[1])
else:
raise Exception(f"Invalid metric id: {metric_id}")
def format_time(seconds):
hours = int(seconds // 3600)
minutes = int((seconds % 3600) // 60)
secs = int(seconds % 60)
parts = []
if hours > 0:
parts.append(f"{hours} hour{'s' if hours != 1 else ''}")
if minutes > 0:
parts.append(f"{minutes} minute{'s' if minutes != 1 else ''}")
if secs > 0 or not parts:
parts.append(f"{secs} second{'s' if secs != 1 else ''}")
return ', '.join(parts[:-1]) + (' and ' if len(parts) > 1 else '') + parts[-1]