Skip to content

Commit

Permalink
more code formatting updates
Browse files Browse the repository at this point in the history
Signed-off-by: Karl W Schulz <karl.schulz@amd.com>
  • Loading branch information
koomie committed Feb 22, 2024
1 parent 5a27189 commit 76873dd
Show file tree
Hide file tree
Showing 5 changed files with 189 additions and 174 deletions.
46 changes: 27 additions & 19 deletions src/roofline.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,10 +223,12 @@ def generate_plot(self, dtype, fig=None) -> go.Figure():
"{} GB/s".format(
to_int(self.__ceiling_data[cache_level.lower()][2])
),
None
if self.__run_parameters["is_standalone"]
else "{} GB/s".format(
to_int(self.__ceiling_data[cache_level.lower()][2])
(
None
if self.__run_parameters["is_standalone"]
else "{} GB/s".format(
to_int(self.__ceiling_data[cache_level.lower()][2])
)
),
],
textposition="top right",
Expand All @@ -243,9 +245,13 @@ def generate_plot(self, dtype, fig=None) -> go.Figure():
mode=plot_mode,
hovertemplate="<b>%{text}</b>",
text=[
None
if self.__run_parameters["is_standalone"]
else "{} GFLOP/s".format(to_int(self.__ceiling_data["valu"][2])),
(
None
if self.__run_parameters["is_standalone"]
else "{} GFLOP/s".format(
to_int(self.__ceiling_data["valu"][2])
)
),
"{} GFLOP/s".format(to_int(self.__ceiling_data["valu"][2])),
],
textposition="top left",
Expand All @@ -265,9 +271,11 @@ def generate_plot(self, dtype, fig=None) -> go.Figure():
mode=plot_mode,
hovertemplate="<b>%{text}</b>",
text=[
None
if self.__run_parameters["is_standalone"]
else "{} GFLOP/s".format(to_int(self.__ceiling_data["mfma"][2])),
(
None
if self.__run_parameters["is_standalone"]
else "{} GFLOP/s".format(to_int(self.__ceiling_data["mfma"][2]))
),
"{} GFLOP/s".format(to_int(self.__ceiling_data["mfma"][2])),
],
textposition=pos,
Expand All @@ -285,9 +293,9 @@ def generate_plot(self, dtype, fig=None) -> go.Figure():
name="ai_l1",
mode="markers",
marker={"color": "#00CC96"},
marker_symbol=SYMBOLS
if self.__run_parameters["include_kernel_names"]
else None,
marker_symbol=(
SYMBOLS if self.__run_parameters["include_kernel_names"] else None
),
)
)
fig.add_trace(
Expand All @@ -297,9 +305,9 @@ def generate_plot(self, dtype, fig=None) -> go.Figure():
name="ai_l2",
mode="markers",
marker={"color": "#EF553B"},
marker_symbol=SYMBOLS
if self.__run_parameters["include_kernel_names"]
else None,
marker_symbol=(
SYMBOLS if self.__run_parameters["include_kernel_names"] else None
),
)
)
fig.add_trace(
Expand All @@ -309,9 +317,9 @@ def generate_plot(self, dtype, fig=None) -> go.Figure():
name="ai_hbm",
mode="markers",
marker={"color": "#636EFA"},
marker_symbol=SYMBOLS
if self.__run_parameters["include_kernel_names"]
else None,
marker_symbol=(
SYMBOLS if self.__run_parameters["include_kernel_names"] else None
),
)
)

