Skip to content

Commit 379de74

Browse files
RUNS
1 parent 9dc58a6 commit 379de74

File tree

4 files changed

+512
-614
lines changed

4 files changed

+512
-614
lines changed

benchmarks/analyze_benchmarks.py

Lines changed: 13 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -2,93 +2,25 @@
22
import matplotlib.pyplot as plt
33
import sys
44

5-
def plot_absolute_latency(df):
6-
import matplotlib.pyplot as plt
7-
pivot = df.pivot_table(index="variant", columns="size", values="metal_ms", aggfunc="min")
8-
pivot.T.plot(marker='o', figsize=(12,6))
9-
plt.title("Absolute Metal Latency (ms) by Variant and Matrix Size")
10-
plt.ylabel("Latency (ms)")
11-
plt.xlabel("Matrix Size")
12-
plt.grid(True, axis='y')
13-
plt.tight_layout()
14-
plt.savefig("gemm_absolute_latency.png")
15-
plt.show()
16-
17-
def plot_speedup_heatmap(df):
18-
import matplotlib.pyplot as plt
19-
import seaborn as sns
20-
pivot = df.pivot_table(index="variant", columns="size", values="speedup_vs_cpu", aggfunc="max")
21-
plt.figure(figsize=(10,7))
22-
sns.heatmap(pivot, annot=True, fmt=".1f", cmap="YlGnBu")
23-
plt.title("Speedup Heatmap: Metal vs. CPU")
24-
plt.ylabel("Variant")
25-
plt.xlabel("Matrix Size")
26-
plt.tight_layout()
27-
plt.savefig("gemm_speedup_heatmap.png")
28-
plt.show()
29-
30-
def plot_batch_scaling(df):
31-
import matplotlib.pyplot as plt
32-
if "batch" in df.columns:
33-
for variant in df["variant"].unique():
34-
df_v = df[df["variant"]==variant]
35-
if not df_v.empty:
36-
plt.plot(df_v["batch"], df_v["metal_ms"], marker='o', label=variant)
37-
plt.title("Batch Size Scaling (Metal)")
38-
plt.xlabel("Batch Size")
39-
plt.ylabel("Metal Latency (ms)")
40-
plt.legend()
41-
plt.grid(True, axis='y')
42-
plt.tight_layout()
43-
plt.savefig("gemm_batch_scaling.png")
44-
plt.show()
45-
46-
def plot_hybrid_breakdown(df):
47-
import matplotlib.pyplot as plt
48-
# Only plot if hybrid results exist
49-
if "hybrid" in df["variant"].str.lower().values:
50-
df_hybrid = df[df["variant"].str.lower().str.contains("hybrid")]
51-
if not df_hybrid.empty:
52-
for idx, row in df_hybrid.iterrows():
53-
labels = []
54-
values = []
55-
for col in ["cpu_ms", "metal_ms", "ane_ms"]:
56-
if col in row and not pd.isnull(row[col]):
57-
labels.append(col)
58-
values.append(row[col])
59-
plt.figure()
60-
plt.bar(labels, values)
61-
plt.title(f"Hybrid Breakdown (size={row['size']})")
62-
plt.ylabel("Latency (ms)")
63-
plt.tight_layout()
64-
plt.savefig(f"gemm_hybrid_breakdown_{row['size']}.png")
65-
plt.show()
66-
675
def main():
686
csv_file = sys.argv[1] if len(sys.argv) > 1 else "benchmarks_ops.csv"
697
df = pd.read_csv(csv_file)
70-
# Only keep relevant columns that might exist
71-
keep_cols = [col for col in ["variant", "size", "cpu_ms", "metal_ms", "ane_ms", "batch", "speedup"] if col in df.columns]
8+
# Only keep relevant columns
9+
keep_cols = ["variant", "size", "cpu_ms", "metal_ms", "speedup"]
7210
df = df[keep_cols]
7311
# Compute speedup for each row (if both cpu_ms and metal_ms are available)
74-
if "cpu_ms" in df.columns and "metal_ms" in df.columns:
75-
df = df.dropna(subset=["cpu_ms", "metal_ms"])
76-
df["speedup_vs_cpu"] = df["cpu_ms"] / df["metal_ms"]
12+
df = df.dropna(subset=["cpu_ms", "metal_ms"])
13+
df["speedup_vs_cpu"] = df["cpu_ms"] / df["metal_ms"]
7714
# Pivot for plotting: show speedup by variant and size
78-
if "speedup_vs_cpu" in df.columns:
79-
pivot = df.pivot_table(index="variant", columns="size", values="speedup_vs_cpu", aggfunc="max")
80-
pivot.plot(kind="bar", figsize=(12,6))
81-
plt.title("GEMM Speedup: Metal vs. CPU")
82-
plt.ylabel("Speedup (X)")
83-
plt.xlabel("Variant")
84-
plt.grid(True, axis='y')
85-
plt.tight_layout()
86-
plt.savefig("gemm_speedup_vs_cpu.png")
87-
plt.show()
88-
plot_speedup_heatmap(df)
89-
plot_absolute_latency(df)
90-
plot_batch_scaling(df)
91-
plot_hybrid_breakdown(df)
15+
pivot = df.pivot_table(index="variant", columns="size", values="speedup_vs_cpu", aggfunc="max")
16+
pivot.plot(kind="bar", figsize=(12,6))
17+
plt.title("GEMM Speedup: Metal vs. CPU")
18+
plt.ylabel("Speedup (X)")
19+
plt.xlabel("Variant")
20+
plt.grid(True, axis='y')
21+
plt.tight_layout()
22+
plt.savefig("gemm_speedup_vs_cpu.png")
23+
plt.show()
9224

9325
if __name__ == "__main__":
9426
main()

tests/metal/ops/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ target_link_libraries(gemm_multi_device_bench_test
1212
"-framework Metal"
1313
"-framework Foundation"
1414
"-framework MetalKit"
15-
"-framework Accelerate"
16-
"-framework MetalPerformanceShaders"
1715
)
1816

1917
add_executable(relu_multi_device_bench_test relu_multi_device_bench_test.mm)

0 commit comments

Comments
 (0)