aboutsummaryrefslogtreecommitdiffstats
path: root/parse_exps.py
diff options
context:
space:
mode:
Diffstat (limited to 'parse_exps.py')
-rwxr-xr-xparse_exps.py53
1 files changed, 40 insertions, 13 deletions
diff --git a/parse_exps.py b/parse_exps.py
index 2d1c370..87d0783 100755
--- a/parse_exps.py
+++ b/parse_exps.py
@@ -8,6 +8,7 @@ import parse.ft as ft
8import parse.sched as st 8import parse.sched as st
9import re 9import re
10import shutil as sh 10import shutil as sh
11import sys
11 12
12from collections import namedtuple 13from collections import namedtuple
13from common import load_params 14from common import load_params
@@ -16,18 +17,20 @@ from parse.point import ExpPoint
16from parse.tuple_table import ColMap,TupleTable 17from parse.tuple_table import ColMap,TupleTable
17 18
18def parse_args(): 19def parse_args():
19 # TODO: convert data-dir to proper option 20 # TODO: convert data-dir to proper option, clean 'dest' options
20 parser = OptionParser("usage: %prog [options] [data_dir]...") 21 parser = OptionParser("usage: %prog [options] [data_dir]...")
21 22
22 parser.add_option('-o', '--out', dest='out', 23 parser.add_option('-o', '--out', dest='out',
23 help='file or directory for data output', default='parse-data') 24 help='file or directory for data output', default='parse-data')
24 25
25 # TODO: this means nothing 26 # TODO: this means nothing, also remove dests
26 parser.add_option('-c', '--clean', action='store_true', default=False, 27 parser.add_option('-c', '--clean', action='store_true', default=False,
27 dest='clean', help='do not output single-point csvs') 28 dest='clean', help='do not output single-point csvs')
28 parser.add_option('-s', '--scale-against', dest='scale_against', 29 parser.add_option('-s', '--scale-against', dest='scale_against',
29 metavar='PARAM=VALUE', default="", 30 metavar='PARAM=VALUE', default="",
30 help='calculate task scaling factors against these configs') 31 help='calculate task scaling factors against these configs')
32 parser.add_option('-i', '--ignore', metavar='[PARAM...]', default="",
33 help='ignore changing parameter values')
31 parser.add_option('-f', '--force', action='store_true', default=False, 34 parser.add_option('-f', '--force', action='store_true', default=False,
32 dest='force', help='overwrite existing data') 35 dest='force', help='overwrite existing data')
33 parser.add_option('-v', '--verbose', action='store_true', default=False, 36 parser.add_option('-v', '--verbose', action='store_true', default=False,
@@ -38,7 +41,7 @@ def parse_args():
38 41
39 return parser.parse_args() 42 return parser.parse_args()
40 43
41ExpData = namedtuple('ExpData', ['name', 'params', 'data_files']) 44ExpData = namedtuple('ExpData', ['name', 'params', 'data_files', 'is_base'])
42DataFiles = namedtuple('DataFiles', ['ft','st']) 45DataFiles = namedtuple('DataFiles', ['ft','st'])
43 46
44def get_exp_params(data_dir, col_map): 47def get_exp_params(data_dir, col_map):
@@ -63,7 +66,9 @@ def gen_exp_data(exp_dirs, base_conf, col_map, force):
63 plain_exps = [] 66 plain_exps = []
64 scaling_bases = [] 67 scaling_bases = []
65 68
66 for data_dir in exp_dirs: 69 sys.stderr.write("Generating data...\n")
70
71 for i, data_dir in enumerate(exp_dirs):
67 if not os.path.isdir(data_dir): 72 if not os.path.isdir(data_dir):
68 raise IOError("Invalid experiment '%s'" % os.path.abspath(data_dir)) 73 raise IOError("Invalid experiment '%s'" % os.path.abspath(data_dir))
69 74
@@ -76,18 +81,30 @@ def gen_exp_data(exp_dirs, base_conf, col_map, force):
76 st_output = st.get_st_output(data_dir, tmp_dir, force) 81 st_output = st.get_st_output(data_dir, tmp_dir, force)
77 ft_output = ft.get_ft_output(data_dir, tmp_dir, force) 82 ft_output = ft.get_ft_output(data_dir, tmp_dir, force)
78 83
79 # Create experiment named after the data dir
80 exp_data = ExpData(data_dir, params, DataFiles(ft_output, st_output))
81 84
82 if base_conf and base_conf.viewitems() & params.viewitems(): 85 if base_conf and base_conf.viewitems() & params.viewitems():
83 if not st_output: 86 if not st_output:
84 raise Exception("Scaling base '%s' useless without sched data!" 87 raise Exception("Scaling base '%s' useless without sched data!"
85 % data_dir) 88 % data_dir)
86 params.pop(base_conf.keys()[0]) 89 is_base = True
87 scaling_bases += [exp_data] 90
91 base_params = copy.deepcopy(params)
92 base_params.pop(base_conf.keys()[0])
93
94 base_exp = ExpData(data_dir, base_params,
95 DataFiles(ft_output, st_output), True)
96 scaling_bases += [base_exp]
88 else: 97 else:
89 plain_exps += [exp_data] 98 is_base = False
90 99
100 # Create experiment named after the data dir
101 exp_data = ExpData(data_dir, params,
102 DataFiles(ft_output, st_output), is_base)
103
104 plain_exps += [exp_data]
105
106 sys.stderr.write('\r {0:.2%}'.format(float(i)/len(exp_dirs)))
107 sys.stderr.write('\n')
91 return (plain_exps, scaling_bases) 108 return (plain_exps, scaling_bases)
92 109
93def main(): 110def main():
@@ -107,14 +124,20 @@ def main():
107 raise IOError("Base column '%s' not present in any parameters!" % 124 raise IOError("Base column '%s' not present in any parameters!" %
108 base_conf.keys()[0]) 125 base_conf.keys()[0])
109 126
110 base_table = TupleTable(col_map) # For tracking 'base' experiments 127 base_map = copy.deepcopy(col_map)
111 result_table = TupleTable(col_map) # For generating csv directories 128 if opts.ignore:
129 for param in opts.ignore.split(","):
130 col_map.try_remove(param)
131
132 base_table = TupleTable(base_map) # For tracking 'base' experiments
133 result_table = TupleTable(col_map) # For generating output
112 134
113 # Used to find matching scaling_base for each experiment 135 # Used to find matching scaling_base for each experiment
114 for base in scaling_bases: 136 for base in scaling_bases:
115 base_table.add_exp(base.params, base) 137 base_table.add_exp(base.params, base)
116 138
117 for exp in plain_exps: 139 sys.stderr.write("Parsing data...\n")
140 for i,exp in enumerate(plain_exps):
118 result = ExpPoint(exp.name) 141 result = ExpPoint(exp.name)
119 142
120 if exp.data_files.ft: 143 if exp.data_files.ft:
@@ -123,7 +146,7 @@ def main():
123 146
124 if exp.data_files.st: 147 if exp.data_files.st:
125 base = None 148 base = None
126 if base_conf: 149 if base_conf and not exp.is_base:
127 # Try to find a scaling base 150 # Try to find a scaling base
128 base_params = copy.deepcopy(exp.params) 151 base_params = copy.deepcopy(exp.params)
129 base_params.pop(base_conf.keys()[0]) 152 base_params.pop(base_conf.keys()[0])
@@ -137,12 +160,16 @@ def main():
137 160
138 if opts.verbose: 161 if opts.verbose:
139 print(result) 162 print(result)
163 else:
164 sys.stderr.write('\r {0:.2%}'.format(float(i)/len(plain_exps)))
165 sys.stderr.write('\n')
140 166
141 if opts.force and os.path.exists(opts.out): 167 if opts.force and os.path.exists(opts.out):
142 sh.rmtree(opts.out) 168 sh.rmtree(opts.out)
143 169
144 result_table.reduce() 170 result_table.reduce()
145 171
172 sys.stderr.write("Writing result...\n")
146 if opts.write_map: 173 if opts.write_map:
147 # Write summarized results into map 174 # Write summarized results into map
148 result_table.write_map(opts.out) 175 result_table.write_map(opts.out)