Update headers based on latest rocprofv2 output. Overwrite old headers.

Signed-off-by: colramos-amd <colramos@amd.com>
This commit is contained in:
colramos-amd
2024-01-19 13:46:01 -06:00
committad av Cole Ramos
förälder 7846a663fd
incheckning a171e776e4
10 ändrade filer med 83 tillägg och 103 borttagningar
+8 -8
Visa fil
@@ -95,28 +95,28 @@ def create_df_kernel_top_stats(
# The logic below for filters are the same as in parser.apply_filters(),
# which can be merged together if need it.
if filter_gpu_ids:
df = df.loc[df["gpu-id"].astype(str).isin([filter_gpu_ids])]
df = df.loc[df["GPU_ID"].astype(str).isin([filter_gpu_ids])]
if filter_dispatch_ids:
# NB: support ignoring the 1st n dispatched execution by '> n'
# The better way may be parsing python slice string
if ">" in filter_dispatch_ids[0]:
m = re.match("\> (\d+)", filter_dispatch_ids[0])
df = df[df["Index"] > int(m.group(1))]
df = df[df["Dispatch_ID"] > int(m.group(1))]
else:
df = df.loc[df["Index"].astype(str).isin(filter_dispatch_ids)]
df = df.loc[df["Dispatch_ID"].astype(str).isin(filter_dispatch_ids)]
# First, create a dispatches file used to populate global vars
dispatch_info = df.loc[:, ["Index", "KernelName", "gpu-id"]]
dispatch_info = df.loc[:, ["Dispatch_ID", "Kernel_Name", "GPU_ID"]]
dispatch_info.to_csv(os.path.join(raw_data_dir, "pmc_dispatch_info.csv"), index=False)
time_stats = pd.concat(
[df["KernelName"], (df["EndNs"] - df["BeginNs"])],
keys=["KernelName", "ExeTime"],
[df["Kernel_Name"], (df["End_Timestamp"] - df["Start_Timestamp"])],
keys=["Kernel_Name", "ExeTime"],
axis=1,
)
grouped = time_stats.groupby(by=["KernelName"]).agg(
grouped = time_stats.groupby(by=["Kernel_Name"]).agg(
{"ExeTime": ["count", "sum", "mean", "median"]}
)
@@ -147,7 +147,7 @@ def create_df_kernel_top_stats(
grouped.to_csv(os.path.join(raw_data_dir, "pmc_kernel_top.csv"), index=False)
elif sortby == "kernel":
grouped = grouped.sort_values("KernelName")
grouped = grouped.sort_values("Kernel_Name")
grouped = grouped.head(max_kernel_num) # Display only the top n results
grouped.to_csv(os.path.join(raw_data_dir, "pmc_kernel_top.csv"), index=False)
+2 -2
Visa fil
@@ -186,7 +186,7 @@ def get_header(raw_pmc, input_filters, kernel_names):
str,
raw_pmc[
schema.pmc_perf_file_prefix
]["gpu-id"],
]["GPU_ID"],
)
),
True,
@@ -219,7 +219,7 @@ def get_header(raw_pmc, input_filters, kernel_names):
str,
raw_pmc[
schema.pmc_perf_file_prefix
]["Index"],
]["Dispatch_ID"],
)
),
id="disp-filt",
+16 -16
Visa fil
@@ -61,7 +61,7 @@ pmc_kernel_top_table_id = 1
# },
# {
# "case": { "$eq": [ $normUnit, "per Sec"]} ,
# "then": {"$divide":[{"$subtract": ["&EndNs", "&BeginNs" ]}, 1000000000]}
# "then": {"$divide":[{"$subtract": ["&End_Timestamp", "&Start_Timestamp" ]}, 1000000000]}
# }
# ],
# "default": 1
@@ -70,7 +70,7 @@ pmc_kernel_top_table_id = 1
supported_denom = {
"per_wave": "SQ_WAVES",
"per_cycle": "GRBM_GUI_ACTIVE",
"per_second": "((EndNs - BeginNs) / 1000000000)",
"per_second": "((End_Timestamp - Start_Timestamp) / 1000000000)",
"per_kernel": "1",
}
@@ -79,7 +79,7 @@ build_in_vars = {
"numActiveCUs": "TO_INT(MIN((((ROUND(AVG(((4 * SQ_BUSY_CU_CYCLES) / GRBM_GUI_ACTIVE)), \
0) / $maxWavesPerCU) * 8) + MIN(MOD(ROUND(AVG(((4 * SQ_BUSY_CU_CYCLES) \
/ GRBM_GUI_ACTIVE)), 0), $maxWavesPerCU), 8)), $numCU))",
"kernelBusyCycles": "ROUND(AVG((((EndNs - BeginNs) / 1000) * $sclk)), 0)",
"kernelBusyCycles": "ROUND(AVG((((End_Timestamp - Start_Timestamp) / 1000) * $sclk)), 0)",
}
supported_call = {
@@ -357,15 +357,15 @@ def gen_counter_list(formula):
}
built_in_counter = [
"lds",
"grd",
"wgr",
"arch_vgpr",
"accum_vgpr",
"sgpr",
"scr",
"BeginNs",
"EndNs",
"LDS_Per_Workgroup",
"Grid_Size",
"Workgroup_Size",
"Arch_VGPR",
"Accum_VGPR",
"SGPR",
"Scratch_Per_Workitem",
"Start_Timestamp",
"End_Timestamp",
]
visited = False
@@ -492,7 +492,7 @@ def build_dfs(archConfigs, filter_metrics, sys_info):
for data_source in panel["data source"]:
for type, data_config in data_source.items():
if type == "metric_table":
headers = ["Index"]
headers = ["Dispatch_ID"]
if (
"cli_style" in data_config
@@ -600,7 +600,7 @@ def build_dfs(archConfigs, filter_metrics, sys_info):
i += 1
df.set_index("Index", inplace=True)
df.set_index("Dispatch_ID", inplace=True)
# df.set_index('Metric', inplace=True)
# print(tabulate(df, headers='keys', tablefmt='fancy_grid'))
elif type == "raw_csv_table":
@@ -828,7 +828,7 @@ def apply_filters(workload, dir, is_gui, debug):
if workload.filter_gpu_ids:
ret_df = ret_df.loc[
ret_df[schema.pmc_perf_file_prefix]["gpu-id"]
ret_df[schema.pmc_perf_file_prefix]["GPU_ID"]
.astype(str)
.isin([workload.filter_gpu_ids])
]
@@ -890,7 +890,7 @@ def apply_filters(workload, dir, is_gui, debug):
if ">" in workload.filter_dispatch_ids[0]:
m = re.match("\> (\d+)", workload.filter_dispatch_ids[0])
ret_df = ret_df[
ret_df[schema.pmc_perf_file_prefix]["Index"] > int(m.group(1))
ret_df[schema.pmc_perf_file_prefix]["Dispatch_ID"] > int(m.group(1))
]
else:
dispatches = [int(x) for x in workload.filter_dispatch_ids]
+2 -2
Visa fil
@@ -338,8 +338,8 @@ def calc_ai(sort_type, ret_df):
logging.debug("[roofline] {}: Skipped hbm_data at index {}".format(kernelName[:35], idx))
pass
totalDuration += df["EndNs"][idx] - df["BeginNs"][idx]
avgDuration += df["EndNs"][idx] - df["BeginNs"][idx]
totalDuration += df["End_Timestamp"][idx] - df["Start_Timestamp"][idx]
avgDuration += df["End_Timestamp"][idx] - df["Start_Timestamp"][idx]
calls += 1
+2 -2
Visa fil
@@ -82,10 +82,10 @@ def show_all(args, runs, archConfigs, output):
if (
type == "raw_csv_table"
and table_config["source"] == "pmc_kernel_top.csv"
and (header == "KernelName" or header == "Kernel_Name")
and header == "Kernel_Name"
):
# NB: the width of kernel name might depend on the header of the table.
adjusted_name = base_df["KernelName"].apply(
adjusted_name = base_df["Kernel_Name"].apply(
lambda x: string_multiple_lines(x, 40, 3)
)
df = pd.concat([df, adjusted_name], axis=1)
+22 -3
Visa fil
@@ -242,20 +242,39 @@ def run_prof(fname, profiler_options, target, workload_dir):
)
# Remove temp directory
shutil.rmtree(workload_dir + "/" + "out")
# Overwrite headers
output_headers = {
"KernelName": "Kernel_Name",
"Index": "Dispatch_ID",
"grd": "Grid_Size",
"gpu-id": "GPU_ID",
"wgr": "Workgroup_Size",
"lds": "LDS_Per_Workgroup",
"scr": "Scratch_Per_Workitem",
"sgpr": "SGPR",
"arch_vgpr": "Arch_VGPR",
"accum_vgpr": "Accum_VGPR",
"BeginNs": "Start_Timestamp",
"EndNs": "End_Timestamp",
}
df = pd.read_csv(workload_dir + "/" + fbase + ".csv")
df.rename(columns=output_headers, inplace=True)
df.to_csv(workload_dir + "/" + fbase + ".csv", index=False)
# write rocprof output to logging
logging.info(output)
def replace_timestamps(workload_dir):
df_stamps = pd.read_csv(workload_dir + "/timestamps.csv")
if "BeginNs" in df_stamps.columns and "EndNs" in df_stamps.columns:
if "Start_Timestamp" in df_stamps.columns and "End_Timestamp" in df_stamps.columns:
# Update timestamps for all *.csv output files
for fname in glob.glob(workload_dir + "/" + "*.csv"):
if path(fname).name != "sysinfo.csv":
df_pmc_perf = pd.read_csv(fname)
df_pmc_perf["BeginNs"] = df_stamps["BeginNs"]
df_pmc_perf["EndNs"] = df_stamps["EndNs"]
df_pmc_perf["Start_Timestamp"] = df_stamps["Start_Timestamp"]
df_pmc_perf["End_Timestamp"] = df_stamps["End_Timestamp"]
df_pmc_perf.to_csv(fname, index=False)
else:
warning = "WARNING: Incomplete profiling data detected. Unable to update timestamps."