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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
|
#!/usr/bin/env python
import defapp
from os.path import splitext, basename
from optparse import make_option as o
from tempfile import NamedTemporaryFile as Tmp
from plot import decode, scenario_heading, get_data_tmpfile
from gnuplot import gnuplot, FORMATS
options = [
o(None, '--shared-l3', action='store_true', dest='sharedL3'),
o(None, '--all', action='store_true', dest='alloh', help='Print a single \
plot for all overheads (assume the file list contains all different \
overheads to plot)'),
o(None, '--name', action='store', dest='name', help='where to store the \
output WHEN using --all'),
o(None, '--type', action='store', dest='type', type='choice',
choices=['hard','soft'], help='type of plot'),
o('-f', '--format', action='store', dest='format', type='choice',
choices=FORMATS, help='output format'),
o(None, '--paper', action='store_true', dest='paper'),
o(None, '--wide', action='store_true', dest='wide'),
]
defaults = {
'sharedL3' : False,
'alloh' : False,
'type' : 'hard',
'format' : 'show',
'xrange' : (74.5, 250.5),
'yrange' : (0, 5000),
'xticks' : (0, 25),
'yticks' : (0, 250),
'title' : None,
'xlabel' : 'number of tasks',
'ylabel' : 'overhead (us)',
'paper' : False,
'split' : False,
'wide' : False,
}
def overhead_heading(conf, sharedL3=False):
ovd_type = 'unknowkn overhead'
if 'ovd' in conf:
if conf['ovd'] == 'preemption':
ovd_type = 'Preemption'
elif conf['ovd'] == 'onchip':
if sharedL3:
ovd_type = 'Shared L3'
else:
ovd_type = 'Shared L2'
elif conf['ovd'] == 'l2cache':
ovd_type = 'Shared L2'
elif conf['ovd'] == 'offchip':
ovd_type = 'Off Chip'
return ovd_type
class PmPlotter(defapp.App):
def __init__(self):
defapp.App.__init__(self, options, defaults, no_std_opts=True)
# "private" values needed when --all options is given
self.graphs_list = []
self.title = ''
self.tmpfile_list = []
self.conf = []
def plot(self, graphs, title, name, conf, **xtra):
gnuplot(graphs, title=title,
xlabel=self.options.xlabel,
ylabel=self.options.ylabel +
(' [avg]' if 'soft' in conf else ' [max]'),
xrange=self.options.xrange,
yrange=self.options.yrange,
xticks=self.options.xticks,
yticks=self.options.yticks,
format=self.options.format,
fname=name, **xtra)
def plot_wide(self, graphs, title, name, conf, **xtra):
tops = 'rounded size 16cm,6.5cm'
gnuplot(graphs, title=title,
xlabel=self.options.xlabel,
ylabel=self.options.ylabel +
(' [avg]' if 'soft' in conf else ' [max]'),
xrange=self.options.xrange,
yrange=self.options.yrange,
xticks=self.options.xticks,
yticks=self.options.yticks,
format=self.options.format,
fname=name,
term_opts=tops,
**xtra)
def plot_paper(self, graphs, title, name, conf, **xtra):
tops = 'color solid font "Helvetica,10" linewidth 1.0 rounded size 16cm,8.5cm'
gnuplot(graphs, title=title,
xlabel=self.options.xlabel,
ylabel=self.options.ylabel +
(' [avg]' if 'soft' in conf else ' [max]'),
xrange=self.options.xrange,
yrange=self.options.yrange,
xticks=self.options.xticks,
yticks=self.options.yticks,
format=self.options.format,
fname=name,
key='off',
style='lines lw 7',
term_opts=tops)
def plot_pm(self, tmpfile, name, conf):
title = overhead_heading(conf, sharedL3=self.options.sharedL3)
title += ' ; ' + scenario_heading(conf, want_period=True)
plugin = conf['plugin']
if 'soft' in conf:
name = 'soft_' + name
else:
name = 'hard_' + name
wsslist = conf['wss'].split(',')
graphs = []
wsspos = 2
if 'soft' in conf:
wsspos += 1
for i in wsslist:
label = plugin + ' WSS=' + i
graphs.append((tmpfile, 1, wsspos, label))
wsspos += 2
if self.options.paper and self.options.format == 'pdf':
self.plot_paper(graphs, title, name, conf)
elif self.options.wide and self.options.format == 'pdf':
self.plot_wide(graphs, title, name, conf)
else:
self.plot(graphs, title, name, conf)
def add_to_graph_list(self, tmpfile, name, conf):
#self.title += overhead_heading(conf, sharedL3=self.options.sharedL3)
#self.title += ' ; '
wsslist = conf['wss'].split(',')
wsspos = 2
if 'soft' in conf:
wsspos += 1
for i in wsslist:
label = conf['plugin'] + ' ' + conf['ovd'] + ' WSS=' + i
self.graphs_list.append((tmpfile, 1, wsspos, label))
wsspos += 2
def plot_graph_list(self, type, name='blob'):
self.title = self.title[0:-3]
if self.options.paper and self.options.format == 'pdf':
self.plot_paper(self.graphs_list, self.title, name, type)
elif self.options.wide and self.options.format == 'pdf':
self.plot_wide(self.graphs_list, self.title, name, type)
else:
self.plot(self.graphs_list, self.title, name, type)
# delete temporary data files
for tmp in self.tmpfile_list:
del tmp
def plot_file(self, datafile):
bname = basename(datafile)
name, ext = splitext(bname)
if ext != '.csv':
self.err("Warning: '%s' doesn't look like a CSV file. Skipping..."
% bname)
return None
conf = decode(name)
tmpfile = get_data_tmpfile(datafile)
if tmpfile:
if 'pm' in conf:
conf[self.options.type] = None
if self.options.alloh:
self.add_to_graph_list(tmpfile.name, name, conf)
else:
self.plot_pm(tmpfile.name, name, conf)
else:
self.err("Skipped '%s'; unknown experiment type."
% bname)
if self.options.alloh:
# keep a list of temporary data files
self.tmpfile_list.append(tmpfile)
else:
del tmpfile # removes temp file
else:
self.err("Skipped '%s'; it dosn't appear to contain data."
% bname)
def default(self, _):
for datafile in self.args:
self.plot_file(datafile)
if self.options.alloh:
# also clean up tmp data files
self.plot_graph_list(self.options.type, self.options.name)
if __name__ == "__main__":
PmPlotter().launch()
|