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
|
#!/usr/bin/env python
import defapp
import time
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, '--name', action='store', dest='name', help='where to store the \
output'),
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,
'name' : 'test',
'type' : 'hard',
'format' : 'show',
'xrange' : (74.5, 250.5),
'yrange' : (100, 1700),
'xticks' : (0, 25),
'yticks' : (0, 250),
'title' : None,
'xlabel' : 'number of tasks',
'ylabel' : 'overhead (us)',
'paper' : False,
'split' : False,
'wide' : False,
}
JOB_TYPE = {
'NP' : 'Non Preemptive jobs',
'P' : 'Preemptive jobs'
}
BWORK = {
'bg' : 'with background work',
'idle' : 'without background work'
}
def overhead_heading(conf, sharedL3=False):
ovd_type = 'unknowkn overhead'
if 'ovd' in conf:
if conf['ovd'] == 'preemption':
ovd_type = 'a preemption'
elif conf['ovd'] == 'onchip':
if sharedL3:
ovd_type = 'a migration through a shared L3 cache'
else:
ovd_type = 'a migration through a shared L2 cache'
elif conf['ovd'] == 'l2cache':
ovd_type = 'a migration through a shared L2 cache'
elif conf['ovd'] == 'offchip':
ovd_type = 'a migration through main memory'
return ovd_type
def style_selector(conf):
style = 'ls 1'
if 'ovd' in conf:
if conf['ovd'] == 'preemption':
style += '1'
elif conf['ovd'] == 'onchip':
style += '2'
elif conf['ovd'] == 'l2cache':
style += '3'
elif conf['ovd'] == 'offchip':
style += '4'
return style
class PmPlotter(defapp.App):
def __init__(self):
defapp.App.__init__(self, options, defaults, no_std_opts=True)
self.graphs_list = []
self.title = ''
self.fname = {'ovd':set([]), 'wss':set([])}
self.tmpfile_list = []
self.conf = []
def compose_name(self, conf):
name = 'pm_'
name += ('avg' if 'soft' in conf else 'wc')
name += '_wss='
wsses = []
for i in self.fname['wss']:
wsses.append(i)
for i in sorted(wsses, key=int):
name += str(i) + ','
name = name[0:-1]
name += '_ovd='
for i in self.fname['ovd']:
name += str(i) + ','
name = name[0:-1]
return name
def plot(self, graphs, title, name, conf, **xtra):
name = self.compose_name(conf)
print name
style = ('yerrorlines' if 'soft' in conf else 'linespoints')
gnuplot(graphs, title=title,
xlabel=self.options.xlabel,
ylabel=self.options.ylabel,
#xrange=self.options.xrange,
#yrange=self.options.yrange,
#xticks=self.options.xticks,
#yticks=self.options.yticks,
format=self.options.format,
style=style,
fname=name, **xtra)
def compose_title(self, conf):
if self.title == '':
if 'soft' in conf:
self.title = 'measured average overhead to 2nd hot access'
else:
self.title = 'measured maximum overhead to 2nd hot access'
def add_to_graph_list(self, tmpfile, name, conf):
self.compose_title(conf)
wsslist = conf['wss'].split(',')
self.fname['ovd'].add(conf['ovd'])
wsspos = 2
if 'soft' in conf:
wsspos += 1
for i in wsslist:
self.fname['wss'].add(i)
### XXX tweaking for ospert
#label = conf['ovd'] + ' WSS=' + i
label = overhead_heading(conf, self.options.sharedL3)
if 'soft' in conf:
self.graphs_list.append((tmpfile, 1, wsspos, wsspos+1, \
wsspos+2, label))
else:
self.graphs_list.append((tmpfile, 1, wsspos, label))
wsspos += 4
def plot_graph_list(self, type, name):
self.plot(self.graphs_list, self.title, name, type)
### XXX bad bad bad hack
### for just one graph save tmp file and plot the gnuplot output for
### manual tweaking
time.sleep(20)
# 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
self.add_to_graph_list(tmpfile.name, name, conf)
else:
self.err("Skipped '%s'; unknown experiment type."
% bname)
# keep a list of temporary data files
self.tmpfile_list.append(tmpfile)
### XXX part of the bad ack
print tmpfile.name + ' ' + name
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)
# also clean up tmp data files
self.plot_graph_list(self.options.type, self.options.name)
if __name__ == "__main__":
PmPlotter().launch()
|