Perf plot
This commit is contained in:
committed by
Linus Baumberger
parent
ca969564a6
commit
e7af3103e8
+49
-60
@@ -5,14 +5,15 @@ import matplotlib.pyplot as plt
|
||||
import matplotlib.patheffects as pe
|
||||
#import seaborn as sns # tried it, the default look was worse
|
||||
|
||||
df = pd.read_csv("analysis/results.csv")
|
||||
df = pd.read_csv("analysis/results_x86.csv")
|
||||
|
||||
# peaks for the ryzen ai 7 350 (zen5) at 2GHz. 2 fma units and the datapath is 256 bit
|
||||
# peaks for the ryzen ai 7 350 (zen5) at 2GHz. 2 fma + 2 fadd units and the datapath is 256 bit
|
||||
# -> scalar 6, double 24, float 48 flops/cycle
|
||||
SCALAR = 6
|
||||
PEAK_D = 24
|
||||
PEAK_F = 48
|
||||
maroon = "#A71D5B"
|
||||
crimson = "#DC143C"
|
||||
|
||||
|
||||
def get(v, n=5000):
|
||||
@@ -20,13 +21,13 @@ def get(v, n=5000):
|
||||
|
||||
|
||||
def getline(v):
|
||||
s = df[df.variant == v].sort_values("n")
|
||||
s = df[df.variant == v].sort_values("n") # pyright: ignore[reportCallIssue]
|
||||
return s.n.values, s["flops_per_cycle"].values
|
||||
|
||||
|
||||
def label_lines_above(ax,
|
||||
entries,
|
||||
fontsize=9,
|
||||
fontsize: float = 9,
|
||||
rotate=False,
|
||||
dy_frac=0.012,
|
||||
halo=0):
|
||||
@@ -108,79 +109,66 @@ tracks = [
|
||||
("variant_float_inlining_SoA_AVX2_polyexp_rsqrt_loopopt",
|
||||
"AVX-256 + PolyExp + RSQRT (float)", "#d05a82", "--"),
|
||||
("variant_float_inlining_SoA_AVX512_polyexp_moreavx_ilp_2_rsqrt_morersqrt",
|
||||
"AVX-512 + PolyExp + RSQRT + ILP (float)", maroon, "-"),
|
||||
"AVX-512 + PolyExp + RSQRT + ILP-Inner (float)", maroon, "-"),
|
||||
("variant_float_inlining_SoA_AVX512_polyexp_moreavx_ilp_2_rsqrt_morersqrt_improved_moreilp",
|
||||
"AVX-512 + PolyExp + RSQRT + ILP-Outer (float)", crimson, "-"),
|
||||
]
|
||||
|
||||
tick_vals = np.array([50, 100, 200, 500, 1000, 2000, 5000, 10000])
|
||||
target_positions = np.arange(len(tick_vals))
|
||||
|
||||
|
||||
def map_x_to_linear(x_val):
|
||||
return np.interp(x_val, tick_vals, target_positions)
|
||||
|
||||
|
||||
fig, ax = plt.subplots(figsize=(9, 4.7))
|
||||
ends = []
|
||||
|
||||
for v, lab, c, ls in tracks:
|
||||
x_raw, y = getline(v)
|
||||
x_mapped = map_x_to_linear(x_raw)
|
||||
x, y = getline(v)
|
||||
ax.plot(
|
||||
x,
|
||||
y, # pyright: ignore[reportArgumentType]
|
||||
ls,
|
||||
color=c,
|
||||
marker="o",
|
||||
ms=4,
|
||||
lw=2.4 if c == maroon else 1.8)
|
||||
if c == maroon:
|
||||
side = "below"
|
||||
xpos = 5600
|
||||
else:
|
||||
side = "above"
|
||||
xpos = None
|
||||
ends.append((x, y, lab, c, xpos, side))
|
||||
|
||||
ax.plot(x_mapped,
|
||||
y,
|
||||
ls,
|
||||
color=c,
|
||||
marker="o",
|
||||
ms=4,
|
||||
lw=2.4 if c == maroon else 1.8)
|
||||
|
||||
ends.append((x_mapped, y, lab, c))
|
||||
|
||||
tick_vals = [50, 100, 200, 500, 1000, 2000, 5000, 10000]
|
||||
target_positions = list(range(len(tick_vals)))
|
||||
|
||||
start_x_pos = 0
|
||||
|
||||
for yv, t in [(PEAK_D, f"Peak π par. w/ doubles ({PEAK_D} flops/cycle)"),
|
||||
(PEAK_F, f"Peak π par. w/ floats ({PEAK_F} flops/cycle)")]:
|
||||
for yv, t in [
|
||||
(27.43, f"Peak π based on instruction mix [{27.43} flops/cycle]"),
|
||||
# (PEAK_D, f"Peak π par. w/ doubles ({PEAK_D} flops/cycle)"),
|
||||
# (PEAK_F, f"Peak π par. w/ floats ({PEAK_F} flops/cycle)")
|
||||
]:
|
||||
ax.axhline(yv, ls=":", color="#999", lw=1.2)
|
||||
ax.text(start_x_pos + 0.2,
|
||||
yv * 1.03,
|
||||
t,
|
||||
fontsize=9,
|
||||
color="#888",
|
||||
fontweight="bold")
|
||||
ax.text(52, yv * 1.03, t, fontsize=9, color="#888", fontweight="bold")
|
||||
|
||||
ax.set_yscale("log", base=2)
|
||||
|
||||
ax.set_xticks(target_positions)
|
||||
ax.set_xticklabels(["50", "100", "200", "500", "1k", "2k", "5k", "10k"],
|
||||
fontweight="bold",
|
||||
fontsize=9)
|
||||
|
||||
ax.set_xlim(-0.5, len(tick_vals) - 0.5)
|
||||
|
||||
ax.yaxis.set_major_formatter(ticker.FuncFormatter(lambda x, _: str(int(x))))
|
||||
ax.set_xscale("log", base=10)
|
||||
ax.set_xticks([50, 100, 200, 500, 1000, 2000, 5000, 10000])
|
||||
ax.set_xticklabels(["50", "100", "200", "500", "1K", "2K", "5K", "10K"])
|
||||
ax.set_xlim(46, 13000)
|
||||
ax.set_ylim(0, 30)
|
||||
for label in ax.get_yticklabels():
|
||||
label.set_fontweight('bold')
|
||||
label.set_fontsize(9)
|
||||
ax.set_ylim(1, 64)
|
||||
for label in ax.get_xticklabels():
|
||||
label.set_fontweight('bold')
|
||||
label.set_fontsize(9)
|
||||
ax.set_xlabel("Number of Pedestrians", fontweight="bold", fontsize=9)
|
||||
ax.grid(color="#e9e9e9")
|
||||
ax.spines["top"].set_visible(False)
|
||||
ax.spines["right"].set_visible(False)
|
||||
plt.title(
|
||||
'Performance [flops/cycle]\nCPU: AMD Ryzen AI 7 350 w/ Radeon 860M @ 2 GHz\nCompiler: g++ (Debian 15.2.0-17) 15.2.0\nFlags: -O3 -march=native -std=c++23 -Wall -Wextra -flto',
|
||||
'Performance (flops/cycle) [N = 3]\nCPU: AMD Ryzen AI 7 350 @ 2 GHz\nCompiler: g++ (Debian 15.2.0-17) 15.2.0\nFlags: -O3 -march=native -std=c++23 -Wall -Wextra -flto',
|
||||
loc='left',
|
||||
size=9,
|
||||
fontweight="bold")
|
||||
ax.grid(color="#e9e9e9")
|
||||
plt.tight_layout()
|
||||
|
||||
label_lines_above(ax, ends, fontsize=7.5, dy_frac=0.012)
|
||||
|
||||
label_lines_above(ax, ends, fontsize=7.25, dy_frac=0.012)
|
||||
plt.savefig("analysis/fig_tracks.svg", bbox_inches="tight")
|
||||
|
||||
# plot 2: all te milestones + the symmetry one that got slower
|
||||
# plot 2: all the milestones + the symmetry one that got slower
|
||||
bars = [
|
||||
("baseline", "variant_baseline"),
|
||||
("AVX2 (double)", "variant_inlining_7_SoA_AVX2"),
|
||||
@@ -219,7 +207,7 @@ ax.grid(axis="y", visible=False)
|
||||
ax.spines["top"].set_visible(False)
|
||||
ax.spines["right"].set_visible(False)
|
||||
plt.tight_layout()
|
||||
plt.savefig("analysis/fig_ladder.png", dpi=170, bbox_inches="tight")
|
||||
plt.savefig("analysis/fig_ladder.svg", bbox_inches="tight")
|
||||
|
||||
|
||||
# plot 3: roofline (n = 5000). same 7 variants as fig_tracks, same colors, inline labels.
|
||||
@@ -318,7 +306,7 @@ ax.set_xticklabels(ax.get_xticklabels(), fontweight="bold")
|
||||
ax.set_yticklabels(ax.get_yticklabels(), fontweight="bold")
|
||||
# ax.set_ylabel("Performance [flops/cycle]", fontweight="bold", fontsize=9)
|
||||
plt.title(
|
||||
'Performance [flops/cycle]\nCPU: AMD Ryzen AI 7 350 w/ Radeon 860M @ 2 GHz\nCompiler: g++ (Debian 15.2.0-17) 15.2.0\nFlags: -O3 -march=native -std=c++23 -Wall -Wextra -flto',
|
||||
'Performance [flops/cycle]\nCPU: AMD Ryzen AI 7 350 @ 2 GHz\nCompiler: g++ (Debian 15.2.0-17) 15.2.0\nFlags: -O3 -march=native -std=c++23 -Wall -Wextra -flto',
|
||||
loc='left',
|
||||
size=9,
|
||||
fontweight="bold")
|
||||
@@ -344,7 +332,7 @@ ax.spines["top"].set_visible(False)
|
||||
ax.spines["right"].set_visible(False)
|
||||
ax.legend(frameon=False, fontsize=10)
|
||||
plt.tight_layout()
|
||||
plt.savefig("analysis/fig_exp.png", dpi=170, bbox_inches="tight")
|
||||
plt.savefig("analysis/fig_exp.svg", bbox_inches="tight")
|
||||
|
||||
# plot 5: the milestone ladder as lines (this is plot0 + line1, line2, ... for the doc).
|
||||
# one line per relevant optimization step across n, baseline at the bottom.
|
||||
@@ -399,7 +387,7 @@ ax.spines["top"].set_visible(False)
|
||||
ax.spines["right"].set_visible(False)
|
||||
plt.tight_layout()
|
||||
label_lines_above(ax, ends, fontsize=6.5, dy_frac=0.02, halo=0)
|
||||
plt.savefig("analysis/fig_milestones.png", dpi=170, bbox_inches="tight")
|
||||
plt.savefig("analysis/fig_milestones.svg", bbox_inches="tight")
|
||||
|
||||
#plt.show()
|
||||
|
||||
@@ -449,7 +437,8 @@ ax.set_xscale("log")
|
||||
ax.set_yscale("log")
|
||||
|
||||
ax.set_xticks([50, 100, 200, 500, 1000, 2000, 5000])
|
||||
ax.set_xticklabels(["50", "100", "200", "500", "1k", "2k", "5k"], fontweight="bold")
|
||||
ax.set_xticklabels(["50", "100", "200", "500", "1k", "2k", "5k"],
|
||||
fontweight="bold")
|
||||
|
||||
ax.set_yticks([1, 2, 5, 10, 20])
|
||||
ax.set_yticklabels(["1x", "2x", "5x", "10x", "20x"], fontweight="bold")
|
||||
@@ -462,7 +451,7 @@ ax.set_ylim(0.8, 28)
|
||||
ax.set_xlabel("Number of Pedestrians", fontweight="bold", fontsize=9)
|
||||
# ax.set_ylabel("Speedup", fontweight="bold", fontsize=9)
|
||||
plt.title(
|
||||
'Runtime Speedup\nCPU: AMD Ryzen AI 7 350 w/ Radeon 860M @ 2 GHz\nCompiler: g++ (Debian 15.2.0-17) 15.2.0\nFlags: -O3 -march=native -std=c++23 -Wall -Wextra -flto',
|
||||
'Runtime Speedup\nCPU: AMD Ryzen AI 7 350 @ 2 GHz\nCompiler: g++ (Debian 15.2.0-17) 15.2.0\nFlags: -O3 -march=native -std=c++23 -Wall -Wextra -flto',
|
||||
loc='left',
|
||||
size=9,
|
||||
fontweight="bold")
|
||||
|
||||
Reference in New Issue
Block a user