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']
17
titles = np.genfromtxt('../bench/gpu.txt', dtype = 'S32', delimiter=",", usecols = [0])
18
specs = np.genfromtxt('../bench/specs.txt', names = True, usecols = range(1,10))
19
# Convert structured numpy array to standard ndarray
20
specs = specs.view(np.float).reshape(specs.shape + (-1,))
22
data = np.genfromtxt('../bench/tex.txt', names = True, usecols = range(1,10))
23
# Convert structured numpy array to standard ndarray
24
data = data.view(np.float).reshape(data.shape + (-1,))
26
tex_gups = np.vectorize(lambda v: ops / v / 1000 / 1000 if v > 0 else 0.)(data)
28
data = np.genfromtxt('../bench/alu.txt', names = True, usecols = range(1,10))
29
# Convert structured numpy array to standard ndarray
30
alu_gups = data.view(np.float).reshape(data.shape + (-1,))
33
std = np.round(tex_gups[0])
34
tex_f1 = np.amax(tex_gups[0:12:4], axis=0)
35
tex_f2 = np.amax(tex_gups[1:12:4], axis=0)
36
tex_f4 = np.amax(tex_gups[2:12:4], axis=0)
37
tex_h4 = np.amax(tex_gups[3:12:4], axis=0)
43
# Compute maximum for precise and approximate modes
44
plin_tex = np.amax([tex_f1, tex_f2], axis=0)
46
pnn_tex = np.amax([plin_tex, tex_f4], axis=0)
47
ann_tex = np.amax([pnn_tex, tex_h4], axis=0)
50
lin_f1 = np.amax(alu_gups[0:8:4], axis=0)
51
lin_f2 = np.amax(alu_gups[1:8:4], axis=0)
52
lin_f4 = np.amax(alu_gups[2:8:4], axis=0)
53
lin_h4 = np.amax(alu_gups[3:8:4], axis=0)
56
alu_fx = np.amax(alu_gups[0:3], axis=0)
57
alu_xx = np.amax(alu_gups[0:4], axis=0)
58
hyb_fx = np.amax(alu_gups[4:7], axis=0)
59
hyb_xx = np.amax(alu_gups[4:8], axis=0)
63
ovs_xx = np.amax(alu_gups[8:12], axis=0)
65
nn_fx = np.amax(alu_gups[12:15], axis=0)
66
#nn_hx = np.amax(alu_gups[15], axis=0)
69
# Compute maximum for precise and approximate modes
70
plin = np.amax([lin_f1, lin_f2, lin_f4, plin_tex], axis=0)
71
alin = np.amax([plin, lin_h4, ovs_xx, alin_tex], axis=0)
72
pnn = np.amax([nn_fx, pnn_tex], axis=0)
73
ann = np.amax([pnn, nn_hx, ann_tex], axis=0)
76
plin_slice = np.amax([tex_f1, lin_f1], axis=0)
77
alin_slice = np.amax([plin_slice, ovs_f1], axis=0)
78
pnn_slice = np.amax([tex_f1, nn_f1], axis=0)
83
#def speedup(x): return (x - std) / std
84
def speedup(x): return x / std
91
idx = np.fliplr([idx])[0]
99
mult = (bar_width + bar_gap) + group_gap;
101
fig, (p) = plt.subplots(1, 1)
103
#p_atex = p.barh(mult * idx + 2 * (bar_width + bar_gap), speedup(atex), bar_width, color=colors[1], edgecolor='black')
104
#p_ptex = p.barh(mult * idx + 2 * (bar_width + bar_gap), speedup(ptex), bar_width, color=colors[0], edgecolor='black')
106
#p_ann = p.barh(mult * idx, speedup(ann), bar_width, hatch='\\\\', color=colors2[5], edgecolor='black')
107
p_pnn = p.barh(mult * (idx + 0.35), speedup(pnn), bar_width, color=colors2[2], edgecolor='black')
109
#p_alin = p.barh(mult * idx + bar_width + bar_gap, speedup(alin), bar_width, hatch="", color=colors2[4], edgecolor='black')
110
p_plin = p.barh(mult * (idx + 0.35), speedup(plin), bar_width, hatch="", color=colors2[1], edgecolor='black')
113
ax.xaxis.grid(alpha=0.25)
114
plt.xticks(np.arange(1,8.1,0.5))
115
plt.yticks(mult * idx + (bar_width + bar_gap)/2, titles)
117
plt.xlabel("speedup (times)")
119
plt.ylim(0, 9*mult - group_gap)
123
(p_plin[0], p_pnn[0]),
124
("Linear", "Nearest-Neighbor"),
126
#, bbox_to_anchor=(0.5,-0.2), ncol=3)
128
#plt.gca().add_artist(legend2)
131
plt.savefig('algorithms.png', dpi=300, bbox_inches='tight', bbox_extra_artists=(legend,))
136
fig, (p) = plt.subplots(1, 1)
138
#p_atex = p.barh(mult * idx + 2 * (bar_width + bar_gap), speedup(atex), bar_width, color=colors[1], edgecolor='black')
139
#p_ptex = p.barh(mult * idx + 2 * (bar_width + bar_gap), speedup(ptex), bar_width, color=colors[0], edgecolor='black')
141
p_alin = p.barh(mult * idx + bar_width + bar_gap, speedup(alin), bar_width, hatch="", color=colors[1], edgecolor='black')
142
p_plin = p.barh(mult * idx + bar_width + bar_gap, speedup(plin), bar_width, hatch="", color=colors[0], edgecolor='black')
144
p_ann = p.barh(mult * idx, speedup(ann), bar_width, hatch='\\\\', color=colors[1], edgecolor='black')
145
p_pnn = p.barh(mult * idx, speedup(pnn), bar_width, hatch='\\\\', color=colors[0], edgecolor='black')
148
ax.xaxis.grid(alpha=0.25)
149
plt.xticks(np.arange(1,8.1,0.5))
150
plt.yticks(mult * idx + 2 * (bar_width + bar_gap)/2, titles)
152
plt.xlabel("speedup (times)")
154
plt.ylim(0, 9*mult - group_gap)
157
(p_plin[0], p_pnn[0], p_alin[0], p_ann[0]),
158
("Linear", "Nearest",
159
"Linear & Oversampling / Half-float", "Nearest / Half-float"),
160
loc='upper center', bbox_to_anchor=(0.5,-0.1), ncol=2)
162
plt.savefig('speedup.pdf', dpi=300, bbox_inches='tight', bbox_extra_artists=(legend,))
166
fig, (p) = plt.subplots(1, 1)
168
p_alin = p.barh(mult * idx + bar_width + bar_gap, speedup(alin_tex), bar_width, hatch="", color=colors[1], edgecolor='black')
169
p_plin = p.barh(mult * idx + bar_width + bar_gap, speedup(plin_tex), bar_width, hatch="", color=colors[0], edgecolor='black')
171
p_ann = p.barh(mult * idx, speedup(ann_tex), bar_width, hatch='\\\\', color=colors[1], edgecolor='black')
172
p_pnn = p.barh(mult * idx, speedup(pnn_tex), bar_width, hatch='\\\\', color=colors[0], edgecolor='black')
175
ax.xaxis.grid(alpha=0.25)
176
plt.xticks(np.arange(1,8.1,0.5))
177
plt.yticks(mult * idx + 2 * (bar_width + bar_gap)/2, titles)
179
plt.xlabel("speedup (times)")
181
plt.ylim(0, 9*mult - group_gap)
184
(p_plin[0], p_pnn[0], p_alin[0], p_ann[0]),
185
("Linear", "Nearest",
186
"Linear / Half-float", "Nearest / Half-float"),
187
loc='upper center', bbox_to_anchor=(0.5,-0.1), ncol=2)
189
plt.savefig('speedup_tex.pdf', dpi=300, bbox_inches='tight', bbox_extra_artists=(legend,))
193
fig, (p) = plt.subplots(1, 1)
195
p_alin = p.barh(mult * idx + bar_width + bar_gap, speedup(alin_slice), bar_width, hatch="", color=colors[1], edgecolor='black')
196
p_plin = p.barh(mult * idx + bar_width + bar_gap, speedup(plin_slice), bar_width, hatch="", color=colors[0], edgecolor='black')
198
#p_ann = p.barh(mult * idx, speedup(ann_slice), bar_width, hatch='\\\\', color=colors[1], edgecolor='black')
199
p_pnn = p.barh(mult * idx, speedup(pnn_slice), bar_width, hatch='\\\\', color=colors[0], edgecolor='black')
202
ax.xaxis.grid(alpha=0.25)
203
plt.xticks(np.arange(1,8.1,0.5))
204
plt.yticks(mult * idx + 2 * (bar_width + bar_gap)/2, titles)
206
plt.xlabel("speedup (times)")
208
plt.ylim(0, 9*mult - group_gap)
211
(p_plin[0], p_pnn[0], p_alin[0], p_ann[0]),
212
("Linear", "Nearest",
214
loc='upper center', bbox_to_anchor=(0.5,-0.1), ncol=2)
216
plt.savefig('speedup_slice.pdf', dpi=300, bbox_inches='tight', bbox_extra_artists=(legend,))