Expand Down
94 changes: 51 additions & 43 deletions src/utils/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,9 +298,11 @@ def build_table_chart(
[
{
column: {
"value": str(row["Tips"])
if column == display_columns[0] and row["Tips"]
else "",
"value": (
str(row["Tips"])
if column == display_columns[0] and row["Tips"]
else ""
),
"type": "markdown",
}
for column, value in row.items()
Expand All @@ -325,52 +327,58 @@ def build_table_chart(
# style cell
style_cell={"maxWidth": "500px"},
# display style
style_header={
"backgroundColor": "rgb(30, 30, 30)",
"color": "white",
"fontWeight": "bold",
}
if IS_DARK
else {},
style_data={
"backgroundColor": "rgb(50, 50, 50)",
"color": "white",
"whiteSpace": "normal",
"height": "auto",
}
if IS_DARK
else {},
style_data_conditional=[
{"if": {"row_index": "odd"}, "backgroundColor": "rgb(60, 60, 60)"},
style_header=(
{
"if": {"column_id": "PoP", "filter_query": "{PoP} > 50"},
"backgroundColor": "#ffa90a",
"backgroundColor": "rgb(30, 30, 30)",
"color": "white",
},
"fontWeight": "bold",
}
if IS_DARK
else {}
),
style_data=(
{
"if": {"column_id": "PoP", "filter_query": "{PoP} > 80"},
"backgroundColor": "#ff120a",
"backgroundColor": "rgb(50, 50, 50)",
"color": "white",
},
{
"if": {
"column_id": "Avg",
"filter_query": "{Unit} = Pct && {Avg} > 50",
"whiteSpace": "normal",
"height": "auto",
}
if IS_DARK
else {}
),
style_data_conditional=(
[
{"if": {"row_index": "odd"}, "backgroundColor": "rgb(60, 60, 60)"},
{
"if": {"column_id": "PoP", "filter_query": "{PoP} > 50"},
"backgroundColor": "#ffa90a",
"color": "white",
},
"backgroundColor": "#ffa90a",
"color": "white",
},
{
"if": {
"column_id": "Avg",
"filter_query": "{Unit} = Pct && {Avg} > 80",
{
"if": {"column_id": "PoP", "filter_query": "{PoP} > 80"},
"backgroundColor": "#ff120a",
"color": "white",
},
"backgroundColor": "#ff120a",
"color": "white",
},
]
if IS_DARK
else [],
{
"if": {
"column_id": "Avg",
"filter_query": "{Unit} = Pct && {Avg} > 50",
},
"backgroundColor": "#ffa90a",
"color": "white",
},
{
"if": {
"column_id": "Avg",
"filter_query": "{Unit} = Pct && {Avg} > 80",
},
"backgroundColor": "#ff120a",
"color": "white",
},
]
if IS_DARK
else []
),
# the df to display
data=display_df.to_dict("records"),
)
Expand Down
90 changes: 32 additions & 58 deletions src/utils/roofline_calc.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,21 +195,11 @@ def calc_ai(sort_type, ret_df):
df = df.sort_values(by=["Kernel_Name"])
df = df.reset_index(drop=True)

total_flops = (
valu_flops
) = (
mfma_flops_bf16
) = (
mfma_flops_f16
) = (
mfma_iops_i8
) = (
total_flops = valu_flops = mfma_flops_bf16 = mfma_flops_f16 = mfma_iops_i8 = (
mfma_flops_f32
) = (
mfma_flops_f64
) = (
lds_data
) = L1cache_data = L2cache_data = hbm_data = calls = totalDuration = avgDuration = 0.0
) = mfma_flops_f64 = lds_data = L1cache_data = L2cache_data = hbm_data = calls = (
totalDuration
) = avgDuration = 0.0

kernelName = ""

Expand Down Expand Up @@ -390,23 +380,11 @@ def calc_ai(sort_type, ret_df):
kernelName, idx, calls
)
)
total_flops = (
valu_flops
) = (
mfma_flops_bf16
) = (
mfma_flops_f16
) = (
mfma_iops_i8
) = (
total_flops = valu_flops = mfma_flops_bf16 = mfma_flops_f16 = mfma_iops_i8 = (
mfma_flops_f32
) = (
mfma_flops_f64
) = (
lds_data
) = (
L1cache_data
) = L2cache_data = hbm_data = calls = totalDuration = avgDuration = 0.0
) = mfma_flops_f64 = lds_data = L1cache_data = L2cache_data = hbm_data = (
calls
) = totalDuration = avgDuration = 0.0

if sort_type == "dispatches":
myList.append(
Expand All @@ -428,23 +406,11 @@ def calc_ai(sort_type, ret_df):
avgDuration,
)
)
total_flops = (
valu_flops
) = (
mfma_flops_bf16
) = (
mfma_flops_f16
) = (
mfma_iops_i8
) = (
total_flops = valu_flops = mfma_flops_bf16 = mfma_flops_f16 = mfma_iops_i8 = (
mfma_flops_f32
) = (
mfma_flops_f64
) = (
lds_data
) = (
L1cache_data
) = L2cache_data = hbm_data = calls = totalDuration = avgDuration = 0.0
) = mfma_flops_f64 = lds_data = L1cache_data = L2cache_data = hbm_data = (
calls
) = totalDuration = avgDuration = 0.0

