-
Notifications
You must be signed in to change notification settings - Fork 2
/
top_configurations.py
72 lines (53 loc) · 2.21 KB
/
top_configurations.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/env python
import json
import sys
import os
kernels = ["dedisp", "hotspot", "convolution", "gemm"]
devices = ["W6600", "MI250X", "A4000", "A100"]
path = path = os.path.dirname(os.path.realpath(__file__)) + "/cache_files/"
def print_top_configs(kernel_name):
for dev in devices:
filename = path + kernel_name + "_" + dev + ".json"
print(r"\begin{minipage}{0.249\columnwidth}\scriptsize\centering")
print(dev + r" \\")
with open(filename) as f:
data = json.load(f)
tune_param_keys = data["tune_params_keys"]
tune_params = data["tune_params"]
objective = data["objective"]
#print(filename)
#print("keys:")
for key in list(tune_param_keys):
if len(tune_params[key]) > 1:
pass
#print(f" - {key}: {tune_params[key]}")
else:
tune_param_keys.remove(key)
num_cols = len(tune_param_keys)+1
col_str = 'r' * (len(tune_param_keys)+1)
print(r"""\begin{tabular}{""" + col_str + """}
\midrule""")
#filter out invalid configs
records = [record for record in list(data["cache"].values()) if isinstance(record[objective], float)]
# prefer GFLOP/s or GB/s as objective over time
if "GFLOP/s" in records[0]:
objective = "GFLOP/s"
if "GB/s" in records[0]:
objective = "GB/s"
#sort on objective
#print(f"sort on {objective}")
records.sort(key=lambda p : p[objective], reverse=True)
for i in range(5):
#print(records[i][objective], best, best/records[i][objective])
records[i]["best"] = "{:.2f}".format(records[i][objective])
for record in records[:5]:
print(" & ".join(str(record[key]) for key in tune_param_keys+["best"]) + f" \\\\ % \t time: {record['time']} \t {objective}: {record[objective]}")
print(r"""\midrule
\end{tabular} \\
\end{minipage}%""")
if __name__ == "__main__":
if len(sys.argv) > 1 and sys.argv[1] in kernels:
print_top_configs(sys.argv[1])
else:
print("Usage: python top_configurations.py [kernel_name]")
print(" kernel_name options:", ", ".join(kernels))