diff options
| author | Jonathan Herman <hermanjl@cs.unc.edu> | 2012-10-12 01:56:20 -0400 |
|---|---|---|
| committer | Jonathan Herman <hermanjl@cs.unc.edu> | 2012-10-12 01:56:20 -0400 |
| commit | d66aa52d719cf7edad8cac20b711e4c16d2899de (patch) | |
| tree | 167415c66fa78c045fc0a793fe655ffba4b24cfa | |
| parent | 5d97a6baf6166b74355c6e744e010949a46fd625 (diff) | |
Bug fixes from mixed-criticality experiments
| -rw-r--r-- | experiment/experiment.py | 2 | ||||
| -rw-r--r-- | parse/ft.py | 12 | ||||
| -rw-r--r-- | parse/sched.py | 8 | ||||
| -rw-r--r-- | parse/tuple_table.py | 5 | ||||
| -rwxr-xr-x | parse_exps.py | 26 | ||||
| -rw-r--r-- | plot_exps.py | 21 | ||||
| -rwxr-xr-x | run_exps.py | 49 |
7 files changed, 79 insertions, 44 deletions
diff --git a/experiment/experiment.py b/experiment/experiment.py index e6dc92d..f0c201d 100644 --- a/experiment/experiment.py +++ b/experiment/experiment.py | |||
| @@ -197,7 +197,7 @@ class Experiment(object): | |||
| 197 | self.exec_out and self.exec_out.close() | 197 | self.exec_out and self.exec_out.close() |
| 198 | self.exec_err and self.exec_err.close() | 198 | self.exec_err and self.exec_err.close() |
| 199 | 199 | ||
| 200 | sleep_time = 5 | 200 | sleep_time = 10 |
| 201 | self.log("Sleeping %d seconds to allow buffer flushing" % sleep_time) | 201 | self.log("Sleeping %d seconds to allow buffer flushing" % sleep_time) |
| 202 | time.sleep(sleep_time) | 202 | time.sleep(sleep_time) |
| 203 | 203 | ||
diff --git a/parse/ft.py b/parse/ft.py index 127e49f..c915978 100644 --- a/parse/ft.py +++ b/parse/ft.py | |||
| @@ -6,7 +6,10 @@ import subprocess | |||
| 6 | 6 | ||
| 7 | from point import Measurement,Type | 7 | from point import Measurement,Type |
| 8 | 8 | ||
| 9 | def get_ft_output(data_dir, out_dir): | 9 | def get_ft_output(data_dir, out_dir, force=False): |
| 10 | """ | ||
| 11 | Create and return files containing sorted and analyzed overhead data | ||
| 12 | """ | ||
| 10 | bin_file = conf.FILES['ft_data'] + "$" | 13 | bin_file = conf.FILES['ft_data'] + "$" |
| 11 | bins = [f for f in os.listdir(data_dir) if re.match(bin_file, f)] | 14 | bins = [f for f in os.listdir(data_dir) if re.match(bin_file, f)] |
| 12 | 15 | ||
| @@ -14,8 +17,11 @@ def get_ft_output(data_dir, out_dir): | |||
| 14 | output_file = "{}/out-ft".format(out_dir) | 17 | output_file = "{}/out-ft".format(out_dir) |
| 15 | 18 | ||
| 16 | if os.path.isfile(output_file): | 19 | if os.path.isfile(output_file): |
| 17 | print("ft-output already exists for %s" % data_dir) | 20 | if force: |
| 18 | return output_file | 21 | os.remove(output_file) |
| 22 | else: | ||
| 23 | print("ft-output already exists for %s" % data_dir) | ||
| 24 | return output_file | ||
| 19 | 25 | ||
| 20 | if len(bins) != 0: | 26 | if len(bins) != 0: |
| 21 | err_file = open("%s/err-ft" % out_dir, 'w') | 27 | err_file = open("%s/err-ft" % out_dir, 'w') |
diff --git a/parse/sched.py b/parse/sched.py index 300c569..a65f001 100644 --- a/parse/sched.py +++ b/parse/sched.py | |||
| @@ -50,7 +50,7 @@ class LeveledArray(object): | |||
| 50 | name = "%s%s" % ("%s-" % level if level else "", self.name) | 50 | name = "%s%s" % ("%s-" % level if level else "", self.name) |
| 51 | result[name] = Measurement(name).from_array(arr) | 51 | result[name] = Measurement(name).from_array(arr) |
| 52 | 52 | ||
| 53 | def get_st_output(data_dir, out_dir): | 53 | def get_st_output(data_dir, out_dir, force=False): |
| 54 | """ | 54 | """ |
| 55 | Create and return files containing unpacked sched data | 55 | Create and return files containing unpacked sched data |
| 56 | """ | 56 | """ |
| @@ -60,7 +60,11 @@ def get_st_output(data_dir, out_dir): | |||
| 60 | output_file = "%s/out-st" % out_dir | 60 | output_file = "%s/out-st" % out_dir |
| 61 | 61 | ||
| 62 | if os.path.isfile(output_file): | 62 | if os.path.isfile(output_file): |
| 63 | return output_file | 63 | if force: |
| 64 | os.remove(output_file) | ||
| 65 | else: | ||
| 66 | print("st-output already exists for %s" % data_dir) | ||
| 67 | return output_file | ||
| 64 | 68 | ||
| 65 | if len(bins) != 0: | 69 | if len(bins) != 0: |
| 66 | cmd_arr = [conf.BINS['st_show']] | 70 | cmd_arr = [conf.BINS['st_show']] |
diff --git a/parse/tuple_table.py b/parse/tuple_table.py index e6f0cc5..5e98d87 100644 --- a/parse/tuple_table.py +++ b/parse/tuple_table.py | |||
| @@ -24,7 +24,7 @@ class ColMap(object): | |||
| 24 | if added < len(kv): | 24 | if added < len(kv): |
| 25 | raise Exception("column map '%s' missed field in map '%s'" % | 25 | raise Exception("column map '%s' missed field in map '%s'" % |
| 26 | (self.col_list, kv)) | 26 | (self.col_list, kv)) |
| 27 | 27 | ||
| 28 | return key | 28 | return key |
| 29 | 29 | ||
| 30 | def __contains__(self, col): | 30 | def __contains__(self, col): |
| @@ -58,7 +58,7 @@ class TupleTable(object): | |||
| 58 | key = self.col_map.get_key(kv) | 58 | key = self.col_map.get_key(kv) |
| 59 | return self.table[key] | 59 | return self.table[key] |
| 60 | 60 | ||
| 61 | def __reduce(self): | 61 | def reduce(self): |
| 62 | if self.reduced: | 62 | if self.reduced: |
| 63 | raise Exception("cannot reduce twice!") | 63 | raise Exception("cannot reduce twice!") |
| 64 | self.reduced = True | 64 | self.reduced = True |
| @@ -67,7 +67,6 @@ class TupleTable(object): | |||
| 67 | 67 | ||
| 68 | def write_result(self, out_dir): | 68 | def write_result(self, out_dir): |
| 69 | dir_map = DirMap(out_dir) | 69 | dir_map = DirMap(out_dir) |
| 70 | self.__reduce() | ||
| 71 | for key, point in self.table.iteritems(): | 70 | for key, point in self.table.iteritems(): |
| 72 | kv = self.col_map.get_map(key) | 71 | kv = self.col_map.get_map(key) |
| 73 | 72 | ||
diff --git a/parse_exps.py b/parse_exps.py index 8f98309..1f36bab 100755 --- a/parse_exps.py +++ b/parse_exps.py | |||
| @@ -7,6 +7,7 @@ import os | |||
| 7 | import parse.ft as ft | 7 | import parse.ft as ft |
| 8 | import parse.sched as st | 8 | import parse.sched as st |
| 9 | import re | 9 | import re |
| 10 | import shutil as sh | ||
| 10 | 11 | ||
| 11 | from collections import namedtuple | 12 | from collections import namedtuple |
| 12 | from common import load_params | 13 | from common import load_params |
| @@ -18,10 +19,16 @@ def parse_args(): | |||
| 18 | parser = OptionParser("usage: %prog [options] [data_dir]...") | 19 | parser = OptionParser("usage: %prog [options] [data_dir]...") |
| 19 | 20 | ||
| 20 | parser.add_option('-o', '--out-dir', dest='out_dir', | 21 | parser.add_option('-o', '--out-dir', dest='out_dir', |
| 21 | help='directory for data output', default=os.getcwd()) | 22 | help='directory for data output', default='parse-data') |
| 23 | parser.add_option('-c', '--clean', action='store_true', default=False, | ||
| 24 | dest='clean', help='do not output single-point csvs') | ||
| 22 | parser.add_option('-s', '--scale-against', dest='scale_against', | 25 | parser.add_option('-s', '--scale-against', dest='scale_against', |
| 23 | metavar='PARAM=VALUE', default="", | 26 | metavar='PARAM=VALUE', default="", |
| 24 | help='calculate task scaling factors against these configs') | 27 | help='calculate task scaling factors against these configs') |
| 28 | parser.add_option('-f', '--force', action='store_true', default=False, | ||
| 29 | dest='force', help='overwrite existing data') | ||
| 30 | parser.add_option('-v', '--verbose', action='store_true', default=False, | ||
| 31 | dest='verbose', help='print out data points') | ||
| 25 | 32 | ||
| 26 | return parser.parse_args() | 33 | return parser.parse_args() |
| 27 | 34 | ||
| @@ -46,7 +53,7 @@ def get_exp_params(data_dir, col_map): | |||
| 46 | return params | 53 | return params |
| 47 | 54 | ||
| 48 | 55 | ||
| 49 | def gen_exp_data(exp_dirs, base_conf, col_map): | 56 | def gen_exp_data(exp_dirs, base_conf, col_map, force): |
| 50 | plain_exps = [] | 57 | plain_exps = [] |
| 51 | scaling_bases = [] | 58 | scaling_bases = [] |
| 52 | 59 | ||
| @@ -60,8 +67,8 @@ def gen_exp_data(exp_dirs, base_conf, col_map): | |||
| 60 | 67 | ||
| 61 | # Read and translate exp output files | 68 | # Read and translate exp output files |
| 62 | params = get_exp_params(data_dir, col_map) | 69 | params = get_exp_params(data_dir, col_map) |
| 63 | st_output = st.get_st_output(data_dir, tmp_dir) | 70 | st_output = st.get_st_output(data_dir, tmp_dir, force) |
| 64 | ft_output = ft.get_ft_output(data_dir, tmp_dir) | 71 | ft_output = ft.get_ft_output(data_dir, tmp_dir, force) |
| 65 | 72 | ||
| 66 | # Create experiment named after the data dir | 73 | # Create experiment named after the data dir |
| 67 | exp_data = ExpData(data_dir, params, DataFiles(ft_output, st_output)) | 74 | exp_data = ExpData(data_dir, params, DataFiles(ft_output, st_output)) |
| @@ -88,7 +95,7 @@ def main(): | |||
| 88 | 95 | ||
| 89 | col_map = ColMap() | 96 | col_map = ColMap() |
| 90 | 97 | ||
| 91 | (plain_exps, scaling_bases) = gen_exp_data(args, base_conf, col_map) | 98 | (plain_exps, scaling_bases) = gen_exp_data(args, base_conf, col_map, opts.force) |
| 92 | 99 | ||
| 93 | if base_conf and base_conf.keys()[0] not in col_map: | 100 | if base_conf and base_conf.keys()[0] not in col_map: |
| 94 | raise IOError("Base column '%s' not present in any parameters!" % | 101 | raise IOError("Base column '%s' not present in any parameters!" % |
| @@ -121,8 +128,15 @@ def main(): | |||
| 121 | 128 | ||
| 122 | result_table.add_exp(exp.params, result) | 129 | result_table.add_exp(exp.params, result) |
| 123 | 130 | ||
| 124 | print(result) | 131 | if opts.verbose: |
| 132 | print(result) | ||
| 125 | 133 | ||
| 134 | if opts.force and os.path.exists(opts.out_dir): | ||
| 135 | sh.rmtree(opts.out_dir) | ||
| 136 | |||
| 137 | # Remove un-plottable values | ||
| 138 | if opts.clean: | ||
| 139 | result_table.reduce() | ||
| 126 | 140 | ||
| 127 | result_table.write_result(opts.out_dir) | 141 | result_table.write_result(opts.out_dir) |
| 128 | 142 | ||
diff --git a/plot_exps.py b/plot_exps.py index e69de29..06f43b0 100644 --- a/plot_exps.py +++ b/plot_exps.py | |||
| @@ -0,0 +1,21 @@ | |||
| 1 | #!/usr/bin/env python | ||
| 2 | from __future__ import print_function | ||
| 3 | |||
| 4 | from optparse import OptionParser | ||
| 5 | |||
| 6 | def parse_args(): | ||
| 7 | parser = OptionParser("usage: %prog [options] [csv_dir]...") | ||
| 8 | |||
| 9 | parser.add_option('-o', '--out-dir', dest='out_dir', | ||
| 10 | help='directory for plot output', default='plot-data') | ||
| 11 | parser.add_option('-f', '--force', action='store_true', default=Fals | ||