myList.sort(key=lambda x: x.totalDuration, reverse=True)

Expand All @@ -456,24 +422,32 @@ def calc_ai(sort_type, ret_df):
# Create list of top 5 intensities
while i < TOP_N and i != len(myList):
kernelNames.append(myList[i].KernelName)
intensities["ai_l1"].append(
myList[i].total_flops / myList[i].L1cache_data
) if myList[i].L1cache_data else intensities["ai_l1"].append(0)
(
intensities["ai_l1"].append(myList[i].total_flops / myList[i].L1cache_data)
if myList[i].L1cache_data
else intensities["ai_l1"].append(0)
)
# print("cur_ai_L1", myList[i].total_flops/myList[i].L1cache_data) if myList[i].L1cache_data else print("null")
# print()
intensities["ai_l2"].append(
myList[i].total_flops / myList[i].L2cache_data
) if myList[i].L2cache_data else intensities["ai_l2"].append(0)
(
intensities["ai_l2"].append(myList[i].total_flops / myList[i].L2cache_data)
if myList[i].L2cache_data
else intensities["ai_l2"].append(0)
)
# print("cur_ai_L2", myList[i].total_flops/myList[i].L2cache_data) if myList[i].L2cache_data else print("null")
# print()
intensities["ai_hbm"].append(
myList[i].total_flops / myList[i].hbm_data
) if myList[i].hbm_data else intensities["ai_hbm"].append(0)
(
intensities["ai_hbm"].append(myList[i].total_flops / myList[i].hbm_data)
if myList[i].hbm_data
else intensities["ai_hbm"].append(0)
)
# print("cur_ai_hbm", myList[i].total_flops/myList[i].hbm_data) if myList[i].hbm_data else print("null")
# print()
curr_perf.append(myList[i].total_flops / myList[i].avgDuration) if myList[
i
].avgDuration else curr_perf.append(0)
(
curr_perf.append(myList[i].total_flops / myList[i].avgDuration)
if myList[i].avgDuration
else curr_perf.append(0)
)
# print("cur_perf", myList[i].total_flops/myList[i].avgDuration) if myList[i].avgDuration else print("null")

i += 1
Expand Down
20 changes: 12 additions & 8 deletions src/utils/tty.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,11 @@ def show_all(args, runs, archConfigs, output):
else:
cur_df_copy = copy.deepcopy(cur_df)
cur_df_copy[header] = [
round(float(x), args.decimal)
if x != ""
else x
(
round(float(x), args.decimal)
if x != ""
else x
)
for x in base_df[header]
]
df = pd.concat([df, cur_df_copy[header]], axis=1)
Expand Down Expand Up @@ -214,11 +216,13 @@ def show_all(args, runs, archConfigs, output):
# fash for now.
ss += (
tabulate(
df.transpose()
if type != "raw_csv_table"
and "columnwise" in table_config
and table_config["columnwise"] == True
else df,
(
df.transpose()
if type != "raw_csv_table"
and "columnwise" in table_config
and table_config["columnwise"] == True
else df
),
headers="keys",
tablefmt="fancy_grid",
floatfmt="." + str(args.decimal) + "f",
Expand Down
Loading

0 comments on commit 76873dd

Please sign in to comment.