Skip to content

Commit d8c4e11

Browse files
committed
Add annotations in mem plot
1 parent 69816ab commit d8c4e11

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

bench/ndarray/roofline-mem-speed-plot.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,54 @@ def extract_xy(mem_dict):
108108
va="top",
109109
)
110110

111+
# --- single workload label per workload name (avoid duplicates) ---
112+
# Build a map: workload name -> list of (intensity, gflops) across mem_4800/mem_6000
113+
workload_map: dict[str, dict[str, list[float]]] = {}
114+
115+
for workload, metrics in mem_4800.items():
116+
intensity = metrics["Intensity"]
117+
gflops = metrics["GFLOPS"]
118+
if workload not in workload_map:
119+
workload_map[workload] = {"intensity": [], "gflops": []}
120+
workload_map[workload]["intensity"].append(intensity)
121+
workload_map[workload]["gflops"].append(gflops)
122+
123+
for workload, metrics in mem_6000.items():
124+
intensity = metrics["Intensity"]
125+
gflops = metrics["GFLOPS"]
126+
if workload not in workload_map:
127+
workload_map[workload] = {"intensity": [], "gflops": []}
128+
workload_map[workload]["intensity"].append(intensity)
129+
workload_map[workload]["gflops"].append(gflops)
130+
131+
# Place a single label per workload at the average intensity and slightly below
132+
# the minimum GFLOPS across both memory speeds for that workload.
133+
for workload, vals in workload_map.items():
134+
intensities = vals["intensity"]
135+
gflops_list = vals["gflops"]
136+
x_label = sum(intensities) / len(intensities)
137+
y_min = min(gflops_list)
138+
raw_ypos = y_min * 0.6
139+
140+
ymin_curr, _ = ax.get_ylim()
141+
safe_ypos = max(raw_ypos, ymin_curr * 1.5 if ymin_curr > 0 else raw_ypos)
142+
143+
# Avoid overlap between matmul1 and matmul2 by using different vertical offsets
144+
if workload == "matmul1":
145+
safe_ypos *= .8 # push matmul1 a bit higher
146+
elif workload == "matmul2":
147+
safe_ypos *= 1.2 # keep matmul2 lower
148+
149+
ax.annotate(
150+
workload,
151+
(x_label, safe_ypos),
152+
ha="center",
153+
va="top",
154+
fontsize=10,
155+
alpha=0.9,
156+
)
157+
# --------------------------------------------------------------
158+
111159
ax.set_xlabel("Arithmetic Intensity (FLOPs/element)")
112160
ax.set_ylabel("Performance (GFLOPS/sec)")
113161
ax.set_title("Memory speed impact on NumPy/NumExpr performance\nAMD 7800X3D (in-memory)")

bench/ndarray/roofline-plot.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
# User selection
1717
# ---------------------------------------------------------------------
1818
# Valid machines: "Apple-M4-Pro", "AMD-7800X3D"
19+
# machine = "Apple-M4-Pro"
1920
machine = "AMD-7800X3D"
2021
# False -> on-disk benchmark, True -> in-memory benchmark
2122
mem_mode = False

0 commit comments

Comments
 (0)