diff options
Diffstat (limited to 'parse_exps.py')
| -rwxr-xr-x | parse_exps.py | 67 |
1 files changed, 56 insertions, 11 deletions
diff --git a/parse_exps.py b/parse_exps.py index ecb1cac..3a1d1b9 100755 --- a/parse_exps.py +++ b/parse_exps.py | |||
| @@ -2,9 +2,11 @@ | |||
| 2 | from __future__ import print_function | 2 | from __future__ import print_function |
| 3 | 3 | ||
| 4 | import config.config as conf | 4 | import config.config as conf |
| 5 | import copy | ||
| 5 | import os | 6 | import os |
| 6 | import parse.ft as ft | 7 | import parse.ft as ft |
| 7 | import parse.sched as st | 8 | import parse.sched as st |
| 9 | import re | ||
| 8 | 10 | ||
| 9 | from collections import namedtuple | 11 | from collections import namedtuple |
| 10 | from common import load_params | 12 | from common import load_params |
| @@ -17,6 +19,9 @@ def parse_args(): | |||
| 17 | 19 | ||
| 18 | parser.add_option('-o', '--out-dir', dest='out_dir', | 20 | parser.add_option('-o', '--out-dir', dest='out_dir', |
| 19 | help='directory for data output', default=os.getcwd()) | 21 | help='directory for data output', default=os.getcwd()) |
| 22 | parser.add_option('-s', '--scale-against', dest='scale_against', | ||
| 23 | metavar='PARAM=VALUE', default="", | ||
| 24 | help='calculate task scaling factors against these configs') | ||
| 20 | 25 | ||
| 21 | return parser.parse_args() | 26 | return parser.parse_args() |
| 22 | 27 | ||
| @@ -41,8 +46,10 @@ def get_exp_params(data_dir, col_map): | |||
| 41 | return params | 46 | return params |
| 42 | 47 | ||
| 43 | 48 | ||
| 44 | def gen_exp_data(exp_dirs, col_map): | 49 | def gen_exp_data(exp_dirs, base_conf, col_map): |
| 45 | exps = [] | 50 | plain_exps = [] |
| 51 | scaling_bases = [] | ||
| 52 | |||
| 46 | for data_dir in exp_dirs: | 53 | for data_dir in exp_dirs: |
| 47 | if not os.path.isdir(data_dir): | 54 | if not os.path.isdir(data_dir): |
| 48 | raise IOError("Invalid experiment '%s'" % os.path.abspath(data_dir)) | 55 | raise IOError("Invalid experiment '%s'" % os.path.abspath(data_dir)) |
| @@ -51,34 +58,72 @@ def gen_exp_data(exp_dirs, col_map): | |||
| 51 | if not os.path.exists(tmp_dir): | 58 | if not os.path.exists(tmp_dir): |
| 52 | os.mkdir(tmp_dir) | 59 | os.mkdir(tmp_dir) |
| 53 | 60 | ||
| 61 | # Read and translate exp output files | ||
| 54 | params = get_exp_params(data_dir, col_map) | 62 | params = get_exp_params(data_dir, col_map) |
| 55 | st_output = st.get_st_output(data_dir, tmp_dir) | 63 | st_output = st.get_st_output(data_dir, tmp_dir) |
| 56 | ft_output = ft.get_ft_output(data_dir, tmp_dir) | 64 | ft_output = ft.get_ft_output(data_dir, tmp_dir) |
| 57 | 65 | ||
| 66 | # Create experiment named after the data dir | ||
| 58 | exp_data = ExpData(data_dir, params, DataFiles(ft_output, st_output)) | 67 | exp_data = ExpData(data_dir, params, DataFiles(ft_output, st_output)) |
| 59 | exps += [exp_data] | ||
| 60 | 68 | ||
| 61 | return exps | 69 | if base_conf and base_conf.viewitems() & params.viewitems(): |
| 70 | if not st_output: | ||
| 71 | raise Exception("Scaling base '%s' useless without sched data!" | ||
| 72 | % data_dir) | ||
| 73 | params.pop(base_conf.keys()[0]) | ||
| 74 | scaling_bases += [exp_data] | ||
| 75 | else: | ||
| 76 | plain_exps += [exp_data] | ||
| 77 | |||
| 78 | return (plain_exps, scaling_bases) | ||
| 62 | 79 | ||
| 63 | def main(): | 80 | def main(): |
| 64 | opts, args = parse_args() | 81 | opts, args = parse_args() |
| 65 | 82 | ||
| 66 | args = args or [os.getcwd()] | 83 | args = args or [os.getcwd()] |
| 84 | |||
| 85 | # Configuration key for task systems used to calculate task | ||
| 86 | # execution scaling factors | ||
| 87 | base_conf = dict(re.findall("(.*)=(.*)", opts.scale_against)) | ||
| 88 | |||
| 67 | col_map = ColMap() | 89 | col_map = ColMap() |
| 68 | exps = gen_exp_data(args, col_map) | ||
| 69 | 90 | ||
| 70 | table = TupleTable(col_map) | 91 | (plain_exps, scaling_bases) = gen_exp_data(args, base_conf, col_map) |
| 92 | |||
| 93 | base_table = TupleTable(col_map) | ||
| 94 | result_table = TupleTable(col_map) | ||
| 71 | 95 | ||
| 72 | for exp in exps: | 96 | # Used to find matching scaling_base for each experiment |
| 97 | for base in scaling_bases: | ||
| 98 | base_table.add_exp(base.params, base) | ||
| 99 | |||
| 100 | for exp in plain_exps: | ||
| 73 | result = ExpPoint(exp.name) | 101 | result = ExpPoint(exp.name) |
| 102 | |||
| 74 | if exp.data_files.ft: | 103 | if exp.data_files.ft: |
| 75 | ft.get_ft_data(exp.data_files.ft, result, conf.BASE_EVENTS) | 104 | # Write overheads into result |
| 105 | ft.extract_ft_data(exp.data_files.ft, result, conf.BASE_EVENTS) | ||
| 106 | |||
| 76 | if exp.data_files.st: | 107 | if exp.data_files.st: |
| 77 | st.get_sched_data(exp.data_files.st, result) | 108 | if base_conf: |
| 109 | # Try to find a scaling base | ||
| 110 | base_params = copy.deepcopy(exp.params) | ||
| 111 | base_params.pop(base_conf.keys()[0]) | ||
| 112 | base = base_table.get_exps(base_params)[0] | ||
| 113 | if base: | ||
| 114 | # Write scaling factor (vs base) into result | ||
| 115 | st.extract_scaling_data(exp.data_files.st, | ||
| 116 | base.data_files.st, | ||
| 117 | result) | ||
| 118 | # Write deadline misses / tardiness into result | ||
| 119 | st.extract_sched_data(exp.data_files.st, result) | ||
| 120 | |||
| 121 | result_table.add_exp(exp.params, result) | ||
| 122 | |||
| 123 | print(result) | ||
| 78 | 124 | ||
| 79 | table.add_exp(exp.params, result) | ||
| 80 | 125 | ||
| 81 | table.write_result(opts.out_dir) | 126 | result_table.write_result(opts.out_dir) |
| 82 | 127 | ||
| 83 | if __name__ == '__main__': | 128 | if __name__ == '__main__': |
| 84 | main() | 129 | main() |
