[rocprofv3-avail] Documentation update and column formatting (#447)
* addressing issues * doc fix * test fix * fix * fix formatting issue and doc update * fix column size * fix * fix formatting in output * tests fix * test fix * add new line * add new line * fix new line * fixing typo in using-rocprofv3-avail.rst
This commit is contained in:
committed by
GitHub
parent
e5161f6e06
commit
3aaffc42da
@@ -185,20 +185,32 @@ def get_basic_agent_info(info):
|
||||
return basic_info
|
||||
|
||||
|
||||
def get_number_columns(max_name_len):
|
||||
total_column_width = 120
|
||||
if sys.stdout.isatty():
|
||||
total_column_width = os.get_terminal_size().columns
|
||||
width = total_column_width / (max_name_len + 1)
|
||||
if width < 1:
|
||||
return 1
|
||||
return int(width)
|
||||
|
||||
|
||||
def list_basic_agent(args, list_counters):
|
||||
def print_agent_counter(counters, info):
|
||||
names = ["{:20}".format(counter.name) for counter in counters]
|
||||
print(" PMC:\n")
|
||||
for idx in range(0, len(names), int(len(names) / 20)):
|
||||
print(
|
||||
" {}".format(
|
||||
" ".join(names[idx : (idx + int(len(names) / 20))])
|
||||
)
|
||||
)
|
||||
def print_agent_counter(counters):
|
||||
names_len = [len(counter.name) for counter in counters]
|
||||
names = [
|
||||
"{name:{width}}".format(name=counter.name, width=max(names_len))
|
||||
for counter in counters
|
||||
]
|
||||
columns = get_number_columns(max(names_len))
|
||||
print("{:30}:\n".format("PMC"))
|
||||
for idx in range(0, len(names), columns):
|
||||
print("{}".format(" ".join(names[idx : (idx + columns)])))
|
||||
print("\n")
|
||||
|
||||
def print_basic_info(info):
|
||||
print("GPU:{}\n".format(info["logical_node_type_id"]))
|
||||
print("\n".join([" {:20}: {}".format(key, itr) for key, itr in info.items()]))
|
||||
print("\n".join(["{:30}:\t{}".format(key, itr) for key, itr in info.items()]))
|
||||
if not list_counters:
|
||||
print("\n")
|
||||
|
||||
@@ -213,13 +225,13 @@ def list_basic_agent(args, list_counters):
|
||||
):
|
||||
print_basic_info(get_basic_agent_info(info))
|
||||
if list_counters:
|
||||
print_agent_counter(agent_counters[agent], info)
|
||||
print_agent_counter(agent_counters[agent])
|
||||
break
|
||||
|
||||
elif info["type"] == 2 and args.device is None:
|
||||
print_basic_info(get_basic_agent_info(info))
|
||||
if list_counters:
|
||||
print_agent_counter(agent_counters[agent], info)
|
||||
print_agent_counter(agent_counters[agent])
|
||||
|
||||
|
||||
def list_pc_sampling(args):
|
||||
@@ -228,7 +240,12 @@ def list_pc_sampling(args):
|
||||
print("Agents supporting PC Sampling\n")
|
||||
for agent in sampling_agents.keys():
|
||||
info = agent_info_map[agent]
|
||||
print("GPU:{}\nNAME:{}\n".format(info["logical_node_type_id"], info["name"]))
|
||||
print(
|
||||
"{:8}:\t{}\n{:8}:\t{}".format(
|
||||
"GPU", info["logical_node_type_id"], "Name", info["name"]
|
||||
)
|
||||
)
|
||||
print("\n")
|
||||
|
||||
|
||||
def info_pc_sampling(args):
|
||||
@@ -236,8 +253,12 @@ def info_pc_sampling(args):
|
||||
agent_info_map = avail.get_agent_info_map()
|
||||
for agent, configs in sampling_agents.items():
|
||||
info = agent_info_map[agent]
|
||||
print("GPU:{}\nNAME:{}".format(info["logical_node_type_id"], info["name"]))
|
||||
print("configs:")
|
||||
print(
|
||||
"{:8}:\t{}\n{:8}:\t{}".format(
|
||||
"GPU", info["logical_node_type_id"], "Name", info["name"]
|
||||
)
|
||||
)
|
||||
print("{:8}:".format("configs"))
|
||||
for config in configs:
|
||||
print(config)
|
||||
print("\n")
|
||||
@@ -245,15 +266,16 @@ def info_pc_sampling(args):
|
||||
|
||||
|
||||
def listing(args):
|
||||
def print_agent_counter(counters, info):
|
||||
names = ["{:20}".format(counter.name) for counter in counters]
|
||||
print("PMC:\n")
|
||||
for idx in range(0, len(names), int(len(names) / 20)):
|
||||
print(
|
||||
" {}".format(
|
||||
" ".join(names[idx : (idx + int(len(names) / 20))])
|
||||
)
|
||||
)
|
||||
def print_agent_counter(counters):
|
||||
names_len = [len(counter.name) for counter in counters]
|
||||
names = [
|
||||
"{name:{width}}".format(name=counter.name, width=max(names_len))
|
||||
for counter in counters
|
||||
]
|
||||
columns = get_number_columns(max(names_len))
|
||||
print("{:30}:\n".format("PMC"))
|
||||
for idx in range(0, len(names), columns):
|
||||
print("{:30}".format(" ".join(names[idx : (idx + columns)])))
|
||||
|
||||
agent_counters = avail.get_counters()
|
||||
agent_info_map = avail.get_agent_info_map()
|
||||
@@ -264,12 +286,22 @@ def listing(args):
|
||||
and args.device is not None
|
||||
and info["logical_node_type_id"] == args.device
|
||||
):
|
||||
print("GPU:{}\nNAME:{}".format(info["logical_node_type_id"], info["name"]))
|
||||
print_agent_counter(agent_counters[agent], info)
|
||||
print(
|
||||
"{:30}:\t{}\n{:30}:\t{}".format(
|
||||
"GPU", info["logical_node_type_id"], "Name", info["name"]
|
||||
)
|
||||
)
|
||||
print_agent_counter(agent_counters[agent])
|
||||
print("\n")
|
||||
break
|
||||
elif info["type"] == 2 and args.device is None:
|
||||
print("GPU:{}\nNAME:{}".format(info["logical_node_type_id"], info["name"]))
|
||||
print_agent_counter(agent_counters[agent], info)
|
||||
print(
|
||||
"{:30}:\t{}\n{:30}:\t{}".format(
|
||||
"GPU", info["logical_node_type_id"], "Name", info["name"]
|
||||
)
|
||||
)
|
||||
print_agent_counter(agent_counters[agent])
|
||||
print("\n")
|
||||
|
||||
|
||||
def info_pmc(args):
|
||||
@@ -285,7 +317,7 @@ def info_pmc(args):
|
||||
else:
|
||||
for pmc in args.pmc:
|
||||
for counter in pmc_counters:
|
||||
if pmc == counter.get_as_dict()["counter_name"]:
|
||||
if pmc == counter.get_as_dict()["Counter_Name"]:
|
||||
print(counter)
|
||||
print("\n")
|
||||
|
||||
@@ -295,11 +327,19 @@ def info_pmc(args):
|
||||
and args.device is not None
|
||||
and info["logical_node_type_id"] == args.device
|
||||
):
|
||||
print("GPU:{}\nNAME:{}".format(info["logical_node_type_id"], info["name"]))
|
||||
print(
|
||||
"{}:{}\n{}:{}".format(
|
||||
"GPU", info["logical_node_type_id"], "Name", info["name"]
|
||||
)
|
||||
)
|
||||
print_pmc_info(args, agent_counters[agent])
|
||||
break
|
||||
elif info["type"] == 2 and args.device is None:
|
||||
print("GPU:{}\nNAME:{}".format(info["logical_node_type_id"], info["name"]))
|
||||
print(
|
||||
"{}:{}\n{}:{}".format(
|
||||
"GPU", info["logical_node_type_id"], "Name", info["name"]
|
||||
)
|
||||
)
|
||||
print_pmc_info(args, agent_counters[agent])
|
||||
|
||||
|
||||
@@ -314,10 +354,12 @@ def process_info(args):
|
||||
|
||||
|
||||
def process_list(args):
|
||||
if not args.agent and args.pc_sampling is None:
|
||||
if args.agent is None and args.pc_sampling is None and args.pmc is None:
|
||||
listing(args)
|
||||
if args.agent:
|
||||
list_basic_agent(args, False)
|
||||
if args.pmc:
|
||||
listing(args)
|
||||
if args.pc_sampling:
|
||||
os.environ["ROCPROFILER_PC_SAMPLING_BETA_ENABLED"] = "on"
|
||||
list_pc_sampling(args)
|
||||
@@ -341,7 +383,7 @@ def process_pmc_check(args):
|
||||
agent_counters = avail.get_counters()
|
||||
for agent, counters in agent_counters.items():
|
||||
for counter in counters:
|
||||
if counter.get_as_dict()["counter_name"] == counter_name:
|
||||
if counter.get_as_dict()["Counter_Name"] == counter_name:
|
||||
return counter.counter_handle
|
||||
avail.fatal_error("Invalid counter name")
|
||||
|
||||
@@ -418,8 +460,9 @@ def main(argv=None):
|
||||
ROCPROFV3_AVAIL_DIR = os.path.dirname(os.path.realpath(__file__))
|
||||
ROCM_DIR = os.path.dirname(ROCPROFV3_AVAIL_DIR)
|
||||
ROCPROF_LIST_AVAIL_TOOL_LIBRARY = (
|
||||
f"{ROCM_DIR}/libexec/rocprofiler-sdk/librocprofv3-list-avail.so"
|
||||
f"{ROCM_DIR}/lib/rocprofiler-sdk/librocprofv3-list-avail.so"
|
||||
)
|
||||
os.environ["ROCPROFILER_METRICS_PATH"] = f"{ROCM_DIR}/share/rocprofiler-sdk"
|
||||
avail.loadLibrary.libname = os.environ.get(
|
||||
"ROCPROF_LIST_AVAIL_TOOL_LIBRARY", ROCPROF_LIST_AVAIL_TOOL_LIBRARY
|
||||
)
|
||||
|
||||
@@ -1056,7 +1056,7 @@ def run(app_args, args, **kwargs):
|
||||
f"{ROCM_DIR}/lib/rocprofiler-sdk/librocprofiler-sdk-tool-kokkosp.so"
|
||||
)
|
||||
ROCPROF_LIST_AVAIL_TOOL_LIBRARY = (
|
||||
f"{ROCM_DIR}/libexec/rocprofiler-sdk/librocprofv3-list-avail.so"
|
||||
f"{ROCM_DIR}/lib/rocprofiler-sdk/librocprofv3-list-avail.so"
|
||||
)
|
||||
|
||||
ROCPROF_TOOL_LIBRARY = resolve_library_path(ROCPROF_TOOL_LIBRARY, args)
|
||||
|
||||
@@ -36,18 +36,16 @@ def fatal_error(msg, exit_code=1):
|
||||
|
||||
def build_counter_string(obj):
|
||||
counter_str = "\n".join(
|
||||
["{:20}: {}".format(key, itr) for key, itr in obj.get_as_dict().items()]
|
||||
["{:20}:\t{}".format(key, itr) for key, itr in obj.get_as_dict().items()]
|
||||
)
|
||||
counter_str = counter_str + "\n"
|
||||
for dim in obj.dimensions:
|
||||
counter_str = counter_str + dim.__str__()
|
||||
counter_str = counter_str + "\n"
|
||||
|
||||
counter_str += "\n" + "{:20}:\t".format("Dimensions")
|
||||
counter_str += " ".join(dim.__str__() for dim in obj.dimensions)
|
||||
return counter_str
|
||||
|
||||
|
||||
class dimension:
|
||||
|
||||
columns = ["dimension_id", "dimension_name", "dimension_instances"]
|
||||
columns = ["Dimension_Id", "Dimension_Name", "Dimension_Instances"]
|
||||
|
||||
def __init__(self, dimension_id, dimension_name, dimension_instances):
|
||||
self.id = dimension_id
|
||||
@@ -58,18 +56,16 @@ class dimension:
|
||||
return dict(zip((self.columns), [self.id, self.name, self.instances]))
|
||||
|
||||
def __str__(self):
|
||||
dimension = "{:20}: {}\n".format(
|
||||
"dimension_name", self.get_as_dict()["dimension_name"]
|
||||
)
|
||||
dimension += "{:20}: [0:{}]".format(
|
||||
"dimension_instances", self.get_as_dict()["dimension_instances"]
|
||||
dimension = "{}[0:{}]".format(
|
||||
self.get_as_dict()["Dimension_Name"],
|
||||
self.get_as_dict()["Dimension_Instances"] - 1,
|
||||
)
|
||||
return dimension
|
||||
|
||||
|
||||
class counter:
|
||||
|
||||
columns = ["counter_name", "description"]
|
||||
columns = ["Counter_Name", "Description"]
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
@@ -90,13 +86,13 @@ class counter:
|
||||
|
||||
def __str__(self):
|
||||
return "\n".join(
|
||||
["{:20}: {}".format(key, itr) for key, itr in self.get_as_dict().items()]
|
||||
["{:20}:\t{}".format(key, itr) for key, itr in self.get_as_dict().items()]
|
||||
)
|
||||
|
||||
|
||||
class derived_counter(counter):
|
||||
|
||||
columns = ["counter_name", "description", "expression"]
|
||||
columns = ["Counter_Name", "Description", "Expression"]
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
@@ -125,7 +121,7 @@ class derived_counter(counter):
|
||||
|
||||
class basic_counter(counter):
|
||||
|
||||
columns = ["counter_name", "description", "block"]
|
||||
columns = ["Counter_Name", "Description", "Block"]
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
@@ -154,7 +150,7 @@ class basic_counter(counter):
|
||||
|
||||
class pc_config:
|
||||
|
||||
columns = ["method", "unit", "min_interval", "max_interval", "flags"]
|
||||
columns = ["Method", "Unit", "Min_Interval", "Max_Interval", "Flags"]
|
||||
|
||||
def __init__(self, config_method, config_unit, min_interval, max_interval, flags):
|
||||
|
||||
@@ -168,9 +164,9 @@ class pc_config:
|
||||
|
||||
return "\n".join(
|
||||
[
|
||||
" {:20}:{}".format(
|
||||
" {:20}:\t{}".format(
|
||||
key,
|
||||
itr if key == "method" or key == "unit" else self.get_value(key, itr),
|
||||
itr if key == "Method" or key == "Unit" else self.get_value(key, itr),
|
||||
)
|
||||
for key, itr in self.get_as_dict().items()
|
||||
]
|
||||
@@ -178,9 +174,9 @@ class pc_config:
|
||||
|
||||
@staticmethod
|
||||
def get_value(key, itr):
|
||||
if key == "min_interval" or key == "max_interval":
|
||||
if key == "Min_Interval" or key == "Max_Interval":
|
||||
return itr.value
|
||||
elif key == "flags":
|
||||
elif key == "Flags":
|
||||
if itr.value == 1:
|
||||
return "interval pow2"
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user