-
Notifications
You must be signed in to change notification settings - Fork 0
/
benchpredict.py
executable file
·89 lines (73 loc) · 2.51 KB
/
benchpredict.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/bin/python
from kernel import Kernel
from predict import *
from benchmark import *
import numpy as np
import pycuda.driver as drv
import pycuda
import sys
from subprocess import run, PIPE
import matplotlib
matplotlib.use("SVG")
import matplotlib.pyplot as plt
#for MN in range(64, 65):
# for TM in range(1, 17):
# for TN in range(1, 17):
# if MN % TM != 0 or MN % TN != 0:
# continue
# print( str(MN) + " " + str(TM) + " " + str(TN) + ": ", end="")
kernels = []
memPreds0 = []
memPreds1 = []
L1Preds = []
ALUPreds = []
UniPreds = []
flopses = []
for MN in [1, 2, 4, 8, 16, 32, 64]:
for TM in range(1, 33):
for TN in range(1, 33):
if MN % TN != 0 or MN % TM != 0:
continue
if TM*TN > 100:
continue
kernels.append(Kernel(MN, MN, TM, TN, 256, reduction="none"))
for kernel in kernels:
memPred = predictMemory(kernel)
memPreds0.append(memPred[0])
memPreds1.append(memPred[1])
L1Pred = predictL1(kernel)
L1Preds.append(L1Pred)
ALUPred = predictALU(kernel)
ALUPreds.append(ALUPred)
UniPred = predictUniform(kernel)
UniPreds.append(UniPred)
print(kernel.name)
print("Mem lat: {:7.0f}".format(memPred[0]))
print("Mem thru: {:7.0f}".format(memPred[1]))
print("L1: {:7.0f}".format(L1Pred))
print("ALU: {:7.0f}".format(ALUPred))
print("Uni: {:7.0f}".format(UniPred))
flops = benchKernel(kernel, maxBufferElements // (kernel.M + kernel.N))
flopses.append(flops)
print()
fig, ax = plt.subplots()
fig.set_figwidth(16)
fig.set_figheight(8)
plt.ioff()
#ax.bar(np.arange(0, len(kernels)) - 0.225, memPreds0, width=0.15)
#ax.bar(np.arange(0, len(kernels)) - 0.075, memPreds1, width=0.15)
#ax.bar(np.arange(0, len(kernels)) + 0.075, L1Preds, width=0.15)
#ax.bar(np.arange(0, len(kernels)) + 0.225, ALUPreds, width=0.15)
ax.bar(np.arange(0, len(kernels)) + 0, UniPreds, width=0.35)
#ax.hlines([min(z) for z in zip(memPreds0, memPreds1, L1Preds, ALUPreds)],
# np.arange(0, len(kernels)) + -0.3,
# np.arange(0, len(kernels)) + 0.425)
ax.plot(np.arange(0, len(kernels)), flopses, "X", color="black")
ax.set_ylim((0, 8000))
ax.set_xlim((-1, len(kernels)))
ax.set_xticks(np.arange(0, len(kernels)))
ax.set_xticklabels([kernel.name for kernel in kernels],
rotation=45,
ha="right",
rotation_mode="anchor")
plt.savefig("perf.png", dpi=300, pad_inches=0.0, bbox_inches="tight")