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>
Этот коммит содержится в:
systems-assistant[bot]
2025-08-08 15:32:30 -04:00
коммит произвёл GitHub
родитель d3f9ab25eb
Коммит 58d2a016ce
72 изменённых файлов: 3272 добавлений и 2395 удалений
+174 -40
Просмотреть файл
@@ -23,7 +23,6 @@
##############################################################################
import argparse
import os
import re
@@ -87,7 +86,8 @@ def omniarg_parser(
help="Profile the target application",
usage="""
rocprof-compute profile --name <workload_name> [profile options] [roofline options] -- <profile_cmd>
`rocprof-compute profile --name <workload_name>
[profile options] [roofline options] -- <profile_cmd>`
---------------------------------------------------------------------------------
Examples:
@@ -118,7 +118,9 @@ Examples:
dest="name",
help="\t\t\tAssign a name to workload.",
)
profile_group.add_argument("--target", type=str, default=None, help=argparse.SUPPRESS)
profile_group.add_argument(
"--target", type=str, default=None, help=argparse.SUPPRESS
)
profile_group.add_argument(
"-p",
"--path",
@@ -127,8 +129,9 @@ Examples:
dest="path",
default=str(Path(os.getcwd()).joinpath("workloads")),
required=False,
help="\t\t\tSpecify path to save workload.\n\t\t\t(DEFAULT: {}/workloads/<name>)".format(
os.getcwd()
help=(
"\t\t\tSpecify path to save workload.\n\t\t\t"
"(DEFAULT: {}/workloads/<name>)".format(os.getcwd())
),
)
profile_group.add_argument(
@@ -138,7 +141,9 @@ Examples:
dest="subpath",
default="gpu",
required=False,
help="\t\t\tSpecify the type of subpath to save workload: node_name, gpu_model.",
help=(
"\t\t\tSpecify the type of subpath to save workload: node_name, gpu_model."
),
)
profile_group.add_argument(
"--hip-trace",
@@ -146,7 +151,10 @@ Examples:
required=False,
default=False,
action="store_true",
help="\t\t\tHIP trace, execturion trace for the entire application at the HIP level.",
help=(
"\t\t\tHIP trace, execturion trace for the entire application at the HIP "
"level."
),
)
profile_group.add_argument(
"--kokkos-trace",
@@ -195,7 +203,11 @@ Examples:
nargs="+",
required=False,
default=[],
help="""\t\t\tSpecify metric id(s) from --list-metrics for filtering (e.g. 12, 12.1, 12.1.1).\n\t\t\tCan provide multiple space separated arguments.""",
help=(
"\t\t\tSpecify metric id(s) from --list-metrics for filtering "
"(e.g. 12, 12.1, 12.1.1).\n"
"\t\t\tCan provide multiple space separated arguments."
),
)
profile_group.add_argument(
"--list-metrics",
@@ -232,7 +244,11 @@ Examples:
required=False,
choices=["kernel", "grid"],
default="grid",
help="\t\t\tChoose how to join rocprof runs: (DEFAULT: grid)\n\t\t\t kernel (i.e. By unique kernel name dispatches)\n\t\t\t grid (i.e. By unique kernel name + grid size dispatches)",
help=(
"\t\t\tChoose how to join rocprof runs: (DEFAULT: grid)\n"
"\t\t\t kernel (i.e. By unique kernel name dispatches)\n"
"\t\t\t grid (i.e. By unique kernel name + grid size dispatches)"
),
)
profile_group.add_argument(
"--no-roof",
@@ -274,7 +290,10 @@ Examples:
metavar="",
dest="pc_sampling_method",
default="stochastic",
help="\t\t\tSet the method of pc sampling, stochastic or host_trap. Support stochastic only >= MI300",
help=(
"\t\t\tSet the method of pc sampling, stochastic or host_trap. "
"Support stochastic only >= MI300"
),
)
profile_group.add_argument(
@@ -283,7 +302,12 @@ Examples:
metavar="",
dest="pc_sampling_interval",
default=1048576,
help="\t\t\tSet the interval of pc sampling.\n\t\t\t For stochastic sampling, the interval is in cycles.\n\t\t\t For host_trap sampling, the interval is in microsecond (DEFAULT: 1048576).",
help=(
"\t\t\tSet the interval of pc sampling.\n"
"\t\t\t For stochastic sampling, the interval is in cycles.\n"
"\t\t\t For host_trap sampling, the interval is in microsecond "
"(DEFAULT: 1048576)."
)
)
profile_group.add_argument(
@@ -299,7 +323,10 @@ Examples:
required=False,
default=False,
action="store_true",
help="\t\t\tRetain the large raw rocpd database in workload directory.\n\t\t\tThis option requires --format-rocprof-output rocpd.",
help=(
"\t\t\tRetain the large raw rocpd database in workload directory.\n"
"\t\t\tThis option requires --format-rocprof-output rocpd."
),
)
## Roofline Command Line Options
@@ -317,7 +344,11 @@ Examples:
type=str,
default="kernels",
choices=["kernels", "dispatches"],
help="\t\t\tOverlay top kernels or top dispatches: (DEFAULT: kernels)\n\t\t\t kernels\n\t\t\t dispatches",
help=(
"\t\t\tOverlay top kernels or top dispatches: (DEFAULT: kernels)\n"
"\t\t\t kernels\n"
"\t\t\t dispatches"
),
)
roofline_group.add_argument(
"-m",
@@ -328,7 +359,13 @@ Examples:
nargs="+",
type=str,
default="ALL",
help="\t\t\tFilter by memory level: (DEFAULT: ALL)\n\t\t\t HBM\n\t\t\t L2\n\t\t\t vL1D\n\t\t\t LDS",
help=(
"\t\t\tFilter by memory level: (DEFAULT: ALL)\n"
"\t\t\t HBM\n"
"\t\t\t L2\n"
"\t\t\t vL1D\n"
"\t\t\t LDS"
),
)
roofline_group.add_argument(
"--device",
@@ -350,19 +387,58 @@ Examples:
"-R",
"--roofline-data-type",
required=False,
choices=["FP4", "FP6", "FP8", "FP16", "BF16", "FP32", "FP64", "I8", "I32", "I64"],
choices=[
"FP4",
"FP6",
"FP8",
"FP16",
"BF16",
"FP32",
"FP64",
"I8",
"I32",
"I64",
],
metavar="",
nargs="+",
type=str,
default=["FP32"],
help="\t\t\tChoose datatypes to view roofline PDFs for: (DEFAULT: FP32)\n\t\t\t FP4\n\t\t\t FP6\n\t\t\t FP8\n\t\t\t FP16\n\t\t\t BF16\n\t\t\t FP32\n\t\t\t FP64\n\t\t\t I8\n\t\t\t I32\n\t\t\t I64\n\t\t\t ",
help=(
"\t\t\tChoose datatypes to view roofline PDFs for: (DEFAULT: FP32)\n"
"\t\t\t FP4\n"
"\t\t\t FP6\n"
"\t\t\t FP8\n"
"\t\t\t FP16\n"
"\t\t\t BF16\n"
"\t\t\t FP32\n"
"\t\t\t FP64\n"
"\t\t\t I8\n"
"\t\t\t I32\n"
"\t\t\t I64\n"
"\t\t\t "
),
)
# roofline_group.add_argument('-w', '--workgroups', required=False, default=-1, type=int, help="\t\t\tNumber of kernel workgroups (DEFAULT: 1024)")
# roofline_group.add_argument('--wsize', required=False, default=-1, type=int, help="\t\t\tWorkgroup size (DEFAULT: 256)")
# roofline_group.add_argument('--dataset', required=False, default = -1, type=int, help="\t\t\tDataset size (DEFAULT: 536M)")
# roofline_group.add_argument('-e', '--experiments', required=False, default=-1, type=int, help="\t\t\tNumber of experiments (DEFAULT: 100)")
# roofline_group.add_argument('--iter', required=False, default=-1, type=int, help="\t\t\tNumber of iterations (DEFAULT: 10)")
# roofline_group.add_argument(
# '-w', '--workgroups', required=False, default=-1, type=int,
# help="\t\t\tNumber of kernel workgroups (DEFAULT: 1024)"
# )
# roofline_group.add_argument(
# '--wsize', required=False, default=-1, type=int,
# help="\t\t\tWorkgroup size (DEFAULT: 256)"
# )
# roofline_group.add_argument(
# '--dataset', required=False, default=-1, type=int,
# help="\t\t\tDataset size (DEFAULT: 536M)"
# )
# roofline_group.add_argument(
# '-e', '--experiments', required=False, default=-1, type=int,
# help="\t\t\tNumber of experiments (DEFAULT: 100)"
# )
# roofline_group.add_argument(
# '--iter', required=False, default=-1, type=int,
# help="\t\t\tNumber of iterations (DEFAULT: 10)"
# )
## Database Command Line Options
## ----------------------------
@@ -374,9 +450,11 @@ Examples:
\n\n-------------------------------------------------------------------------------
\nExamples:
\n\trocprof-compute database --import -H pavii1 -u temp -t asw -w workloads/vcopy/mi200/
\n\trocprof-compute database --remove -H pavii1 -u temp -w rocprofiler-compute_asw_sample_mi200
\n-------------------------------------------------------------------------------\n
\n\trocprof-compute database --import -H pavii1 -u temp -t asw -w "
"workloads/vcopy/mi200/"
"\n\trocprof-compute database --remove -H pavii1 -u temp -w "
"rocprofiler-compute_asw_sample_mi200"
"\n-------------------------------------------------------------------------------\n"
""",
prog="tool",
allow_abbrev=False,
@@ -445,13 +523,20 @@ Examples:
required=True,
metavar="",
dest="workload",
help="\t\t\t\tSpecify name of workload (to remove) or path to workload (to import)",
help=(
"\t\t\t\tSpecify name of workload (to remove) or path to workload "
"(to import)"
),
)
connection_group.add_argument(
"--kernel-verbose",
required=False,
metavar="",
help="\t\tSpecify Kernel Name verbose level 1-5. Lower the level, shorter the kernel name. (DEFAULT: 5) (DISABLE: 5)",
help=(
"\t\tSpecify Kernel Name verbose level 1-5. "
"Lower the level, shorter the kernel name. "
"(DEFAULT: 5) (DISABLE: 5)"
),
default=5,
type=int,
)
@@ -558,23 +643,50 @@ Examples:
type=int,
nargs="?",
const=8050,
help="\t\tActivate a GUI to interate with rocprofiler-compute metrics.\n\t\tOptionally, specify port to launch application (DEFAULT: 8050)",
help=(
"\t\tActivate a GUI to interate with rocprofiler-compute metrics.\n"
"\t\tOptionally, specify port to launch application (DEFAULT: 8050)"
),
)
analyze_group.add_argument(
"--tui",
action="store_true",
help="\t\tActivate a Textual User Interface (TUI) to interact with rocprofiler-compute metrics.",
help="\t\tActivate a Textual User Interface (TUI) to "
"interact with rocprofiler-compute metrics.",
)
analyze_group.add_argument(
"-R",
"--roofline-data-type",
required=False,
choices=["FP4", "FP6", "FP8", "FP16", "BF16", "FP32", "FP64", "I8", "I32", "I64"],
choices=[
"FP4",
"FP6",
"FP8",
"FP16",
"BF16",
"FP32",
"FP64",
"I8",
"I32",
"I64",
],
metavar="",
nargs="+",
type=str,
default=["FP32"],
help="\t\tChoose datatypes to view roofline PDFs for: (DEFAULT: FP32)\n\t\t\t FP4\n\t\t\t FP6\n\t\t\t FP8\n\t\t\t FP16\n\t\t\t BF16\n\t\t\t FP32\n\t\t\t FP64\n\t\t\t I8\n\t\t\t I32\n\t\t\t I64\n\t\t\t ",
help=(
"\t\tChoose datatypes to view roofline PDFs for: (DEFAULT: FP32)\n"
"\t\t\t FP4\n"
"\t\t\t FP6\n"
"\t\t\t FP8\n"
"\t\t\t FP16\n"
"\t\t\t BF16\n"
"\t\t\t FP32\n"
"\t\t\t FP64\n"
"\t\t\t I8\n"
"\t\t\t I32\n"
"\t\t\t I64\n\t\t\t "
),
)
analyze_group.add_argument(
@@ -584,13 +696,15 @@ Examples:
dest="pc_sampling_sorting_type",
default="offset",
type=str,
help="\t\tSet the sorting type of pc sampling: offset or count (DEFAULT: offset).",
help="\t\tSet the sorting type of pc sampling: "
"offset or count (DEFAULT: offset).",
)
analyze_advanced_group.add_argument(
"--random-port",
action="store_true",
help="\t\tRandomly generate a port to launch GUI application.\n\t\tRegistered Ports range inclusive (1024-49151).",
help="\t\tRandomly generate a port to launch GUI application.\n"
"\t\tRegistered Ports range inclusive (1024-49151).",
)
analyze_advanced_group.add_argument(
"--max-stat-num",
@@ -598,7 +712,8 @@ Examples:
metavar="",
type=int,
default=10,
help='\t\tSpecify the maximum number of stats shown in "Top Stats" tables (DEFAULT: 10)',
help="\t\tSpecify the maximum number of stats shown in "
'"Top Stats" tables (DEFAULT: 10)',
)
analyze_advanced_group.add_argument(
"-n",
@@ -607,7 +722,11 @@ Examples:
metavar="",
default="per_kernel",
choices=["per_wave", "per_cycle", "per_second", "per_kernel"],
help="\t\tSpecify the normalization unit: (DEFAULT: per_kernel)\n\t\t per_wave\n\t\t per_cycle\n\t\t per_second\n\t\t per_kernel",
help="\t\tSpecify the normalization unit: (DEFAULT: per_kernel)\n"
"\t\t per_wave\n"
"\t\t per_cycle\n"
"\t\t per_second\n"
"\t\t per_kernel",
)
analyze_advanced_group.add_argument(
"-t",
@@ -616,7 +735,11 @@ Examples:
metavar="",
default="ns",
choices=["s", "ms", "us", "ns"],
help="\t\tSpecify display time unit: (DEFAULT: ns)\n\t\t s\n\t\t ms\n\t\t us\n\t\t ns",
help="\t\tSpecify display time unit: (DEFAULT: ns)\n"
"\t\t s\n"
"\t\t ms\n"
"\t\t us\n"
"\t\t ns",
)
analyze_advanced_group.add_argument(
"--decimal",
@@ -644,7 +767,10 @@ Examples:
dest="cols",
metavar="",
nargs="+",
help="\t\tSpecify column indices to display.\n\t\tDefaults to display all columns.",
help=(
"\t\tSpecify column indices to display.\n"
"\t\tDefaults to display all columns."
),
)
analyze_advanced_group.add_argument(
"--include-cols",
@@ -653,7 +779,8 @@ Examples:
nargs="+",
help=(
"\t\tSpecify which hidden column names should be included in cli output.\n"
"\t\tFor example, to show 'Description' column which is hidden by default in cli output,\n"
"\t\tFor example, to show 'Description' column which is hidden by "
"default in cli output,\n"
"\t\tuse the option --include-cols Description."
),
)
@@ -669,7 +796,9 @@ Examples:
"--kernel-verbose",
required=False,
metavar="",
help="\t\tSpecify Kernel Name verbose level 1-5. Lower the level, shorter the kernel name. (DEFAULT: 5) (DISABLE: 5)",
help="\t\tSpecify Kernel Name verbose level 1-5. "
"Lower the level, shorter the kernel name. "
"(DEFAULT: 5) (DISABLE: 5)",
default=5,
type=int,
)
@@ -680,7 +809,9 @@ Examples:
"--specs-correction",
type=str,
metavar="",
help="\t\tSpecify the specs to correct. e.g. --specs-correction='specname1:specvalue1,specname2:specvalue2'",
help="\t\tSpecify the specs to correct. e.g. "
"--specs-correction='specname1:specvalue1,"
"specname2:specvalue2'",
)
analyze_advanced_group.add_argument(
"--list-nodes",
@@ -693,5 +824,8 @@ Examples:
type=str,
dest="nodes",
nargs="*",
help="\t\tMulti-node option: filter with node names. Enable it without node names means ALL.",
help=(
"\t\tMulti-node option: filter with node names. "
"Enable it without node names means ALL."
),
)