diff options
| author | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-02-08 16:20:01 -0500 |
|---|---|---|
| committer | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-02-08 16:20:01 -0500 |
| commit | 7c647198fc40e72ef6ca23c2484bf49eba2079ee (patch) | |
| tree | 270de30a1cd896382a0954b2d8f7994ca84f88b7 /parse_exps.py | |
| parent | d312e270ed5c2926c8651291a4026062213876f8 (diff) | |
Added translation from DirMap to ReducedTupleTable.
Diffstat (limited to 'parse_exps.py')
| -rwxr-xr-x | parse_exps.py | 42 |
1 files changed, 29 insertions, 13 deletions
diff --git a/parse_exps.py b/parse_exps.py index 1bd3d48..c2376de 100755 --- a/parse_exps.py +++ b/parse_exps.py | |||
| @@ -5,14 +5,16 @@ import config.config as conf | |||
| 5 | import os | 5 | import os |
| 6 | import parse.ft as ft | 6 | import parse.ft as ft |
| 7 | import parse.sched as st | 7 | import parse.sched as st |
| 8 | import pickle | ||
| 8 | import shutil as sh | 9 | import shutil as sh |
| 9 | import sys | 10 | import sys |
| 10 | 11 | ||
| 11 | from collections import namedtuple | 12 | from collections import namedtuple |
| 12 | from common import load_params | 13 | from common import load_params |
| 13 | from optparse import OptionParser | 14 | from optparse import OptionParser |
| 15 | from parse.dir_map import DirMap | ||
| 14 | from parse.point import ExpPoint | 16 | from parse.point import ExpPoint |
| 15 | from parse.tuple_table import TupleTable | 17 | from parse.tuple_table import TupleTable,ReducedTupleTable |
| 16 | from parse.col_map import ColMapBuilder | 18 | from parse.col_map import ColMapBuilder |
| 17 | 19 | ||
| 18 | 20 | ||
| @@ -83,6 +85,29 @@ def load_exps(exp_dirs, cm_builder, clean): | |||
| 83 | 85 | ||
| 84 | return exps | 86 | return exps |
| 85 | 87 | ||
| 88 | def parse_exp(exp, force): | ||
| 89 | result_file = exp.work_dir + "/exp_point.pkl" | ||
| 90 | should_load = not force and os.path.exists(result_file) | ||
| 91 | mode = 'r' if should_load else 'w' | ||
| 92 | |||
| 93 | with open(result_file, mode + 'b') as f: | ||
| 94 | if should_load: | ||
| 95 | # No need to go through this work twice | ||
| 96 | result = pickle.load(f) | ||
| 97 | else: | ||
| 98 | result = ExpPoint(exp.path) | ||
| 99 | cycles = exp.params[conf.PARAMS['cycles']] | ||
| 100 | |||
| 101 | # Write overheads into result | ||
| 102 | ft.extract_ft_data(result, exp.path, exp.work_dir, cycles) | ||
| 103 | |||
| 104 | # Write scheduling statistics into result | ||
| 105 | st.extract_sched_data(result, exp.path, exp.work_dir) | ||
| 106 | |||
| 107 | pickle.dump(result, f) | ||
| 108 | |||
| 109 | return result | ||
| 110 | |||
| 86 | def main(): | 111 | def main(): |
| 87 | opts, args = parse_args() | 112 | opts, args = parse_args() |
| 88 | 113 | ||
| @@ -102,28 +127,19 @@ def main(): | |||
| 102 | 127 | ||
| 103 | sys.stderr.write("Parsing data...\n") | 128 | sys.stderr.write("Parsing data...\n") |
| 104 | for i,exp in enumerate(exps): | 129 | for i,exp in enumerate(exps): |
| 105 | result = ExpPoint(exp.path) | 130 | result = parse_exp(exp, opts.force) |
| 106 | cycles = exp.params[conf.PARAMS['cycles']] | ||
| 107 | |||
| 108 | # Write overheads into result | ||
| 109 | ft.extract_ft_data(result, exp.path, exp.work_dir, cycles) | ||
| 110 | |||
| 111 | # Write scheduling statistics into result | ||
| 112 | st.extract_sched_data(result, exp.path, exp.work_dir) | ||
| 113 | |||
| 114 | if opts.verbose: | 131 | if opts.verbose: |
| 115 | print(result) | 132 | print(result) |
| 116 | else: | 133 | else: |
| 117 | sys.stderr.write('\r {0:.2%}'.format(float(i)/len(exps))) | 134 | sys.stderr.write('\r {0:.2%}'.format(float(i)/len(exps))) |
| 118 | 135 | result_table[exp.params] += [result] | |
| 119 | result_table.add_exp(exp.params, result) | ||
| 120 | 136 | ||
| 121 | sys.stderr.write('\n') | 137 | sys.stderr.write('\n') |
| 122 | 138 | ||
| 123 | if opts.force and os.path.exists(opts.out): | 139 | if opts.force and os.path.exists(opts.out): |
| 124 | sh.rmtree(opts.out) | 140 | sh.rmtree(opts.out) |
| 125 | 141 | ||
| 126 | result_table.reduce() | 142 | result_table = result_table.reduce() |
| 127 | 143 | ||
| 128 | sys.stderr.write("Writing result...\n") | 144 | sys.stderr.write("Writing result...\n") |
| 129 | if opts.write_map: | 145 | if opts.write_map: |
