From 9c613968ee815c1f4c32d594ddc67a5cabccce81 Mon Sep 17 00:00:00 2001 From: Andrea Bastoni Date: Tue, 23 Mar 2010 12:41:18 -0400 Subject: Add support for plotting multiple types of pm overheads --- plot_pm.py | 102 +++++++++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 79 insertions(+), 23 deletions(-) (limited to 'plot_pm.py') diff --git a/plot_pm.py b/plot_pm.py index 7388dce..2fb04c5 100755 --- a/plot_pm.py +++ b/plot_pm.py @@ -8,6 +8,13 @@ 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'), @@ -16,11 +23,12 @@ options = [ defaults = { 'sharedL3' : False, + 'alloh' : False, 'format' : 'show', - 'xrange' : (49.5, 250.5), - 'yrange' : (0, 500.05), + 'xrange' : (74.5, 250.5), + 'yrange' : (0, 4300.05), 'xticks' : (0, 10), - 'yticks' : (0, 50), + 'yticks' : (0, 100), 'title' : None, 'xlabel' : 'number of tasks', 'ylabel' : 'overhead (us)', @@ -57,21 +65,7 @@ def get_data_tmpfile(datafile): del d # removes temp file return None -def scenario_heading(conf, want_period=False, sharedL3=False): - ovd_type = 'unknowkn overhead' - if 'ovd' in conf: - if conf['ovd'] == 'preemption': - ovd_type = 'Preemption ovhead' - elif conf['ovd'] == 'onchip': - if sharedL3: - ovd_type = 'Shared L3 migration ovhead' - else: - ovd_type = 'Shared L2 migration ovhead' - elif conf['ovd'] == 'l2cache': - ovd_type = 'Shared L2 migration ovhead' - elif conf['ovd'] == 'offchip': - ovd_type = 'Off Chip migration ovhead' - +def scenario_heading(conf, want_period=False): dist = 'unknown distribution' if 'dist' in conf: if conf['dist'] == 'uni': @@ -98,11 +92,33 @@ def scenario_heading(conf, want_period=False, sharedL3=False): else: dist += '; period uniformly in [10, 100]' - return ovd_type + '; ' + dist + return dist + +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, @@ -148,7 +164,8 @@ class PmPlotter(defapp.App): term_opts=tops) def plot_pm(self, tmpfile, name, conf): - title = scenario_heading(conf, want_period=True, sharedL3=self.options.sharedL3) + title = overhead_heading(conf, sharedL3=self.options.sharedL3) + title += ' ; ' + scenario_heading(conf, want_period=True) plugin = conf['plugin'] wsslist = conf['wss'].split(',') graphs = [] @@ -167,21 +184,56 @@ class PmPlotter(defapp.App): 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 + for i in wsslist: + if 'soft' in conf: + wsspos += 1 + label = conf['plugin'] + ' ' + conf['ovd'] + ' WSS=' + i + self.graphs_list.append((tmpfile, 1, wsspos, label)) + wsspos += 2 + + def plot_graph_list(self, name='blob', conf='hard'): + self.title = self.title[0:-3] + if self.options.paper and self.options.format == 'pdf': + self.plot_paper(self.graphs_list, self.title, name, conf) + elif self.options.wide and self.options.format == 'pdf': + self.plot_wide(self.graphs_list, self.title, name, conf) + else: + self.plot(self.graphs_list, self.title, name, conf) + + # 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." + 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: - self.plot_pm(tmpfile.name, name, conf) + 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'; unkown experiment type." % bname) - del tmpfile # removes temp file + + 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) @@ -190,5 +242,9 @@ class PmPlotter(defapp.App): 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.name, self.options.type) + if __name__ == "__main__": PmPlotter().launch() -- cgit v1.2.2