diff options
Diffstat (limited to 'parse_exps.py')
-rwxr-xr-x | parse_exps.py | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/parse_exps.py b/parse_exps.py index c254536..d07378c 100755 --- a/parse_exps.py +++ b/parse_exps.py | |||
@@ -1,7 +1,6 @@ | |||
1 | #!/usr/bin/env python | 1 | #!/usr/bin/env python |
2 | from __future__ import print_function | 2 | from __future__ import print_function |
3 | 3 | ||
4 | import config.config as conf | ||
5 | import os | 4 | import os |
6 | import parse.ft as ft | 5 | import parse.ft as ft |
7 | import parse.sched as st | 6 | import parse.sched as st |
@@ -12,6 +11,7 @@ import traceback | |||
12 | 11 | ||
13 | from collections import namedtuple | 12 | from collections import namedtuple |
14 | from common import load_params | 13 | from common import load_params |
14 | from config.config import DEFAULTS,PARAMS | ||
15 | from optparse import OptionParser | 15 | from optparse import OptionParser |
16 | from parse.point import ExpPoint | 16 | from parse.point import ExpPoint |
17 | from parse.tuple_table import TupleTable | 17 | from parse.tuple_table import TupleTable |
@@ -22,7 +22,8 @@ def parse_args(): | |||
22 | parser = OptionParser("usage: %prog [options] [data_dir]...") | 22 | parser = OptionParser("usage: %prog [options] [data_dir]...") |
23 | 23 | ||
24 | parser.add_option('-o', '--out', dest='out', | 24 | parser.add_option('-o', '--out', dest='out', |
25 | help='file or directory for data output', default='parse-data') | 25 | help='file or directory for data output', |
26 | default=DEFAULTS['out-parse']) | ||
26 | parser.add_option('-i', '--ignore', metavar='[PARAM...]', default="", | 27 | parser.add_option('-i', '--ignore', metavar='[PARAM...]', default="", |
27 | help='ignore changing parameter values') | 28 | help='ignore changing parameter values') |
28 | parser.add_option('-f', '--force', action='store_true', default=False, | 29 | parser.add_option('-f', '--force', action='store_true', default=False, |
@@ -41,7 +42,7 @@ def parse_args(): | |||
41 | ExpData = namedtuple('ExpData', ['path', 'params', 'work_dir']) | 42 | ExpData = namedtuple('ExpData', ['path', 'params', 'work_dir']) |
42 | 43 | ||
43 | def get_exp_params(data_dir, cm_builder): | 44 | def get_exp_params(data_dir, cm_builder): |
44 | param_file = "%s/%s" % (data_dir, conf.DEFAULTS['params_file']) | 45 | param_file = "%s/%s" % (data_dir, DEFAULTS['params_file']) |
45 | if os.path.isfile(param_file): | 46 | if os.path.isfile(param_file): |
46 | params = load_params(param_file) | 47 | params = load_params(param_file) |
47 | 48 | ||
@@ -53,8 +54,8 @@ def get_exp_params(data_dir, cm_builder): | |||
53 | params = {} | 54 | params = {} |
54 | 55 | ||
55 | # Cycles must be present for feather-trace measurement parsing | 56 | # Cycles must be present for feather-trace measurement parsing |
56 | if conf.PARAMS['cycles'] not in params: | 57 | if PARAMS['cycles'] not in params: |
57 | params[conf.PARAMS['cycles']] = conf.DEFAULTS['cycles'] | 58 | params[PARAMS['cycles']] = DEFAULTS['cycles'] |
58 | 59 | ||
59 | return params | 60 | return params |
60 | 61 | ||
@@ -101,7 +102,7 @@ def parse_exp(exp_force): | |||
101 | if not result: | 102 | if not result: |
102 | try: | 103 | try: |
103 | result = ExpPoint(exp.path) | 104 | result = ExpPoint(exp.path) |
104 | cycles = exp.params[conf.PARAMS['cycles']] | 105 | cycles = exp.params[PARAMS['cycles']] |
105 | 106 | ||
106 | # Write overheads into result | 107 | # Write overheads into result |
107 | ft.extract_ft_data(result, exp.path, exp.work_dir, cycles) | 108 | ft.extract_ft_data(result, exp.path, exp.work_dir, cycles) |
@@ -116,21 +117,31 @@ def parse_exp(exp_force): | |||
116 | 117 | ||
117 | return (exp, result) | 118 | return (exp, result) |
118 | 119 | ||
120 | def get_exps(args): | ||
121 | if args: | ||
122 | return args | ||
123 | elif os.path.exists(DEFAULTS['out-run']): | ||
124 | sys.stderr.write("Reading data from %s/*\n" % DEFAULTS['out-run']) | ||
125 | sched_dirs = os.listdir(DEFAULTS['out-run']) | ||
126 | return ['%s/%s' % (DEFAULTS['out-run'], d) for d in sched_dirs] | ||
127 | else: | ||
128 | sys.stderr.write("Reading data from current directory.\n") | ||
129 | return [os.getcwd()] | ||
130 | |||
119 | def main(): | 131 | def main(): |
120 | opts, args = parse_args() | 132 | opts, args = parse_args() |
121 | 133 | exp_dirs = get_exps(args) | |
122 | args = args or [os.getcwd()] | ||
123 | 134 | ||
124 | # Load exp parameters into a ColMap | 135 | # Load exp parameters into a ColMap |
125 | builder = ColMapBuilder() | 136 | builder = ColMapBuilder() |
126 | exps = load_exps(args, builder, opts.force) | 137 | exps = load_exps(exp_dirs, builder, opts.force) |
127 | 138 | ||
128 | # Don't track changes in ignored parameters | 139 | # Don't track changes in ignored parameters |
129 | if opts.ignore: | 140 | if opts.ignore: |
130 | for param in opts.ignore.split(","): | 141 | for param in opts.ignore.split(","): |
131 | builder.try_remove(param) | 142 | builder.try_remove(param) |
132 | # Always average multiple trials | 143 | # Always average multiple trials |
133 | builder.try_remove(conf.PARAMS['trial']) | 144 | builder.try_remove(PARAMS['trial']) |
134 | 145 | ||
135 | col_map = builder.build() | 146 | col_map = builder.build() |
136 | result_table = TupleTable(col_map) | 147 | result_table = TupleTable(col_map) |
@@ -175,7 +186,8 @@ def main(): | |||
175 | # No csvs to write, assume user meant to print out data | 186 | # No csvs to write, assume user meant to print out data |
176 | if dir_map.is_empty(): | 187 | if dir_map.is_empty(): |
177 | if not opts.verbose: | 188 | if not opts.verbose: |
178 | sys.stderr.write("Too little data to make csv files.\n") | 189 | sys.stderr.write("Too little data to make csv files, " + |
190 | "printing results.\n") | ||
179 | for key, exp in result_table: | 191 | for key, exp in result_table: |
180 | for e in exp: | 192 | for e in exp: |
181 | print(e) | 193 | print(e) |