-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathplot_pht_associativity.py
33 lines (29 loc) · 1.07 KB
/
plot_pht_associativity.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import subprocess
from matplotlib import pyplot as plt
import numpy as np
import csv
# Test branch toggles
for prefix in [""]:
x_data = []
y_data = []
z_data = []
with open(f"{prefix}pht_associativity.csv", newline="") as f:
r = csv.DictReader(f)
for row in r:
x_data.append(int(row["branches"]))
y_data.append(int(row["align"]))
z_data.append(min(float(row["min"]), 0.5))
z_data = np.array(z_data)
x_data = list(sorted(set(x_data)))
y_data = list(sorted(set(y_data)))
z_data = z_data.reshape((len(x_data), len(y_data)))
plt.imshow(z_data.transpose())
plt.xlabel("# Conditional branches")
plt.xticks(range(len(x_data)), x_data, rotation=90)
plt.ylabel("Log2 branch base address")
plt.yticks(range(len(y_data)), y_data)
bar = plt.colorbar(shrink=0.5)
bar.ax.set_ylabel("Misprediction rate", fontsize=8, rotation=270, labelpad=9.0)
plt.savefig(f"plot_{prefix}pht_associativity.png")
plt.savefig(f"plot_{prefix}pht_associativity.pdf", bbox_inches="tight")
plt.cla()