aboutsummaryrefslogtreecommitdiffstats
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
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.
-rw-r--r--config/config.py7
-rwxr-xr-xgen_exps.py11
-rwxr-xr-xparse_exps.py34
-rwxr-xr-xplot_exps.py21
-rwxr-xr-xrun_exps.py73
5 files changed, 102 insertions, 44 deletions
diff --git a/config/config.py b/config/config.py
index cbac6b2..1ac468b 100644
--- a/config/config.py
+++ b/config/config.py
@@ -39,13 +39,18 @@ DEFAULTS = {'params_file' : 'params.py',
39 'sched_file' : 'sched.py', 39 'sched_file' : 'sched.py',
40 'duration' : 10, 40 'duration' : 10,
41 'prog' : 'rtspin', 41 'prog' : 'rtspin',
42 'out-gen' : 'exps',
43 'out-run' : 'run-data',
44 'out-parse' : 'parse-data',
45 'out-plot' : 'plot-data',
42 'cycles' : ft_freq() or 2000} 46 'cycles' : ft_freq() or 2000}
43 47
48
44'''Default sched_trace events (this is all of them).''' 49'''Default sched_trace events (this is all of them).'''
45SCHED_EVENTS = range(501, 513) 50SCHED_EVENTS = range(501, 513)
46 51
47'''Overhead events.''' 52'''Overhead events.'''
48OVH_BASE_EVENTS = ['SCHED', 'RELEASE', 'SCHED2', 'TICK', 'CXS'] 53OVH_BASE_EVENTS = ['SCHED', 'RELEASE', 'SCHED2', 'TICK', 'CXS', 'LOCK', 'UNLOCK']
49OVH_ALL_EVENTS = ["%s_%s" % (e, t) for (e,t) in 54OVH_ALL_EVENTS = ["%s_%s" % (e, t) for (e,t) in
50 itertools.product(OVH_BASE_EVENTS, ["START","END"])] 55 itertools.product(OVH_BASE_EVENTS, ["START","END"])]
51OVH_ALL_EVENTS += ['RELEASE_LATENCY'] 56OVH_ALL_EVENTS += ['RELEASE_LATENCY']
diff --git a/gen_exps.py b/gen_exps.py
index 6488cdc..b847661 100755
--- a/gen_exps.py
+++ b/gen_exps.py
@@ -7,6 +7,7 @@ import re
7import shutil as sh 7import shutil as sh
8import sys 8import sys
9 9
10from config.config import DEFAULTS
10from optparse import OptionParser 11from optparse import OptionParser
11 12
12def parse_args(): 13def parse_args():
@@ -15,7 +16,7 @@ def parse_args():
15 16
16 parser.add_option('-o', '--out-dir', dest='out_dir', 17 parser.add_option('-o', '--out-dir', dest='out_dir',
17 help='directory for data output', 18 help='directory for data output',
18 default=("%s/exps"%os.getcwd())) 19 default=("%s/%s"% (os.getcwd(), DEFAULTS['out-gen'])))
19 parser.add_option('-f', '--force', action='store_true', default=False, 20 parser.add_option('-f', '--force', action='store_true', default=False,
20 dest='force', help='overwrite existing data') 21 dest='force', help='overwrite existing data')
21 parser.add_option('-n', '--num-trials', default=1, type='int', dest='trials', 22 parser.add_option('-n', '--num-trials', default=1, type='int', dest='trials',
@@ -51,9 +52,9 @@ def main():
51 if opts.described != None: 52 if opts.described != None:
52 for generator in opts.described.split(','): 53 for generator in opts.described.split(','):
53 if generator not in gen.get_generators(): 54 if generator not in gen.get_generators():
54 print("No generator '%s'" % generator) 55 sys.stderr.write("No generator '%s'\n" % generator)
55 else: 56 else:
56 sys.stdout.write("Generator '%s', " % generator) 57 print("Generator '%s', " % generator)
57 gen.get_generators()[generator]().print_help() 58 gen.get_generators()[generator]().print_help()
58 if opts.list_gens or opts.described: 59 if opts.list_gens or opts.described:
59 return 0 60 return 0
@@ -85,7 +86,7 @@ def main():
85 if gen_name not in gen.get_generators(): 86 if gen_name not in gen.get_generators():
86 raise ValueError("Invalid generator '%s'" % gen_name) 87 raise ValueError("Invalid generator '%s'" % gen_name)
87 88
88 print("Creating experiments using %s generator..." % gen_name) 89 sys.stderr.write("Creating experiments with %s generator...\n" % gen_name)
89 90
90 params = dict(gen_params.items() + global_params.items()) 91 params = dict(gen_params.items() + global_params.items())
91 clazz = gen.get_generators()[gen_name] 92 clazz = gen.get_generators()[gen_name]
@@ -94,5 +95,7 @@ def main():
94 95
95 generator.create_exps(opts.out_dir, opts.force, opts.trials) 96 generator.create_exps(opts.out_dir, opts.force, opts.trials)
96 97
98 sys.stderr.write("Experiments saved in %s.\n" % opts.out_dir)
99
97if __name__ == '__main__': 100if __name__ == '__main__':
98 main() 101 main()
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: