diff options
| author | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-02-17 15:02:15 -0500 |
|---|---|---|
| committer | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-02-17 15:02:15 -0500 |
| commit | 649b64013619f67160fd289b208189b88e6196fa (patch) | |
| tree | 4198c160a8ff83f0976e8e125c0d796db19985fb | |
| parent | ea121dd26076998ffdc89792f62da5d585a1f35c (diff) | |
Save feather-trace timer frequency, not CPU frequency, with each experiment.
| -rw-r--r-- | common.py | 6 | ||||
| -rw-r--r-- | config/config.py | 15 | ||||
| -rw-r--r-- | run/litmus_util.py | 32 | ||||
| -rwxr-xr-x | run_exps.py | 18 |
4 files changed, 44 insertions, 27 deletions
| @@ -33,12 +33,14 @@ def get_executable(prog, hint, optional=False): | |||
| 33 | def get_config_option(option): | 33 | def get_config_option(option): |
| 34 | '''Search for @option in installed kernel config (if present). | 34 | '''Search for @option in installed kernel config (if present). |
| 35 | Raise an IOError if the kernel config isn't found in /boot/.''' | 35 | Raise an IOError if the kernel config isn't found in /boot/.''' |
| 36 | uname = subprocess.check_output(["uname", "-r"])[-1] | 36 | uname = subprocess.check_output(["uname", "-r"]).strip() |
| 37 | fname = "/boot/config-%s" % uname | 37 | fname = "/boot/config-%s" % uname |
| 38 | 38 | ||
| 39 | if os.path.exists(fname): | 39 | if os.path.exists(fname): |
| 40 | config_regex = "^CONFIG_{}=(?P<val>.*)$".format(option) | 40 | config_regex = "^CONFIG_{}=(?P<val>.*)$".format(option) |
| 41 | match = re.search(config_regex, open(fname, 'r').read()) | 41 | with open(fname, 'r') as f: |
| 42 | data = f.read() | ||
| 43 | match = re.search(config_regex, data, re.M) | ||
| 42 | if not match: | 44 | if not match: |
| 43 | return None | 45 | return None |
| 44 | else: | 46 | else: |
diff --git a/config/config.py b/config/config.py index d463999..31ef7c7 100644 --- a/config/config.py +++ b/config/config.py | |||
| @@ -10,7 +10,7 @@ BINS = {'rtspin' : get_executable('rtspin', 'liblitmus'), | |||
| 10 | 'ftsort' : get_executable('ftsort', 'feather-trace-tools'), | 10 | 'ftsort' : get_executable('ftsort', 'feather-trace-tools'), |
| 11 | 'st_trace' : get_executable('st_trace', 'feather-trace-tools'), | 11 | 'st_trace' : get_executable('st_trace', 'feather-trace-tools'), |
| 12 | 'trace-cmd' : get_executable('trace-cmd', 'rt-kernelshark'), | 12 | 'trace-cmd' : get_executable('trace-cmd', 'rt-kernelshark'), |
| 13 | # Optional, as sched_trace is not a publically supported repository | 13 | # Optional, as sched_trace is not a publically supported repository |
| 14 | 'st_show' : get_executable('st_show', 'sched_trace', True)} | 14 | 'st_show' : get_executable('st_show', 'sched_trace', True)} |
| 15 | 15 | ||
| 16 | '''Names of output files.''' | 16 | '''Names of output files.''' |
| @@ -20,19 +20,18 @@ FILES = {'ft_data' : 'ft.bin', | |||
| 20 | 'log_data' : 'trace.slog'} | 20 | 'log_data' : 'trace.slog'} |
| 21 | 21 | ||
| 22 | '''Default parameter names in params.py.''' | 22 | '''Default parameter names in params.py.''' |
| 23 | # TODO: add check for config options | 23 | PARAMS = {'sched' : 'scheduler', # Scheduler used by run_exps |
| 24 | PARAMS = {'sched' : 'scheduler', # Scheduler used by run_exps | 24 | 'dur' : 'duration', # Duration of tests in run_exps |
| 25 | 'dur' : 'duration', # Duration of tests in run_exps | 25 | 'kernel' : 'uname', # Regex of required OS name in run_exps |
| 26 | 'kernel' : 'uname', # Regex of required OS name in run_exps | 26 | 'cycles' : 'clock-frequency', # Frequency run_exps was run with |
| 27 | 'cycles' : 'cpu-frequency', # Frequency run_exps was run with | 27 | 'tasks' : 'tasks' # Number of tasks |
| 28 | 'tasks' : 'tasks' # Number of tasks | ||
| 29 | } | 28 | } |
| 30 | 29 | ||
| 31 | '''Default values for program options.''' | 30 | '''Default values for program options.''' |
| 32 | DEFAULTS = {'params_file' : 'params.py', | 31 | DEFAULTS = {'params_file' : 'params.py', |
| 33 | 'sched_file' : 'sched.py', | 32 | 'sched_file' : 'sched.py', |
| 34 | 'duration' : 10, | 33 | 'duration' : 10, |
| 35 | 'spin' : 'rtspin', | 34 | 'spin' : 'rtspin', |
| 36 | 'cycles' : 2000} | 35 | 'cycles' : 2000} |
| 37 | 36 | ||
| 38 | '''Default sched_trace events (this is all of them).''' | 37 | '''Default sched_trace events (this is all of them).''' |
diff --git a/run/litmus_util.py b/run/litmus_util.py index 340113d..ec1700e 100644 --- a/run/litmus_util.py +++ b/run/litmus_util.py | |||
| @@ -4,6 +4,7 @@ import subprocess | |||
| 4 | import os | 4 | import os |
| 5 | import stat | 5 | import stat |
| 6 | import config.config as conf | 6 | import config.config as conf |
| 7 | from common import get_config_option | ||
| 7 | 8 | ||
| 8 | def num_cpus(): | 9 | def num_cpus(): |
| 9 | '''Return the number of CPUs in the system.''' | 10 | '''Return the number of CPUs in the system.''' |
| @@ -17,18 +18,25 @@ def num_cpus(): | |||
| 17 | cpus += 1 | 18 | cpus += 1 |
| 18 | return cpus | 19 | return cpus |
| 19 | 20 | ||
| 20 | def cpu_freq(): | 21 | def ft_freq(): |
| 21 | ''' | 22 | '''The frequency (in MHz) of the clock used by feather trace.''' |
| 22 | The frequency (in MHz) of the CPU. | 23 | if get_config_option('CPU_V7') == 'y': |
| 23 | ''' | 24 | # Arm V7s use a millisecond timer |
| 24 | reg = re.compile(r'^cpu MHz\s*:\s*(\d+)', re.M) | 25 | freq = 1000.0 |
| 25 | with open('/proc/cpuinfo', 'r') as f: | 26 | elif get_config_option('X86') == 'y': |
| 26 | data = f.read() | 27 | # X86 timer is equal to processor clock |
| 27 | 28 | reg = re.compile(r'^cpu MHz\s*:\s*(?P<FREQ>\d+)', re.M) | |
| 28 | match = re.search(reg, data) | 29 | with open('/proc/cpuinfo', 'r') as f: |
| 29 | if not match: | 30 | data = f.read() |
| 30 | raise Exception("Cannot parse CPU frequency!") | 31 | |
| 31 | return int(match.group(1)) | 32 | match = re.search(reg, data) |
| 33 | if not match: | ||
| 34 | raise Exception("Cannot parse CPU frequency from x86 CPU!") | ||
| 35 | freq = int(match.group('FREQ')) | ||
| 36 | else: | ||
| 37 | # You're on your own | ||
| 38 | freq = 0 | ||
| 39 | return freq | ||
| 32 | 40 | ||
| 33 | def switch_scheduler(switch_to_in): | 41 | def switch_scheduler(switch_to_in): |
| 34 | '''Switch the scheduler to whatever is passed in. | 42 | '''Switch the scheduler to whatever is passed in. |
diff --git a/run_exps.py b/run_exps.py index 8fd9ed2..d1e0026 100755 --- a/run_exps.py +++ b/run_exps.py | |||
| @@ -14,9 +14,13 @@ from run.executable.executable import Executable | |||
| 14 | from run.experiment import Experiment,ExperimentDone | 14 | from run.experiment import Experiment,ExperimentDone |
| 15 | from run.proc_entry import ProcEntry | 15 | from run.proc_entry import ProcEntry |
| 16 | 16 | ||
| 17 | def InvalidKernel(Exception): | 17 | class InvalidKernel(Exception): |
| 18 | def __init__(self, kernel): | 18 | def __init__(self, kernel, wanted): |
| 19 | self.kernel = kernel | 19 | self.kernel = kernel |
| 20 | self.wanted = wanted | ||
| 21 | |||
| 22 | def __str__(self): | ||
| 23 | return "Kernel '%s' does not match '%s'." % (self.kernel, self.wanted) | ||
| 20 | 24 | ||
| 21 | def parse_args(): | 25 | def parse_args(): |
| 22 | parser = OptionParser("usage: %prog [options] [sched_file]... [exp_dir]...") | 26 | parser = OptionParser("usage: %prog [options] [sched_file]... [exp_dir]...") |
| @@ -114,12 +118,16 @@ def load_experiment(sched_file, scheduler, duration, param_file, out_dir): | |||
| 114 | run_exp(sched_file, schedule, scheduler, kernel, duration, work_dir, out_dir) | 118 | run_exp(sched_file, schedule, scheduler, kernel, duration, work_dir, out_dir) |
| 115 | 119 | ||
| 116 | # Save parameters used to run experiment in out_dir | 120 | # Save parameters used to run experiment in out_dir |
| 117 | # Cycles is saved here for accurate overhead calculations later | ||
| 118 | out_params = dict(params.items() + | 121 | out_params = dict(params.items() + |
| 119 | [(conf.PARAMS['sched'], scheduler), | 122 | [(conf.PARAMS['sched'], scheduler), |
| 120 | (conf.PARAMS['tasks'], len(schedule['spin'])), | 123 | (conf.PARAMS['tasks'], len(schedule['spin'])), |
| 121 | (conf.PARAMS['dur'], duration), | 124 | (conf.PARAMS['dur'], duration)]) |
| 122 | (conf.PARAMS['cycles'], lu.cpu_freq())]) | 125 | |
| 126 | # Feather-trace clock frequency saved for accurate overhead parsing | ||
| 127 | ft_freq = lu.ft_freq() | ||
| 128 | if ft_freq: | ||
| 129 | out_params[conf.PARAMS['cycles']] = ft_freq | ||
| 130 | |||
| 123 | with open("%s/%s" % (out_dir, conf.DEFAULTS['params_file']), 'w') as f: | 131 | with open("%s/%s" % (out_dir, conf.DEFAULTS['params_file']), 'w') as f: |
| 124 | f.write(str(out_params)) | 132 | f.write(str(out_params)) |
| 125 | 133 | ||
