Format source code to PEP8 using Ruff (#36)
* added ruff docs * style: Run ruff and black before yapf pass * yapf -r -i (23 fixes) * fixed conf.py and ran ruff format . * fixed conf.py 2 * formatted argparser.py * formatted src/rocprof_compute_analyze * formatted src/rocprof_compute_profile * formatted soc_base.py * formatted rocprof_compute_tui * formatted gui_components * formatted src/utils * formatted tests/ * format extra files * cleanup * fix test_utils.py * fixed typos * Update pyproject.toml * Update README.md * Update test_utils.py --------- Signed-off-by: jamessiddeley-amd <James.Siddeley@amd.com> Co-authored-by: James Siddeley <James.Siddeley@amd.com> Co-authored-by: systems-assistant[bot] <systems-assistant[bot]@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
szülő
d3f9ab25eb
commit
58d2a016ce
@@ -23,7 +23,6 @@
|
||||
|
||||
##############################################################################
|
||||
|
||||
|
||||
import csv
|
||||
import glob
|
||||
import os
|
||||
@@ -96,7 +95,7 @@ class RocProfCompute_Base:
|
||||
return
|
||||
|
||||
# Set default output directory if not specified
|
||||
if type(self.__args.path) == str:
|
||||
if isinstance(self.__args.path, str):
|
||||
if out is None:
|
||||
out = self.__args.path + "/pmc_perf.csv"
|
||||
files = glob.glob(self.__args.path + "/" + "pmc_perf_*.csv")
|
||||
@@ -121,7 +120,7 @@ class RocProfCompute_Base:
|
||||
os.path.basename(f)
|
||||
)
|
||||
]
|
||||
elif type(self.__args.path) == list:
|
||||
elif isinstance(self.__args.path, list):
|
||||
files = self.__args.path
|
||||
else:
|
||||
console_error(
|
||||
@@ -130,7 +129,7 @@ class RocProfCompute_Base:
|
||||
|
||||
df = None
|
||||
for i, file in enumerate(files):
|
||||
_df = pd.read_csv(file) if type(self.__args.path) == str else file
|
||||
_df = pd.read_csv(file) if isinstance(self.__args.path, str) else file
|
||||
if self.__args.join_type == "kernel":
|
||||
key = _df.groupby("Kernel_Name").cumcount()
|
||||
_df["key"] = _df.Kernel_Name + " - " + key.astype(str)
|
||||
@@ -145,7 +144,8 @@ class RocProfCompute_Base:
|
||||
)
|
||||
else:
|
||||
console_error(
|
||||
"%s is an unrecognized option for --join-type" % self.__args.join_type
|
||||
"%s is an unrecognized option for --join-type"
|
||||
% self.__args.join_type
|
||||
)
|
||||
|
||||
if df is None:
|
||||
@@ -174,7 +174,9 @@ class RocProfCompute_Base:
|
||||
}
|
||||
# Check for vgpr counter in ROCm < 5.3
|
||||
if "vgpr" in df.columns:
|
||||
duplicate_cols["vgpr"] = [col for col in df.columns if col.startswith("vgpr")]
|
||||
duplicate_cols["vgpr"] = [
|
||||
col for col in df.columns if col.startswith("vgpr")
|
||||
]
|
||||
# Check for vgpr counter in ROCm >= 5.3
|
||||
else:
|
||||
duplicate_cols["Arch_VGPR"] = [
|
||||
@@ -235,7 +237,8 @@ class RocProfCompute_Base:
|
||||
)
|
||||
]
|
||||
]
|
||||
# B) any timestamps that are _not_ the duration, which is the one we care about
|
||||
# B) any timestamps that are _not_ the duration,
|
||||
# which is the one we care about
|
||||
df = df[
|
||||
[
|
||||
k
|
||||
@@ -275,8 +278,9 @@ class RocProfCompute_Base:
|
||||
df["End_Timestamp"] = endNs
|
||||
# finally, join the drop key
|
||||
df = df.drop(columns=["key"])
|
||||
# save to file and delete old file(s), skip if we're being called outside of rocprof-compute
|
||||
if type(self.__args.path) == str:
|
||||
# save to file and delete old file(s)
|
||||
# skip if we're being called outside of rocprof-compute
|
||||
if isinstance(self.__args.path, str):
|
||||
df.to_csv(out, index=False)
|
||||
if not self.__args.verbose:
|
||||
for file in files:
|
||||
@@ -322,7 +326,12 @@ class RocProfCompute_Base:
|
||||
self.__args.remaining = " ".join(self.__args.remaining)
|
||||
else:
|
||||
console_error(
|
||||
"Profiling command required. Pass application executable after -- at the end of options.\n\t\ti.e. rocprof-compute profile -n vcopy -- ./vcopy -n 1048576 -b 256"
|
||||
(
|
||||
"Profiling command required. Pass application executable after -- "
|
||||
"at the end of options.\n"
|
||||
"\t\ti.e. rocprof-compute profile -n vcopy -- "
|
||||
"./vcopy -n 1048576 -b 256"
|
||||
)
|
||||
)
|
||||
|
||||
gen_sysinfo(
|
||||
@@ -380,27 +389,28 @@ class RocProfCompute_Base:
|
||||
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}]..."
|
||||
f"[Run {run_number}/{total_runs}]"
|
||||
f"[Approximate profiling time left: {time_left}]..."
|
||||
)
|
||||
else:
|
||||
console_log(
|
||||
f"[Run {run_number}/{total_runs}][Approximate profiling time left: pending first measurement...]"
|
||||
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(
|
||||
[
|
||||
"sed",
|
||||
"-i",
|
||||
"-r",
|
||||
"s%^(kernel:).*%"
|
||||
+ "kernel: "
|
||||
+ ",".join(self.__args.kernel)
|
||||
+ "%g",
|
||||
fname,
|
||||
]
|
||||
)
|
||||
success, output = capture_subprocess_output([
|
||||
"sed",
|
||||
"-i",
|
||||
"-r",
|
||||
"s%^(kernel:).*%"
|
||||
+ "kernel: "
|
||||
+ ",".join(self.__args.kernel)
|
||||
+ "%g",
|
||||
fname,
|
||||
])
|
||||
# log output from profile filtering
|
||||
if not success:
|
||||
console_error(output)
|
||||
@@ -409,18 +419,16 @@ class RocProfCompute_Base:
|
||||
|
||||
# Dispatch filtering (inplace replacement)
|
||||
if not self.__args.dispatch == None:
|
||||
success, output = capture_subprocess_output(
|
||||
[
|
||||
"sed",
|
||||
"-i",
|
||||
"-r",
|
||||
"s%^(range:).*%"
|
||||
+ "range: "
|
||||
+ " ".join(self.__args.dispatch)
|
||||
+ "%g",
|
||||
fname,
|
||||
]
|
||||
)
|
||||
success, output = capture_subprocess_output([
|
||||
"sed",
|
||||
"-i",
|
||||
"-r",
|
||||
"s%^(range:).*%"
|
||||
+ "range: "
|
||||
+ " ".join(self.__args.dispatch)
|
||||
+ "%g",
|
||||
fname,
|
||||
])
|
||||
# log output from profile filtering
|
||||
if not success:
|
||||
console_error(output)
|
||||
@@ -462,7 +470,9 @@ class RocProfCompute_Base:
|
||||
"rocprofv3",
|
||||
"rocprofiler-sdk",
|
||||
):
|
||||
console_log(f"[Run {total_runs+1}/{total_runs+1}][PC sampling profile run]")
|
||||
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,
|
||||
|
||||
+7
-11
@@ -23,8 +23,6 @@
|
||||
|
||||
##############################################################################
|
||||
|
||||
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
import config
|
||||
@@ -67,15 +65,13 @@ class rocprof_v1_profiler(RocProfCompute_Base):
|
||||
'"' + app_cmd + '"',
|
||||
]
|
||||
# store original args for debug message
|
||||
store_app_cmd(
|
||||
[
|
||||
"--timestamp",
|
||||
"on",
|
||||
"-o",
|
||||
self.get_args().path + "/" + fbase + ".csv",
|
||||
app_cmd,
|
||||
]
|
||||
)
|
||||
store_app_cmd([
|
||||
"--timestamp",
|
||||
"on",
|
||||
"-o",
|
||||
self.get_args().path + "/" + fbase + ".csv",
|
||||
app_cmd,
|
||||
])
|
||||
return args
|
||||
|
||||
# -----------------------
|
||||
|
||||
@@ -23,8 +23,6 @@
|
||||
|
||||
##############################################################################
|
||||
|
||||
|
||||
import os
|
||||
import shlex
|
||||
from pathlib import Path
|
||||
|
||||
@@ -44,7 +42,6 @@ class rocprof_v2_profiler(RocProfCompute_Base):
|
||||
)
|
||||
|
||||
def get_profiler_options(self, fname, soc):
|
||||
fbase = Path(fname).stem
|
||||
app_cmd = shlex.split(self.get_args().remaining)
|
||||
|
||||
args = []
|
||||
|
||||
+3
-4
@@ -23,12 +23,9 @@
|
||||
|
||||
##############################################################################
|
||||
|
||||
|
||||
import os
|
||||
import shlex
|
||||
from pathlib import Path
|
||||
|
||||
import config
|
||||
from rocprof_compute_profile.profiler_base import RocProfCompute_Base
|
||||
from utils.logger import console_error, console_log, demarcate
|
||||
|
||||
@@ -49,7 +46,9 @@ class rocprof_v3_profiler(RocProfCompute_Base):
|
||||
trace_option = "--kokkos-trace"
|
||||
# NOTE: --kokkos-trace feature is incomplete and is disabled for now.
|
||||
console_error(
|
||||
"The option '--kokkos-trace' is not supported in the current version of rocprof-compute. This functionality is planned for a future release. Please adjust your profiling options accordingly."
|
||||
"The option '--kokkos-trace' is not supported in the current "
|
||||
"version of rocprof-compute. This functionality is planned for a "
|
||||
"future release. Please adjust your profiling options accordingly."
|
||||
)
|
||||
if self.get_args().hip_trace:
|
||||
trace_option = "--hip-trace"
|
||||
|
||||
+3
-3
@@ -23,8 +23,6 @@
|
||||
|
||||
##############################################################################
|
||||
|
||||
|
||||
import os
|
||||
import shlex
|
||||
from pathlib import Path
|
||||
|
||||
@@ -64,7 +62,9 @@ class rocprofiler_sdk_profiler(RocProfCompute_Base):
|
||||
if self.get_args().kokkos_trace:
|
||||
# NOTE: --kokkos-trace feature is incomplete and is disabled for now.
|
||||
console_error(
|
||||
"The option '--kokkos-trace' is not supported in the current version of rocprof-compute. This functionality is planned for a future release. Please adjust your profiling options accordingly."
|
||||
"The option '--kokkos-trace' is not supported in the current "
|
||||
"version of rocprof-compute. This functionality is planned for a "
|
||||
"future release. Please adjust your profiling options accordingly."
|
||||
)
|
||||
if self.get_args().hip_trace:
|
||||
options["ROCPROF_HIP_COMPILER_API_TRACE"] = "1"
|
||||
|
||||
Reference in New Issue
Block a user