aboutsummaryrefslogtreecommitdiffstats
path: root/parse_exps.py
diff options
context:
space:
mode:
authorJonathan Herman <hermanjl@cs.unc.edu>2013-04-21 13:28:38 -0400
committerJonathan Herman <hermanjl@cs.unc.edu>2013-04-21 13:28:38 -0400
commitfbd1df6f63eb551b99f71330d2370c570ff323f5 (patch)
treeca0db4599365bf8f4de7cd247c6363ef0ffba288 /parse_exps.py
parentdaa0e3a92e03a89baf7ea3750df374df79123245 (diff)
Scripts read directories created by other scripts if no arguments.
With no arguments, all scripts first try to load the current directory. If the current directory has no data, the scripts search for the output of the previous scripts in the toolchain, e.g. parse_exps.py loads run-data/*, created by run_exps.py. This commit also switched messages to stderr where they belong, and adds in missing lock and unlock overheads.
Diffstat (limited to 'parse_exps.py')
-rwxr-xr-xparse_exps.py34
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
2from __future__ import print_function 2from __future__ import print_function
3 3
4import config.config as conf
5import os 4import os
6import parse.ft as ft 5import parse.ft as ft
7import parse.sched as st 6import parse.sched as st
@@ -12,6 +11,7 @@ import traceback
12 11
13from collections import namedtuple 12from collections import namedtuple
14from common import load_params 13from common import load_params
14from config.config import DEFAULTS,PARAMS
15from optparse import OptionParser 15from optparse import OptionParser
16from parse.point import ExpPoint 16from parse.point import ExpPoint
17from parse.tuple_table import TupleTable 17from 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():
41ExpData = namedtuple('ExpData', ['path', 'params', 'work_dir']) 42ExpData = namedtuple('ExpData', ['path', 'params', 'work_dir'])
42 43
43def get_exp_params(data_dir, cm_builder): 44def 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
120def 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
119def main(): 131def 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)