aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrea Bastoni <bastoni@cs.unc.edu>2010-04-02 15:26:30 -0400
committerAndrea Bastoni <bastoni@cs.unc.edu>2010-04-02 15:26:30 -0400
commitfa1fb842fe42e07508cc8f6cf371aeb468b077a3 (patch)
tree4c13adfca369e73f0a2a9e2ba9f5857b2e2f985b
parent0fbeff4a0887a48dea0a95a1d51e4ff9766c8d12 (diff)
Better file processing in plot_pm and plotting errorbars
-rwxr-xr-xgnuplot.py11
-rwxr-xr-xplot_pm.py159
2 files changed, 72 insertions, 98 deletions
diff --git a/gnuplot.py b/gnuplot.py
index d32b3c5..0afb9b3 100755
--- a/gnuplot.py
+++ b/gnuplot.py
@@ -56,8 +56,15 @@ def gnuplot_cmd(graphs, title=None, ylabel=None, xlabel=None,
56 g('set key %s' % key) 56 g('set key %s' % key)
57 plot = [] 57 plot = []
58 for gr in graphs: 58 for gr in graphs:
59 par = (gr[0], gr[1], gr[2], gr[3], style) if len(gr) == 4 else gr 59 if len(gr) == 4:
60 plot += ["'%s' using %s:%s title '%s' with %s" % par] 60 par = (gr[0], gr[1], gr[2], gr[3], style)
61 plot += ["'%s' using %s:%s title '%s' with %s" % par]
62 elif len(gr) == 6:
63 par = (gr[0], gr[1], gr[2], gr[3], gr[4], style, gr[5])
64 plot += ["'%s' using %s:%s:%s:%s with %s title '%s'" % par]
65 else:
66 par = gr
67 plot += ["'%s' using %s:%s title '%s' with %s" % par]
61 if plot: 68 if plot:
62 g('plot ' + ', '.join(plot)) 69 g('plot ' + ', '.join(plot))
63 if format != 'show' and fname: 70 if format != 'show' and fname:
diff --git a/plot_pm.py b/plot_pm.py
index c2b501c..2975b45 100755
--- a/plot_pm.py
+++ b/plot_pm.py
@@ -9,11 +9,8 @@ from gnuplot import gnuplot, FORMATS
9 9
10options = [ 10options = [
11 o(None, '--shared-l3', action='store_true', dest='sharedL3'), 11 o(None, '--shared-l3', action='store_true', dest='sharedL3'),
12 o(None, '--all', action='store_true', dest='alloh', help='Print a single \
13plot for all overheads (assume the file list contains all different \
14overheads to plot)'),
15 o(None, '--name', action='store', dest='name', help='where to store the \ 12 o(None, '--name', action='store', dest='name', help='where to store the \
16output WHEN using --all'), 13output'),
17 o(None, '--type', action='store', dest='type', type='choice', 14 o(None, '--type', action='store', dest='type', type='choice',
18 choices=['hard','soft'], help='type of plot'), 15 choices=['hard','soft'], help='type of plot'),
19 o('-f', '--format', action='store', dest='format', type='choice', 16 o('-f', '--format', action='store', dest='format', type='choice',
@@ -24,11 +21,11 @@ output WHEN using --all'),
24 21
25defaults = { 22defaults = {
26 'sharedL3' : False, 23 'sharedL3' : False,
27 'alloh' : False, 24 'name' : 'test',
28 'type' : 'hard', 25 'type' : 'hard',
29 'format' : 'show', 26 'format' : 'show',
30 'xrange' : (74.5, 250.5), 27 'xrange' : (74.5, 250.5),
31 'yrange' : (0, 5000), 28 'yrange' : (100, 1700),
32 'xticks' : (0, 25), 29 'xticks' : (0, 25),
33 'yticks' : (0, 250), 30 'yticks' : (0, 250),
34 'title' : None, 31 'title' : None,
@@ -37,7 +34,17 @@ defaults = {
37 'paper' : False, 34 'paper' : False,
38 'split' : False, 35 'split' : False,
39 'wide' : False, 36 'wide' : False,
40 } 37}
38
39JOB_TYPE = {
40 'NP' : 'Non Preemptive jobs',
41 'P' : 'Preemptive jobs'
42}
43
44BWORK = {
45 'bg' : 'with background work',
46 'idle' : 'without background work'
47}
41 48
42def overhead_heading(conf, sharedL3=False): 49def overhead_heading(conf, sharedL3=False):
43 ovd_type = 'unknowkn overhead' 50 ovd_type = 'unknowkn overhead'
@@ -52,107 +59,76 @@ def overhead_heading(conf, sharedL3=False):
52 elif conf['ovd'] == 'l2cache': 59 elif conf['ovd'] == 'l2cache':
53 ovd_type = 'Shared L2' 60 ovd_type = 'Shared L2'
54 elif conf['ovd'] == 'offchip': 61 elif conf['ovd'] == 'offchip':
55 ovd_type = 'Off Chip' 62 ovd_type = 'Diff. Socket'
56 63
57 return ovd_type 64 return ovd_type
58 65
59class PmPlotter(defapp.App): 66class PmPlotter(defapp.App):
60 def __init__(self): 67 def __init__(self):
61 defapp.App.__init__(self, options, defaults, no_std_opts=True) 68 defapp.App.__init__(self, options, defaults, no_std_opts=True)
62 # "private" values needed when --all options is given
63 self.graphs_list = [] 69 self.graphs_list = []
64 self.title = '' 70 self.title = ''
71 self.fname = {'ovd':set([]), 'wss':set([])}
65 self.tmpfile_list = [] 72 self.tmpfile_list = []
66 self.conf = [] 73 self.conf = []
67 74
75 def compose_name(self, conf):
76 name = 'pm_'
77 name += ('avg' if 'soft' in conf else 'wc')
78 name += '_wss='
79 wsses = []
80 for i in self.fname['wss']:
81 wsses.append(i)
82 for i in sorted(wsses, key=int):
83 name += str(i) + ','
84 name = name[0:-1]
85 name += '_ovd='
86 for i in self.fname['ovd']:
87 name += str(i) + ','
88 name = name[0:-1]
89 return name
90
68 def plot(self, graphs, title, name, conf, **xtra): 91 def plot(self, graphs, title, name, conf, **xtra):
92 name = self.compose_name(conf)
93 print name
69 gnuplot(graphs, title=title, 94 gnuplot(graphs, title=title,
70 xlabel=self.options.xlabel, 95 xlabel=self.options.xlabel,
71 ylabel=self.options.ylabel + 96 ylabel=self.options.ylabel +
72 (' [avg]' if 'soft' in conf else ' [max]'), 97 (' [avg]' if 'soft' in conf else ' [max]'),
73 xrange=self.options.xrange, 98 #xrange=self.options.xrange,
74 yrange=self.options.yrange, 99 #yrange=self.options.yrange,
75 xticks=self.options.xticks, 100 #xticks=self.options.xticks,
76 yticks=self.options.yticks, 101 #yticks=self.options.yticks,
77 format=self.options.format, 102 format=self.options.format,
103 style=('yerrorlines' if 'soft' in conf else 'linespoints'),
78 fname=name, **xtra) 104 fname=name, **xtra)
79 105
80 def plot_wide(self, graphs, title, name, conf, **xtra): 106 def compose_title(self, conf):
81 tops = 'rounded size 16cm,6.5cm' 107 if self.title == '':
82 gnuplot(graphs, title=title, 108 if 'soft' in conf:
83 xlabel=self.options.xlabel, 109 self.title = 'measured average overhead to 2nd hot access'
84 ylabel=self.options.ylabel + 110 else:
85 (' [avg]' if 'soft' in conf else ' [max]'), 111 self.title = 'measured maximum overhead to 2nd hot access'
86 xrange=self.options.xrange,
87 yrange=self.options.yrange,
88 xticks=self.options.xticks,
89 yticks=self.options.yticks,
90 format=self.options.format,
91 fname=name,
92 term_opts=tops,
93 **xtra)
94
95 def plot_paper(self, graphs, title, name, conf, **xtra):
96 tops = 'color solid font "Helvetica,10" linewidth 1.0 rounded size 16cm,8.5cm'
97 gnuplot(graphs, title=title,
98 xlabel=self.options.xlabel,
99 ylabel=self.options.ylabel +
100 (' [avg]' if 'soft' in conf else ' [max]'),
101 xrange=self.options.xrange,
102 yrange=self.options.yrange,
103 xticks=self.options.xticks,
104 yticks=self.options.yticks,
105 format=self.options.format,
106 fname=name,
107 key='off',
108 style='lines lw 7',
109 term_opts=tops)
110
111 def plot_pm(self, tmpfile, name, conf):
112 title = overhead_heading(conf, sharedL3=self.options.sharedL3)
113 title += ' ; ' + scenario_heading(conf, want_period=True)
114 plugin = conf['plugin']
115 if 'soft' in conf:
116 name = 'soft_' + name
117 else:
118 name = 'hard_' + name
119 wsslist = conf['wss'].split(',')
120 graphs = []
121 wsspos = 2
122 if 'soft' in conf:
123 wsspos += 1
124 for i in wsslist:
125 label = plugin + ' WSS=' + i
126 graphs.append((tmpfile, 1, wsspos, label))
127 wsspos += 2
128
129 if self.options.paper and self.options.format == 'pdf':
130 self.plot_paper(graphs, title, name, conf)
131 elif self.options.wide and self.options.format == 'pdf':
132 self.plot_wide(graphs, title, name, conf)
133 else:
134 self.plot(graphs, title, name, conf)
135 112
136 def add_to_graph_list(self, tmpfile, name, conf): 113 def add_to_graph_list(self, tmpfile, name, conf):
137 #self.title += overhead_heading(conf, sharedL3=self.options.sharedL3) 114 self.compose_title(conf)
138 #self.title += ' ; '
139 wsslist = conf['wss'].split(',') 115 wsslist = conf['wss'].split(',')
116 self.fname['ovd'].add(conf['ovd'])
140 wsspos = 2 117 wsspos = 2
141 if 'soft' in conf: 118 if 'soft' in conf:
142 wsspos += 1 119 wsspos += 1
143 for i in wsslist: 120 for i in wsslist:
144 label = conf['plugin'] + ' ' + conf['ovd'] + ' WSS=' + i 121 self.fname['wss'].add(i)
145 self.graphs_list.append((tmpfile, 1, wsspos, label)) 122 label = conf['ovd'] + ' WSS=' + i
146 wsspos += 2 123 if 'soft' in conf:
147 124 self.graphs_list.append((tmpfile, 1, wsspos, wsspos+1, \
148 def plot_graph_list(self, type, name='blob'): 125 wsspos+2, label))
149 self.title = self.title[0:-3] 126 else:
150 if self.options.paper and self.options.format == 'pdf': 127 self.graphs_list.append((tmpfile, 1, wsspos, label))
151 self.plot_paper(self.graphs_list, self.title, name, type) 128 wsspos += 4
152 elif self.options.wide and self.options.format == 'pdf': 129
153 self.plot_wide(self.graphs_list, self.title, name, type) 130 def plot_graph_list(self, type, name):
154 else: 131 self.plot(self.graphs_list, self.title, name, type)
155 self.plot(self.graphs_list, self.title, name, type)
156 132
157 # delete temporary data files 133 # delete temporary data files
158 for tmp in self.tmpfile_list: 134 for tmp in self.tmpfile_list:
@@ -170,20 +146,12 @@ class PmPlotter(defapp.App):
170 if tmpfile: 146 if tmpfile:
171 if 'pm' in conf: 147 if 'pm' in conf:
172 conf[self.options.type] = None 148 conf[self.options.type] = None
173 if self.options.alloh: 149 self.add_to_graph_list(tmpfile.name, name, conf)
174 self.add_to_graph_list(tmpfile.name, name, conf)
175 else:
176 self.plot_pm(tmpfile.name, name, conf)
177 else: 150 else:
178 self.err("Skipped '%s'; unknown experiment type." 151 self.err("Skipped '%s'; unknown experiment type."
179 % bname) 152 % bname)
180 153 # keep a list of temporary data files
181 if self.options.alloh: 154 self.tmpfile_list.append(tmpfile)
182 # keep a list of temporary data files
183 self.tmpfile_list.append(tmpfile)
184
185 else:
186 del tmpfile # removes temp file
187 else: 155 else:
188 self.err("Skipped '%s'; it dosn't appear to contain data." 156 self.err("Skipped '%s'; it dosn't appear to contain data."
189 % bname) 157 % bname)
@@ -192,9 +160,8 @@ class PmPlotter(defapp.App):
192 for datafile in self.args: 160 for datafile in self.args:
193 self.plot_file(datafile) 161 self.plot_file(datafile)
194 162
195 if self.options.alloh: 163 # also clean up tmp data files
196 # also clean up tmp data files 164 self.plot_graph_list(self.options.type, self.options.name)
197 self.plot_graph_list(self.options.type, self.options.name)
198 165
199if __name__ == "__main__": 166if __name__ == "__main__":
200 PmPlotter().launch() 167 PmPlotter().launch()