diff options
| author | Jonathan Herman <hermanjl@cs.unc.edu> | 2012-09-28 11:17:43 -0400 |
|---|---|---|
| committer | Jonathan Herman <hermanjl@cs.unc.edu> | 2012-09-28 11:17:43 -0400 |
| commit | 0ff824061ff5a58d25e64453dd0abc800d8db933 (patch) | |
| tree | 5878c51a32cb89e38bade37202bf007b1b603c9b | |
| parent | 7c09ec981c6e06af2e62d67a609eb53728267954 (diff) | |
Experiments can specify a required kernel name for running.
| -rw-r--r-- | config/config.example.py | 5 | ||||
| -rw-r--r-- | experiment/litmus_util.py | 3 | ||||
| -rwxr-xr-x | run_exps.py | 21 |
3 files changed, 24 insertions, 5 deletions
diff --git a/config/config.example.py b/config/config.example.py index 9675f66..785977b 100644 --- a/config/config.example.py +++ b/config/config.example.py | |||
| @@ -36,8 +36,9 @@ FILES = {'ft_data' : 'ft.bin', | |||
| 36 | 'sched_data' : 'st-{}.bin', | 36 | 'sched_data' : 'st-{}.bin', |
| 37 | 'log_data' : 'trace.slog',} | 37 | 'log_data' : 'trace.slog',} |
| 38 | 38 | ||
| 39 | PARAMS = {'sched' : 'scheduler', | 39 | PARAMS = {'sched' : 'scheduler', |
| 40 | 'dur' : 'duration'} | 40 | 'dur' : 'duration', |
| 41 | 'kernel' : 'uname'} | ||
| 41 | 42 | ||
| 42 | SCHED_EVENTS = range(501, 513) | 43 | SCHED_EVENTS = range(501, 513) |
| 43 | BASE_EVENTS = ['SCHED', 'RELEASE', 'SCHED2', 'TICK', 'CXS'] | 44 | BASE_EVENTS = ['SCHED', 'RELEASE', 'SCHED2', 'TICK', 'CXS'] |
diff --git a/experiment/litmus_util.py b/experiment/litmus_util.py index 114f4c9..cde0bca 100644 --- a/experiment/litmus_util.py +++ b/experiment/litmus_util.py | |||
| @@ -39,6 +39,9 @@ def switch_scheduler(switch_to_in): | |||
| 39 | if switch_to != cur_plugin: | 39 | if switch_to != cur_plugin: |
| 40 | raise Exception("Could not switch to plugin: %s" % switch_to) | 40 | raise Exception("Could not switch to plugin: %s" % switch_to) |
| 41 | 41 | ||
| 42 | def uname_matches(reg): | ||
| 43 | data = subprocess.check_output(["uname", "-r"]) | ||
| 44 | return bool( re.match(reg, data) ) | ||
| 42 | 45 | ||
| 43 | def is_executable(fname): | 46 | def is_executable(fname): |
| 44 | """Return whether the file passed in is executable""" | 47 | """Return whether the file passed in is executable""" |
diff --git a/run_exps.py b/run_exps.py index d2606f8..bda0e40 100755 --- a/run_exps.py +++ b/run_exps.py | |||
| @@ -13,6 +13,9 @@ from experiment.executable.executable import Executable | |||
| 13 | from experiment.experiment import Experiment,ExperimentDone | 13 | from experiment.experiment import Experiment,ExperimentDone |
| 14 | from experiment.proc_entry import ProcEntry | 14 | from experiment.proc_entry import ProcEntry |
| 15 | 15 | ||
| 16 | def InvalidKernel(Exception): | ||
| 17 | def __init__(self, kernel): | ||
| 18 | self.kernel = kernel | ||
| 16 | 19 | ||
| 17 | def parse_args(): | 20 | def parse_args(): |
| 18 | parser = OptionParser("usage: %prog [options] [sched_file]... [exp_dir]...]") | 21 | parser = OptionParser("usage: %prog [options] [sched_file]... [exp_dir]...]") |
| @@ -83,6 +86,7 @@ def load_experiment(sched_file, scheduler, duration, param_file, out_base): | |||
| 83 | dirname = os.path.split(sched_file)[0] | 86 | dirname = os.path.split(sched_file)[0] |
| 84 | 87 | ||
| 85 | params = {} | 88 | params = {} |
| 89 | kernel = "" | ||
| 86 | 90 | ||
| 87 | if not scheduler or not duration: | 91 | if not scheduler or not duration: |
| 88 | param_file = param_file or \ | 92 | param_file = param_file or \ |
| @@ -93,6 +97,10 @@ def load_experiment(sched_file, scheduler, duration, param_file, out_base): | |||
| 93 | scheduler = scheduler or params[conf.PARAMS['sched']] | 97 | scheduler = scheduler or params[conf.PARAMS['sched']] |
| 94 | duration = duration or params[conf.PARAMS['dur']] | 98 | duration = duration or params[conf.PARAMS['dur']] |
| 95 | 99 | ||
| 100 | # Experiments can specify required kernel name | ||
| 101 | if conf.PARAMS['kernel'] in params: | ||
| 102 | kernel = params[conf.PARAMS['kernel']] | ||
| 103 | |||
| 96 | duration = duration or conf.DEFAULTS['duration'] | 104 | duration = duration or conf.DEFAULTS['duration'] |
| 97 | 105 | ||
| 98 | if not scheduler: | 106 | if not scheduler: |
| @@ -102,7 +110,7 @@ def load_experiment(sched_file, scheduler, duration, param_file, out_base): | |||
| 102 | schedule = load_schedule(sched_file) | 110 | schedule = load_schedule(sched_file) |
| 103 | (work_dir, out_dir) = get_dirs(sched_file, out_base) | 111 | (work_dir, out_dir) = get_dirs(sched_file, out_base) |
| 104 | 112 | ||
| 105 | run_exp(sched_file, schedule, scheduler, duration, work_dir, out_dir) | 113 | run_exp(sched_file, schedule, scheduler, kernel, duration, work_dir, out_dir) |
| 106 | 114 | ||
| 107 | # Save parameters used to run experiment in out_dir | 115 | # Save parameters used to run experiment in out_dir |
| 108 | out_params = dict(params.items() + | 116 | out_params = dict(params.items() + |
| @@ -121,10 +129,13 @@ def load_schedule(fname): | |||
| 121 | return schedule | 129 | return schedule |
| 122 | 130 | ||
| 123 | 131 | ||
| 124 | def run_exp(name, schedule, scheduler, duration, work_dir, out_dir): | 132 | def run_exp(name, schedule, scheduler, kernel, duration, work_dir, out_dir): |
| 125 | proc_entries = [] | 133 | proc_entries = [] |
| 126 | executables = [] | 134 | executables = [] |
| 127 | 135 | ||
| 136 | if kernel and not lu.uname_matches(kernel): | ||
| 137 | raise InvalidKernel(kernel) | ||
| 138 | |||
| 128 | # Parse values for proc entries | 139 | # Parse values for proc entries |
| 129 | for entry_conf in schedule['proc']: | 140 | for entry_conf in schedule['proc']: |
| 130 | path = entry_conf[0] | 141 | path = entry_conf[0] |
| @@ -178,6 +189,7 @@ def main(): | |||
| 178 | done = 0 | 189 | done = 0 |
| 179 | succ = 0 | 190 | succ = 0 |
| 180 | failed = 0 | 191 | failed = 0 |
| 192 | invalid = 0 | ||
| 181 | 193 | ||
| 182 | for exp in args: | 194 | for exp in args: |
| 183 | path = "%s/%s" % (os.getcwd(), exp) | 195 | path = "%s/%s" % (os.getcwd(), exp) |
| @@ -194,6 +206,8 @@ def main(): | |||
| 194 | except ExperimentDone: | 206 | except ExperimentDone: |
| 195 | done += 1 | 207 | done += 1 |
| 196 | print("Experiment '%s' already completed at '%s'" % (exp, out_base)) | 208 | print("Experiment '%s' already completed at '%s'" % (exp, out_base)) |
| 209 | except InvalidKernel: | ||
| 210 | invalid += 1 | ||
| 197 | except: | 211 | except: |
| 198 | print("Failed experiment %s" % exp) | 212 | print("Failed experiment %s" % exp) |
| 199 | traceback.print_exc() | 213 | traceback.print_exc() |
| @@ -203,7 +217,8 @@ def main(): | |||
| 203 | print("Experiments run:\t%d" % len(args)) | 217 | print("Experiments run:\t%d" % len(args)) |
| 204 | print(" Successful:\t\t%d" % succ) | 218 | print(" Successful:\t\t%d" % succ) |
| 205 | print(" Failed:\t\t%d" % failed) | 219 | print(" Failed:\t\t%d" % failed) |
| 206 | print(" Skipped:\t\t%d" % done) | 220 | print(" Already Done:\t\t%d" % done) |
| 221 | print(" Invalid Kernel:\t\t%d" % invalid) | ||
| 207 | 222 | ||
| 208 | 223 | ||
| 209 | if __name__ == '__main__': | 224 | if __name__ == '__main__': |
