Streamline --list-metrics command line option in rocprof-compute (#310)
* Remove L2 channels from --list-metrics --list-metrics moved to general options List metrics for the current architecture Filter blocks for metrics Removed test for --list-metrics in profile mode Test the options don't throw error Fixed --config-dir error Test stdout for command line options Provide path list for loading panel configs Show L2 Cache (per) channel metrics Changed command line option names Can show two levels only Removed filtering blocks Moved blocks to original position Removed filter block tests Removed filtering Formaating fix Readability enhancement Test formatting Filter L2 channels without sysinfo Show avilable metrics for current arch Intermediate commit Fixed tests Added argument sanitization Added list_metrics to ctest merge iconflict resolution Updated test marker Updated changelog Fixed formatting * Updated docs
Tento commit je obsažen v:
@@ -30,13 +30,15 @@ from pathlib import Path
|
||||
|
||||
|
||||
def print_avail_arch(avail_arch: list):
|
||||
ret_str = "\t\t\tList all available metrics for analysis on specified arch:"
|
||||
ret_str = "List all available metrics for analysis on specified arch:"
|
||||
for arch in avail_arch:
|
||||
ret_str += "\n\t\t\t {}".format(arch)
|
||||
ret_str += "\n {}".format(arch)
|
||||
return ret_str
|
||||
|
||||
|
||||
def add_general_group(parser, rocprof_compute_version):
|
||||
def add_general_group(
|
||||
parser, rocprof_compute_version, supported_archs, rocprof_compute_home
|
||||
):
|
||||
general_group = parser.add_argument_group("General Options")
|
||||
|
||||
general_group.add_argument(
|
||||
@@ -55,6 +57,20 @@ def add_general_group(parser, rocprof_compute_version):
|
||||
general_group.add_argument(
|
||||
"-q", "--quiet", action="store_true", help="Reduce output and run quietly."
|
||||
)
|
||||
general_group.add_argument(
|
||||
"--list-metrics",
|
||||
dest="list_metrics",
|
||||
metavar="",
|
||||
choices=supported_archs.keys(), # ["gfx908", "gfx90a"],
|
||||
help=print_avail_arch(supported_archs.keys()),
|
||||
)
|
||||
general_group.add_argument(
|
||||
"--config-dir",
|
||||
dest="config_dir",
|
||||
metavar="",
|
||||
help="Specify the directory of customized report section configs.",
|
||||
default=rocprof_compute_home.joinpath("rocprof_compute_soc/analysis_configs/"),
|
||||
)
|
||||
# Nowhere to load specs from in db mode
|
||||
if "database" not in parser.usage:
|
||||
general_group.add_argument(
|
||||
@@ -71,7 +87,9 @@ def omniarg_parser(
|
||||
|
||||
## General Command Line Options
|
||||
## ----------------------------
|
||||
add_general_group(parser, rocprof_compute_version)
|
||||
add_general_group(
|
||||
parser, rocprof_compute_version, supported_archs, rocprof_compute_home
|
||||
)
|
||||
parser._positionals.title = "Modes"
|
||||
parser._optionals.title = "Help"
|
||||
|
||||
@@ -106,7 +124,9 @@ Examples:
|
||||
)
|
||||
profile_parser._optionals.title = "Help"
|
||||
|
||||
add_general_group(profile_parser, rocprof_compute_version)
|
||||
add_general_group(
|
||||
profile_parser, rocprof_compute_version, supported_archs, rocprof_compute_home
|
||||
)
|
||||
profile_group = profile_parser.add_argument_group("Profile Options")
|
||||
roofline_group = profile_parser.add_argument_group("Standalone Roofline Options")
|
||||
|
||||
@@ -194,6 +214,12 @@ Examples:
|
||||
return value
|
||||
raise argparse.ArgumentTypeError(f"Invalid metric id: {value}")
|
||||
|
||||
profile_group.add_argument(
|
||||
"--list-available-metrics",
|
||||
dest="list_available_metrics",
|
||||
help="\t\t\tList all available metrics for analysis on current arch",
|
||||
action="store_true",
|
||||
)
|
||||
profile_group.add_argument(
|
||||
"-b",
|
||||
"--block",
|
||||
@@ -209,16 +235,6 @@ Examples:
|
||||
"\t\t\tCan provide multiple space separated arguments."
|
||||
),
|
||||
)
|
||||
profile_group.add_argument(
|
||||
"--list-metrics",
|
||||
metavar="",
|
||||
nargs="?",
|
||||
const="",
|
||||
# Argument to --list-metrics is optional
|
||||
choices=[""] + list(supported_archs.keys()), # ["gfx908", "gfx90a"],
|
||||
help=print_avail_arch(supported_archs.keys()),
|
||||
)
|
||||
|
||||
profile_group.add_argument(
|
||||
"--list-sets",
|
||||
action="store_true",
|
||||
@@ -232,13 +248,6 @@ Examples:
|
||||
"counters in a single pass.\n\t\t\tFor available sets, see --list-sets",
|
||||
)
|
||||
|
||||
profile_group.add_argument(
|
||||
"--config-dir",
|
||||
dest="config_dir",
|
||||
metavar="",
|
||||
help="\t\t\tSpecify the directory of customized report section configs.",
|
||||
default=rocprof_compute_home.joinpath("rocprof_compute_soc/analysis_configs/"),
|
||||
)
|
||||
profile_group.add_argument(
|
||||
"--join-type",
|
||||
metavar="",
|
||||
@@ -465,7 +474,9 @@ Examples:
|
||||
)
|
||||
db_parser._optionals.title = "Help"
|
||||
|
||||
add_general_group(db_parser, rocprof_compute_version)
|
||||
add_general_group(
|
||||
db_parser, rocprof_compute_version, supported_archs, rocprof_compute_home
|
||||
)
|
||||
interaction_group = db_parser.add_argument_group("Interaction Type")
|
||||
connection_group = db_parser.add_argument_group("Connection Options")
|
||||
|
||||
@@ -565,7 +576,9 @@ Examples:
|
||||
)
|
||||
analyze_parser._optionals.title = "Help"
|
||||
|
||||
add_general_group(analyze_parser, rocprof_compute_version)
|
||||
add_general_group(
|
||||
analyze_parser, rocprof_compute_version, supported_archs, rocprof_compute_home
|
||||
)
|
||||
analyze_group = analyze_parser.add_argument_group("Analyze Options")
|
||||
analyze_advanced_group = analyze_parser.add_argument_group("Advanced Options")
|
||||
|
||||
@@ -585,10 +598,10 @@ Examples:
|
||||
help="\t\tList all detected kernels and kernel dispatches.",
|
||||
)
|
||||
analyze_group.add_argument(
|
||||
"--list-metrics",
|
||||
metavar="",
|
||||
choices=supported_archs.keys(), # ["gfx906", "gfx908", "gfx90a"],
|
||||
help=print_avail_arch(supported_archs.keys()),
|
||||
"--list-available-metrics",
|
||||
dest="list_available_metrics",
|
||||
help="\t\tList all available metrics for analysis on current arch",
|
||||
action="store_true",
|
||||
)
|
||||
analyze_group.add_argument(
|
||||
"-k",
|
||||
@@ -767,13 +780,6 @@ Examples:
|
||||
default=2,
|
||||
help="\t\tSpecify desired decimal precision of analysis results. (DEFAULT: 2)",
|
||||
)
|
||||
analyze_advanced_group.add_argument(
|
||||
"--config-dir",
|
||||
dest="config_dir",
|
||||
metavar="",
|
||||
help="\t\tSpecify the directory of customized configs.",
|
||||
default=rocprof_compute_home.joinpath("rocprof_compute_soc/analysis_configs/"),
|
||||
)
|
||||
analyze_advanced_group.add_argument(
|
||||
"--cols",
|
||||
type=int,
|
||||
|
||||
@@ -85,6 +85,8 @@ class RocProfCompute:
|
||||
setattr(self.__args, "loglevel", self.__loglevel)
|
||||
set_locale_encoding()
|
||||
|
||||
self.sanitize()
|
||||
|
||||
if self.__mode == "profile":
|
||||
self.detect_profiler()
|
||||
elif self.__mode == "analyze":
|
||||
@@ -143,6 +145,21 @@ class RocProfCompute:
|
||||
self.__analyze_mode = "cli"
|
||||
return
|
||||
|
||||
def sanitize(self):
|
||||
block = False
|
||||
if (hasattr(self.__args, "filter_metrics") and self.__args.filter_metrics) or (
|
||||
hasattr(self.__args, "filter_blocks") and self.__args.filter_blocks
|
||||
):
|
||||
block = True
|
||||
|
||||
if self.__args.list_metrics is not None and block:
|
||||
console_error("Cannot use --list-metrics with --blocks")
|
||||
if (
|
||||
hasattr(self.__args, "list_available_metrics")
|
||||
and self.__args.list_available_metrics
|
||||
) and block:
|
||||
console_error("Cannot use --list-available-metrics with --blocks")
|
||||
|
||||
@demarcate
|
||||
def load_soc_specs(self, sysinfo: dict = None):
|
||||
"""Load OmniSoC instance for RocProfCompute run"""
|
||||
@@ -190,6 +207,15 @@ class RocProfCompute:
|
||||
if self.__args.specs:
|
||||
print(generate_machine_specs(self.__args))
|
||||
sys.exit(0)
|
||||
elif self.__args.list_metrics is not None:
|
||||
self.list_metrics()
|
||||
sys.exit(0)
|
||||
elif self.__args.config_dir:
|
||||
parser.print_help(sys.stderr)
|
||||
console_error(
|
||||
"rocprof-compute requires you to pass --list-metrics "
|
||||
"with --config-dir."
|
||||
)
|
||||
parser.print_help(sys.stderr)
|
||||
console_error(
|
||||
"rocprof-compute requires you to pass a valid mode. Detected None."
|
||||
@@ -225,16 +251,27 @@ class RocProfCompute:
|
||||
|
||||
@demarcate
|
||||
def list_metrics(self):
|
||||
if not self.__args.list_metrics:
|
||||
arch = self.__mspec.gpu_arch
|
||||
else:
|
||||
arch = self.__args.list_metrics
|
||||
self.load_soc_specs()
|
||||
|
||||
for_current_arch = False
|
||||
if (
|
||||
hasattr(self.__args, "list_available_metrics")
|
||||
and self.__args.list_available_metrics
|
||||
):
|
||||
for_current_arch = True
|
||||
|
||||
arch = (
|
||||
self.__mspec.gpu_arch
|
||||
if (for_current_arch or self.__args.list_metrics is None)
|
||||
else self.__args.list_metrics
|
||||
)
|
||||
if arch in self.__supported_archs.keys():
|
||||
ac = schema.ArchConfig()
|
||||
ac.panel_configs = file_io.load_panel_configs([
|
||||
self.__args.config_dir.joinpath(arch)
|
||||
])
|
||||
sys_info = self.__mspec.get_class_members().iloc[0]
|
||||
config_dir = Path(self.__args.config_dir)
|
||||
ac.panel_configs = file_io.load_panel_configs([config_dir.joinpath(arch)])
|
||||
sys_info = (
|
||||
self.__mspec.get_class_members().iloc[0] if for_current_arch else None
|
||||
)
|
||||
parser.build_dfs(archConfigs=ac, filter_metrics=[], sys_info=sys_info)
|
||||
for key, value in ac.metric_list.items():
|
||||
prefix = ""
|
||||
@@ -303,7 +340,7 @@ class RocProfCompute:
|
||||
self.print_graphic()
|
||||
self.load_soc_specs()
|
||||
|
||||
if self.__args.list_metrics is not None:
|
||||
if self.__args.list_metrics is not None or self.__args.list_available_metrics:
|
||||
self.list_metrics()
|
||||
elif self.__args.list_sets:
|
||||
self.list_sets()
|
||||
|
||||
@@ -555,24 +555,25 @@ def build_dfs(archConfigs, filter_metrics, sys_info):
|
||||
):
|
||||
# print(data_config["metric"])
|
||||
new_metrics = {}
|
||||
# NB: support single placeholder for now!!
|
||||
p_range = data_config["metric"].pop("placeholder_range")
|
||||
metric, metric_expr = data_config["metric"].popitem()
|
||||
# print(len(data_config["metric"]))
|
||||
# data_config['metric'].clear()
|
||||
for p, r in p_range.items():
|
||||
# NB: We have to resolve placeholder range first if it
|
||||
# is a build-in var. It will be too late to do it in
|
||||
# eval_metric(). This is the only reason we need
|
||||
# sys_info at this stage.
|
||||
var = calc_builtin_var(r, sys_info)
|
||||
for i in range(var):
|
||||
new_key = metric.replace(p, str(i))
|
||||
new_val = {}
|
||||
for k, v in metric_expr.items():
|
||||
new_val[k] = metric_expr[k].replace(p, str(i))
|
||||
# print(new_val)
|
||||
new_metrics[new_key] = new_val
|
||||
if sys_info is not None:
|
||||
# NB: support single placeholder for now!!
|
||||
p_range = data_config["metric"].pop("placeholder_range")
|
||||
metric, metric_expr = data_config["metric"].popitem()
|
||||
# print(len(data_config["metric"]))
|
||||
# data_config['metric'].clear()
|
||||
for p, r in p_range.items():
|
||||
# NB: We have to resolve placeholder range first if it
|
||||
# is a build-in var. It will be too late to do it in
|
||||
# eval_metric(). This is the only reason we need
|
||||
# sys_info at this stage.
|
||||
var = calc_builtin_var(r, sys_info)
|
||||
for i in range(var):
|
||||
new_key = metric.replace(p, str(i))
|
||||
new_val = {}
|
||||
for k, v in metric_expr.items():
|
||||
new_val[k] = metric_expr[k].replace(p, str(i))
|
||||
# print(new_val)
|
||||
new_metrics[new_key] = new_val
|
||||
|
||||
# print(p_range)
|
||||
# print(new_metrics)
|
||||
@@ -616,6 +617,16 @@ def build_dfs(archConfigs, filter_metrics, sys_info):
|
||||
df = pd.DataFrame(columns=headers)
|
||||
|
||||
i = 0
|
||||
|
||||
if not data_config["metric"]:
|
||||
data_source_idx = (
|
||||
str(data_config["id"] // 100)
|
||||
+ "."
|
||||
+ str(data_config["id"] % 100)
|
||||
)
|
||||
metric_idx = data_source_idx + "." + str(i)
|
||||
metric_list[data_source_idx] = data_config["title"]
|
||||
|
||||
for key, entries in data_config["metric"].items():
|
||||
data_source_idx = (
|
||||
str(data_config["id"] // 100)
|
||||
|
||||
Odkázat v novém úkolu
Zablokovat Uživatele