diff options
author | Andrea Bastoni <bastoni@cs.unc.edu> | 2010-03-23 12:41:18 -0400 |
---|---|---|
committer | Andrea Bastoni <bastoni@cs.unc.edu> | 2010-03-23 12:41:18 -0400 |
commit | 9c613968ee815c1f4c32d594ddc67a5cabccce81 (patch) | |
tree | c87f375f0372d05ff869692f27459ab5ec086379 /plot_pm.py | |
parent | b34525e7838d6e513e1ffdcfea5482f6b879d527 (diff) |
Add support for plotting multiple types of pm overheads
Diffstat (limited to 'plot_pm.py')
-rwxr-xr-x | plot_pm.py | 102 |
1 files changed, 79 insertions, 23 deletions
@@ -8,6 +8,13 @@ from gnuplot import gnuplot, FORMATS | |||
8 | 8 | ||
9 | options = [ | 9 | options = [ |
10 | o(None, '--shared-l3', action='store_true', dest='sharedL3'), | 10 | o(None, '--shared-l3', action='store_true', dest='sharedL3'), |
11 | o(None, '--all', action='store_true', dest='alloh', help='Print a single \ | ||
12 | plot for all overheads (assume the file list contains all different \ | ||
13 | overheads to plot)'), | ||
14 | o(None, '--name', action='store', dest='name', help='where to store the \ | ||
15 | output WHEN using --all'), | ||
16 | o(None, '--type', action='store', dest='type', type='choice', | ||
17 | choices=['hard','soft'], help='type of plot'), | ||
11 | o('-f', '--format', action='store', dest='format', type='choice', | 18 | o('-f', '--format', action='store', dest='format', type='choice', |
12 | choices=FORMATS, help='output format'), | 19 | choices=FORMATS, help='output format'), |
13 | o(None, '--paper', action='store_true', dest='paper'), | 20 | o(None, '--paper', action='store_true', dest='paper'), |
@@ -16,11 +23,12 @@ options = [ | |||
16 | 23 | ||
17 | defaults = { | 24 | defaults = { |
18 | 'sharedL3' : False, | 25 | 'sharedL3' : False, |
26 | 'alloh' : False, | ||
19 | 'format' : 'show', | 27 | 'format' : 'show', |
20 | 'xrange' : (49.5, 250.5), | 28 | 'xrange' : (74.5, 250.5), |
21 | 'yrange' : (0, 500.05), | 29 | 'yrange' : (0, 4300.05), |
22 | 'xticks' : (0, 10), | 30 | 'xticks' : (0, 10), |
23 | 'yticks' : (0, 50), | 31 | 'yticks' : (0, 100), |
24 | 'title' : None, | 32 | 'title' : None, |
25 | 'xlabel' : 'number of tasks', | 33 | 'xlabel' : 'number of tasks', |
26 | 'ylabel' : 'overhead (us)', | 34 | 'ylabel' : 'overhead (us)', |
@@ -57,21 +65,7 @@ def get_data_tmpfile(datafile): | |||
57 | del d # removes temp file | 65 | del d # removes temp file |
58 | return None | 66 | return None |
59 | 67 | ||
60 | def scenario_heading(conf, want_period=False, sharedL3=False): | 68 | def scenario_heading(conf, want_period=False): |
61 | ovd_type = 'unknowkn overhead' | ||
62 | if 'ovd' in conf: | ||
63 | if conf['ovd'] == 'preemption': | ||
64 | ovd_type = 'Preemption ovhead' | ||
65 | elif conf['ovd'] == 'onchip': | ||
66 | if sharedL3: | ||
67 | ovd_type = 'Shared L3 migration ovhead' | ||
68 | else: | ||
69 | ovd_type = 'Shared L2 migration ovhead' | ||
70 | elif conf['ovd'] == 'l2cache': | ||
71 | ovd_type = 'Shared L2 migration ovhead' | ||
72 | elif conf['ovd'] == 'offchip': | ||
73 | ovd_type = 'Off Chip migration ovhead' | ||
74 | |||
75 | dist = 'unknown distribution' | 69 | dist = 'unknown distribution' |
76 | if 'dist' in conf: | 70 | if 'dist' in conf: |
77 | if conf['dist'] == 'uni': | 71 | if conf['dist'] == 'uni': |
@@ -98,11 +92,33 @@ def scenario_heading(conf, want_period=False, sharedL3=False): | |||
98 | else: | 92 | else: |
99 | dist += '; period uniformly in [10, 100]' | 93 | dist += '; period uniformly in [10, 100]' |
100 | 94 | ||
101 | return ovd_type + '; ' + dist | 95 | return dist |
96 | |||
97 | def overhead_heading(conf, sharedL3=False): | ||
98 | ovd_type = 'unknowkn overhead' | ||
99 | if 'ovd' in conf: | ||
100 | if conf['ovd'] == 'preemption': | ||
101 | ovd_type = 'Preemption' | ||
102 | elif conf['ovd'] == 'onchip': | ||
103 | if sharedL3: | ||
104 | ovd_type = 'Shared L3' | ||
105 | else: | ||
106 | ovd_type = 'Shared L2' | ||
107 | elif conf['ovd'] == 'l2cache': | ||
108 | ovd_type = 'Shared L2' | ||
109 | elif conf['ovd'] == 'offchip': | ||
110 | ovd_type = 'Off Chip' | ||
111 | |||
112 | return ovd_type | ||
102 | 113 | ||
103 | class PmPlotter(defapp.App): | 114 | class PmPlotter(defapp.App): |
104 | def __init__(self): | 115 | def __init__(self): |
105 | defapp.App.__init__(self, options, defaults, no_std_opts=True) | 116 | defapp.App.__init__(self, options, defaults, no_std_opts=True) |
117 | # "private" values needed when --all options is given | ||
118 | self.graphs_list = [] | ||
119 | self.title = '' | ||
120 | self.tmpfile_list = [] | ||
121 | self.conf = [] | ||
106 | 122 | ||
107 | def plot(self, graphs, title, name, conf, **xtra): | 123 | def plot(self, graphs, title, name, conf, **xtra): |
108 | gnuplot(graphs, title=title, | 124 | gnuplot(graphs, title=title, |
@@ -148,7 +164,8 @@ class PmPlotter(defapp.App): | |||
148 | term_opts=tops) | 164 | term_opts=tops) |
149 | 165 | ||
150 | def plot_pm(self, tmpfile, name, conf): | 166 | def plot_pm(self, tmpfile, name, conf): |
151 | title = scenario_heading(conf, want_period=True, sharedL3=self.options.sharedL3) | 167 | title = overhead_heading(conf, sharedL3=self.options.sharedL3) |
168 | title += ' ; ' + scenario_heading(conf, want_period=True) | ||
152 | plugin = conf['plugin'] | 169 | plugin = conf['plugin'] |
153 | wsslist = conf['wss'].split(',') | 170 | wsslist = conf['wss'].split(',') |
154 | graphs = [] | 171 | graphs = [] |
@@ -167,21 +184,56 @@ class PmPlotter(defapp.App): | |||
167 | else: | 184 | else: |
168 | self.plot(graphs, title, name, conf) | 185 | self.plot(graphs, title, name, conf) |
169 | 186 | ||
187 | def add_to_graph_list(self, tmpfile, name, conf): | ||
188 | self.title += overhead_heading(conf, sharedL3=self.options.sharedL3) | ||
189 | self.title += ' ; ' | ||
190 | wsslist = conf['wss'].split(',') | ||
191 | wsspos = 2 | ||
192 | for i in wsslist: | ||
193 | if 'soft' in conf: | ||
194 | wsspos += 1 | ||
195 | label = conf['plugin'] + ' ' + conf['ovd'] + ' WSS=' + i | ||
196 | self.graphs_list.append((tmpfile, 1, wsspos, label)) | ||
197 | wsspos += 2 | ||
198 | |||
199 | def plot_graph_list(self, name='blob', conf='hard'): | ||
200 | self.title = self.title[0:-3] | ||
201 | if self.options.paper and self.options.format == 'pdf': | ||
202 | self.plot_paper(self.graphs_list, self.title, name, conf) | ||
203 | elif self.options.wide and self.options.format == 'pdf': | ||
204 | self.plot_wide(self.graphs_list, self.title, name, conf) | ||
205 | else: | ||
206 | self.plot(self.graphs_list, self.title, name, conf) | ||
207 | |||
208 | # delete temporary data files | ||
209 | for tmp in self.tmpfile_list: | ||
210 | del tmp | ||
211 | |||
170 | def plot_file(self, datafile): | 212 | def plot_file(self, datafile): |
171 | bname = basename(datafile) | 213 | bname = basename(datafile) |
172 | name, ext = splitext(bname) | 214 | name, ext = splitext(bname) |
173 | if ext != '.csv': | 215 | if ext != '.csv': |
174 | self.err("Warning: '%s' doesn't look like a CSV file." | 216 | self.err("Warning: '%s' doesn't look like a CSV file. Skipping..." |
175 | % bname) | 217 | % bname) |
218 | return None | ||
176 | conf = decode(name) | 219 | conf = decode(name) |
177 | tmpfile = get_data_tmpfile(datafile) | 220 | tmpfile = get_data_tmpfile(datafile) |
178 | if tmpfile: | 221 | if tmpfile: |
179 | if 'pm' in conf: | 222 | if 'pm' in conf: |
180 | self.plot_pm(tmpfile.name, name, conf) | 223 | if self.options.alloh: |
224 | self.add_to_graph_list(tmpfile.name, name, conf) | ||
225 | else: | ||
226 | self.plot_pm(tmpfile.name, name, conf) | ||
181 | else: | 227 | else: |
182 | self.err("Skipped '%s'; unkown experiment type." | 228 | self.err("Skipped '%s'; unkown experiment type." |
183 | % bname) | 229 | % bname) |
184 | del tmpfile # removes temp file | 230 | |
231 | if self.options.alloh: | ||
232 | # keep a list of temporary data files | ||
233 | self.tmpfile_list.append(tmpfile) | ||
234 | |||
235 | else: | ||
236 | del tmpfile # removes temp file | ||
185 | else: | 237 | else: |
186 | self.err("Skipped '%s'; it dosn't appear to contain data." | 238 | self.err("Skipped '%s'; it dosn't appear to contain data." |
187 | % bname) | 239 | % bname) |
@@ -190,5 +242,9 @@ class PmPlotter(defapp.App): | |||
190 | for datafile in self.args: | 242 | for datafile in self.args: |
191 | self.plot_file(datafile) | 243 | self.plot_file(datafile) |
192 | 244 | ||
245 | if self.options.alloh: | ||
246 | # also clean up tmp data files | ||
247 | self.plot_graph_list(self.options.name, self.options.type) | ||
248 | |||
193 | if __name__ == "__main__": | 249 | if __name__ == "__main__": |
194 | PmPlotter().launch() | 250 | PmPlotter().launch() |