5
import matplotlib.pyplot as plt
9
#colors=['green', 'red']
10
#colors=['#05500a', '#ff676c']
11
colors=['#05500a', 'lightyellow']
13
#colors2=['black', '#011268', '#15601a', '#ff676c', 'lightyellow']
14
#colors2=['#303030', '#2b83ba', 'limegreen', '#fdd5a5', '#d3ffd5', 'lightyellow']
15
colors2=['#303030', '#2b83ba', 'limegreen', 'red', 'lightyellow', '#d3ffd5']
18
titles = np.genfromtxt('../bench/gpu.txt', dtype = 'S32', delimiter=",", usecols = [0])
19
specs = np.genfromtxt('../bench/specs.txt', names = True, usecols = range(1,10))
20
# Convert structured numpy array to standard ndarray
21
specs = specs.view(np.float).reshape(specs.shape + (-1,))
23
data = np.genfromtxt('../bench/tex.txt', names = True, usecols = range(1,10))
24
# Convert structured numpy array to standard ndarray
25
data = data.view(np.float).reshape(data.shape + (-1,))
27
tex_gups = np.vectorize(lambda v: ops / v / 1000 / 1000 if v > 0 else 0.)(data)
29
data = np.genfromtxt('../bench/alu.txt', names = True, usecols = range(1,10))
30
# Convert structured numpy array to standard ndarray
31
alu_gups = data.view(np.float).reshape(data.shape + (-1,))
34
std = np.round(tex_gups[0])
35
tex_f1 = np.amax(tex_gups[0:12:4], axis=0)
36
tex_f2 = np.amax(tex_gups[1:12:4], axis=0)
37
tex_f4 = np.amax(tex_gups[2:12:4], axis=0)
38
tex_h4 = np.amax(tex_gups[3:12:4], axis=0)
44
# Compute maximum for precise and approximate modes
45
plin_tex = np.amax([tex_f1, tex_f2], axis=0)
47
pnn_tex = np.amax([plin_tex, tex_f4], axis=0)
48
ann_tex = np.amax([pnn_tex, tex_h4], axis=0)
51
lin_f1 = np.amax(alu_gups[0:8:4], axis=0)
52
lin_f2 = np.amax(alu_gups[1:8:4], axis=0)
53
lin_f4 = np.amax(alu_gups[2:8:4], axis=0)
54
lin_h4 = np.amax(alu_gups[3:8:4], axis=0)
57
alu_fx = np.amax(alu_gups[0:3], axis=0)
58
alu_xx = np.amax(alu_gups[0:4], axis=0)
59
hyb_fx = np.amax(alu_gups[4:7], axis=0)
60
hyb_xx = np.amax(alu_gups[4:8], axis=0)
64
ovs_xx = np.amax(alu_gups[8:12], axis=0)
66
nn_fx = np.amax(alu_gups[12:15], axis=0)
67
#nn_hx = np.amax(alu_gups[15], axis=0)
70
# Compute maximum for precise and approximate modes
71
plin = np.amax([lin_f1, lin_f2, lin_f4, plin_tex], axis=0)
72
alin = np.amax([plin, lin_h4, ovs_xx, alin_tex], axis=0)
73
pnn = np.amax([nn_fx, pnn_tex], axis=0)
74
ann = np.amax([pnn, nn_hx, ann_tex], axis=0)
77
plin_slice = np.amax([tex_f1, lin_f1], axis=0)
78
alin_slice = np.amax([plin_slice, ovs_f1], axis=0)
79
pnn_slice = np.amax([tex_f1, nn_f1], axis=0)
84
#def speedup(x): return (x - std) / std
85
def speedup(x): return x / std
92
idx = np.fliplr([idx])[0]
100
mult = 2 * bar_width + bar_gap + group_gap;
102
fig, (p) = plt.subplots(1, 1)
104
#p_atex = p.barh(mult * idx + 2 * (bar_width + bar_gap), speedup(atex), bar_width, color=colors[1], edgecolor='black')
105
#p_ptex = p.barh(mult * idx + 2 * (bar_width + bar_gap), speedup(ptex), bar_width, color=colors[0], edgecolor='black')
108
p_alin = p.barh(mult * idx + bar_width + bar_gap, speedup(alin), bar_width, hatch="", color=colors2[4], edgecolor='black')
109
p_plin = p.barh(mult * idx + bar_width + bar_gap, speedup(plin), bar_width, hatch="", color=colors2[3], edgecolor='black')
110
p_plin_alu = p.barh(mult * idx + bar_width + bar_gap, speedup(alu_fx), bar_width, hatch="", color=colors2[2], edgecolor='black')
111
p_plin_tex = p.barh(mult * idx + bar_width + bar_gap, speedup(plin_tex), bar_width, hatch="", color=colors2[1], edgecolor='black')
112
p_plin_simple = p.barh(mult * idx + bar_width + bar_gap, speedup(lin_simple), bar_width, hatch="", color=colors2[0], edgecolor='black')
113
p_plin_white = p.barh(mult * idx + bar_width + bar_gap, speedup(std), bar_width, hatch="", color="white", edgecolor='black')
114
p_plin_col5 = p.barh(mult * idx + bar_width + bar_gap, speedup(std), bar_width, hatch="", color=colors2[5], edgecolor='black')
117
p_ann = p.barh(mult * idx, speedup(ann), bar_width, hatch='\\\\', color=colors2[5], edgecolor='black')
118
p_pnn = p.barh(mult * idx, speedup(pnn), bar_width, hatch='\\\\', color=colors2[3], edgecolor='black')
119
p_pnn_alu = p.barh(mult * idx, speedup(nn_fx), bar_width, hatch='\\\\', color=colors2[2], edgecolor='black')
120
p_pnn_tex = p.barh(mult * idx, speedup(pnn_tex), bar_width, hatch='\\\\', color=colors2[1], edgecolor='black')
121
p_pnn_simple = p.barh(mult * idx, speedup(nn_simple), bar_width, hatch='\\\\', color=colors2[0], edgecolor='black')
122
p_pnn_white = p.barh(mult * idx, speedup(std), bar_width, hatch='\\\\', color="white", edgecolor='black')
125
ax.xaxis.grid(alpha=0.25)
126
plt.xticks(np.arange(1,8.1,0.5))
127
plt.yticks(mult * (idx - 0.17) + bar_width + bar_gap/2, titles)
129
plt.xlabel("speedup (times)")
131
plt.ylim(0, 9*mult)# - group_gap)
134
(p_plin_white[0], p_pnn_white[0]),
135
("Linear", "Nearest"),
136
loc='right lower', bbox_to_anchor=(1.24,0.5), ncol=1)
139
(p_plin_simple[0], p_plin_tex[0], p_plin_alu[0], p_plin[0], p_alin[0], p_plin_col5),
140
("Re-mapped", "Multi-slice", "ALU-based", "Hybrid", "Oversampling", "Half-Precision"),
141
loc='right upper', bbox_to_anchor=(1.32,1.02), ncol=1)
144
# (p_plin_simple[0], p_pnn_simple[0], p_plin_tex[0], p_pnn_tex[0], p_plin_alu[0], p_pnn_alu[0], p_plin[0], p_pnn[0], p_alin[0], p_ann[0]),
145
# ("Single", "Single",
146
# "Multi-slice", "Multi-slice",
147
# "ALU-based", "ALU-based",
148
# "Hybrid", "Hybrid",
149
# "Oversampling", "Half-precision"),
150
# loc='upper center', bbox_to_anchor=(0.5,-0.3), ncol=3)
152
plt.gca().add_artist(legend2)
156
plt.savefig('speedup.png', dpi=300, bbox_inches='tight', bbox_extra_artists=(legend,))