5
import matplotlib as mpl
6
import matplotlib.pyplot as plt
7
import matplotlib.ticker as ticker
8
import matplotlib.gridspec as gridspec
11
mpl.rcParams.update({'font.size': font})
16
#colors=['green', 'red']
17
#colors=['#05500a', '#ff676c']
18
#colors=['#05500a', 'lightyellow']
19
#colors=['#303030', '#2b83ba', 'limegreen', '#fdd5a5', '#d3ffd5', 'lightyellow']
20
#colors=['#303030', '#2b83ba', 'limegreen', '#fdd5a5', '#d3ffd5', 'lightyellow']
21
colors=['darkred', '#2b83ba', 'limegreen', '#fdd5a5', '#d3ffd5', 'lightyellow']
22
colors1=['darkgreen', 'darkred', '#fdd5a5', '#d3ffd5', 'lightyellow']
23
colors2=['limegreen', 'orange', '#d3ffd5', 'lightyellow']
28
titles = np.genfromtxt('../bench/gpu.txt', dtype = 'S32', delimiter=",", usecols = [0])
29
specs = np.genfromtxt('../bench/specs.txt', names = True, usecols = range(1,10))
30
# Convert structured numpy array to standard ndarray
31
specs = specs.view(np.float).reshape(specs.shape + (-1,))
38
data = np.genfromtxt('../bench/tex.txt', names = True, usecols = range(1,10))
39
# Convert structured numpy array to standard ndarray
40
data = data.view(np.float).reshape(data.shape + (-1,))
42
tex_gups = np.vectorize(lambda v: ops / v / 1000 / 1000 if v > 0 else 0.)(data)
44
data = np.genfromtxt('../bench/alu.txt', names = True, usecols = range(1,10))
45
# Convert structured numpy array to standard ndarray
46
alu_gups = data.view(np.float).reshape(data.shape + (-1,))
49
std = np.round(tex_gups[0])
50
tex_f1 = np.amax(tex_gups[0:12:4], axis=0)
51
tex_f2 = np.amax(tex_gups[1:12:4], axis=0)
52
tex_f4 = np.amax(tex_gups[2:12:4], axis=0)
53
tex_h4 = np.amax(tex_gups[3:12:4], axis=0)
59
# Compute maximum for precise and approximate modes
60
plin_tex = np.amax([tex_f1, tex_f2], axis=0)
62
pnn_tex = np.amax([plin_tex, tex_f4], axis=0)
63
ann_tex = np.amax([pnn_tex, tex_h4], axis=0)
66
lin_f1 = np.amax(alu_gups[0:8:4], axis=0)
67
lin_f2 = np.amax(alu_gups[1:8:4], axis=0)
68
lin_f4 = np.amax(alu_gups[2:8:4], axis=0)
69
lin_h4 = np.amax(alu_gups[3:8:4], axis=0)
72
alu_fx = np.amax(alu_gups[0:3], axis=0)
73
alu_xx = np.amax(alu_gups[0:4], axis=0)
74
hyb_fx = np.amax(alu_gups[4:7], axis=0)
75
hyb_xx = np.amax(alu_gups[4:8], axis=0)
79
ovs_xx = np.amax(alu_gups[8:12], axis=0)
81
nn_fx = np.amax(alu_gups[12:15], axis=0)
82
#nn_hx = np.amax(alu_gups[15], axis=0)
85
# Compute maximum for precise and approximate modes
86
plin = np.amax([lin_f1, lin_f2, lin_f4, plin_tex], axis=0)
87
alin = np.amax([plin, lin_h4, ovs_xx, alin_tex], axis=0)
88
pnn = np.amax([nn_fx, pnn_tex], axis=0)
89
ann = np.amax([pnn, nn_hx, ann_tex], axis=0)
92
plin_slice = np.amax([tex_f1, lin_f1], axis=0)
93
alin_slice = np.amax([plin_slice, ovs_f1], axis=0)
94
pnn_slice = np.amax([tex_f1, nn_f1], axis=0)
99
#def speedup(x): return (x - std) / std
100
def speedup(x): return x / std
107
idx = np.fliplr([idx])[0]
115
mult = 2 * (bar_width + bar_gap) + group_gap;
117
def get_change(x, r): return [x[n]/x[n-1] for n in r]
118
flops_change = get_change(flops, range(1,6))
119
texfl_change = get_change(texfl, range(1,6))
120
shmem_change = get_change(shmem, range(1,6))
121
tconv_change = get_change(tconv, range(1,6))
122
std_change = get_change(std, range(1,6))
123
plin_change = get_change(plin, range(1,6))
124
pnn_change = get_change(pnn, range(1,6))
132
def speedup0(x,y): return x / x[0]
135
fig = plt.figure(figsize=(10, 6))
136
gs = gridspec.GridSpec(1, 3, width_ratios=[3, 0, 3])
137
plots = [ plt.subplot(gs[0]), plt.subplot(gs[2]) ]
142
p.set_xticklabels(titles[0:6])
143
p.set_ylabel('speed-up relative to GTX295 (times)')
145
p_spec = p.plot(seq1, speedup0(flops[0:6], flops[0:6]), "-o", color=colors[0], markersize=3)
146
p_tex = p.plot(seq1, speedup0(texfl[0:6], texfl[0:6]), "-o", color=colors[1], markersize=3)
147
p_shm = p.plot(seq1, speedup0(shmem[0:6], shmem[0:6]), "-o", color=colors[2], markersize=3)
148
p_cnv = p.plot(seq1, speedup0(tconv[0:6], tconv[0:6]), "-o", color=colors[3], markersize=3)
150
fig.subplots_adjust(bottom=0.3)
151
legend = plt.figlegend(
152
(p_spec[0], p_tex[0], p_shm[0], p_cnv[0]),
153
("FP throughput (Peak)", "Texture throuhgput (Peak)", "Shared memory bandwidth (Peak)", "Throughput of type-conversions (Peak)",),
154
loc='lower center', bbox_to_anchor=(0.44,0.04), ncol=2)
159
#p.set_xticklabels(titles[6:9])
161
#p.set_ylabel('speed-up (times)')
162
#p_spec = p.plot(seq2, speedup0(flops[6:9], flops[6:9]), "-o", color=colors[0], markersize=3)
163
#p_std = p.plot(seq2, speedup0(std[6:9], flops[6:9]), "-o", color=colors[1], markersize=3)
164
#p_lin = p.plot(seq2, speedup0(plin[6:9], flops[6:9]), "-o", color=colors[2], markersize=3)
165
#p_nn = p.plot(seq2, speedup0(pnn[6:9], flops[6:9]), "-o", color=colors[3], markersize=3)
168
#p.set_xticklabels(titles[1:6])
170
#p_spec = p.plot(seq, flops_change, "-o", color=colors[0], markersize=3)
171
#p_std = p.plot(seq, std_change, "-o", color=colors[1], markersize=3)
172
#p_lin = p.plot(seq, plin_change, "-o", color=colors[2], markersize=3)
173
#p_nn = p.plot(seq, pnn_change, "-o", color=colors[3], markersize=3)
179
mult = 4 * (bar_width + bar_gap) + group_gap;
181
p.set_ylabel('speed-up & slow-down relative\nto previous architecture (times)')
183
p.set_xticks(0.45 * mult + mult * np.arange(5))
184
p.set_xticklabels(titles[1:6])
186
@ticker.FuncFormatter
187
def yformatter(x, pos):
188
return ("%.1f" % (x + 1)) if (x >= 0) else ("2/%u" % abs(2 * x - 2)) if (round(x) != x) else ("1/%u" % abs(x - 1))
191
p.yaxis.set_major_formatter(yformatter)
194
def speedup1(x): return (x - 1) if (x >=1) else (-1/x + 1)
198
p_tconv = p.bar(mult * idx + 3 * (bar_width + bar_gap), speedup1(tconv_change[idx]), bar_width, color=colors[3], edgecolor='black')
199
p_shmem = p.bar(mult * idx + 2 * (bar_width + bar_gap), speedup1(shmem_change[idx]), bar_width, color=colors[2], edgecolor='black')
200
p_texfl = p.bar(mult * idx + 1 * (bar_width + bar_gap), speedup1(texfl_change[idx]), bar_width, color=colors[1], edgecolor='black')
201
p_spec = p.bar(mult * idx + 0 * (bar_width + bar_gap), speedup1(flops_change[idx]), bar_width, color=colors[0], edgecolor='black')
205
va = [0, -.05, 0, -.05, 0, -.05, 0 ]
206
for t, y in zip( plots[0].get_xticklabels( ), va ):
208
for t, y in zip( plots[1].get_xticklabels( ), va ):
212
plt.savefig('speedup-steps.png', dpi=300, bbox_inches='tight')#, bbox_extra_artists=(legend,))