diff options
author | Jonathan Herman <hermanjl@cs.unc.edu> | 2012-11-26 17:06:27 -0500 |
---|---|---|
committer | Jonathan Herman <hermanjl@cs.unc.edu> | 2012-11-26 17:06:27 -0500 |
commit | b43b83beead92ff7cf28a5fe5a2710537268aae1 (patch) | |
tree | d9c29b14cd18a9df520f36d7e85eb460c30fa7a9 | |
parent | cb8db5d30ee769304c2c2b00f2a7d9bcb3c4098f (diff) |
Read locations of binary files from path instead of config.py.
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | common.py | 25 | ||||
-rw-r--r-- | config/config.example.py | 58 | ||||
-rw-r--r-- | config/config.py | 45 | ||||
-rw-r--r-- | parse/ft.py | 2 | ||||
-rw-r--r-- | parse/sched.py | 14 | ||||
-rw-r--r-- | run/__init__.py (renamed from experiment/__init__.py) | 0 | ||||
-rw-r--r-- | run/executable/__init__.py (renamed from experiment/executable/__init__.py) | 0 | ||||
-rw-r--r-- | run/executable/executable.py (renamed from experiment/executable/executable.py) | 0 | ||||
-rw-r--r-- | run/executable/ftcat.py (renamed from experiment/executable/ftcat.py) | 0 | ||||
-rw-r--r-- | run/experiment.py (renamed from experiment/experiment.py) | 0 | ||||
-rw-r--r-- | run/litmus_util.py (renamed from experiment/litmus_util.py) | 0 | ||||
-rw-r--r-- | run/proc_entry.py (renamed from experiment/proc_entry.py) | 0 | ||||
-rw-r--r-- | run/tracer.py (renamed from experiment/tracer.py) | 18 |
14 files changed, 86 insertions, 77 deletions
@@ -1,4 +1,3 @@ | |||
1 | config/config.py | ||
2 | *~ | 1 | *~ |
3 | \#*# | 2 | \#*# |
4 | *.pyc | 3 | *.pyc |
@@ -2,6 +2,29 @@ import sys | |||
2 | from collections import defaultdict | 2 | from collections import defaultdict |
3 | from textwrap import dedent | 3 | from textwrap import dedent |
4 | 4 | ||
5 | def get_executable(prog, hint, optional=False): | ||
6 | import os | ||
7 | def is_exe(fpath): | ||
8 | return os.path.isfile(fpath) and os.access(fpath, os.X_OK) | ||
9 | |||
10 | fpath, fname = os.path.split(prog) | ||
11 | if fpath: | ||
12 | if is_exe(prog): | ||
13 | return prog | ||
14 | else: | ||
15 | for path in os.environ["PATH"].split(os.pathsep): | ||
16 | exe_file = os.path.join(path, prog) | ||
17 | if is_exe(exe_file): | ||
18 | return exe_file | ||
19 | |||
20 | if not optional: | ||
21 | sys.stderr.write("Cannot find executable '%s' in PATH. This is a part " | ||
22 | "of '%s' which should be added to PATH to run." % | ||
23 | (prog, hint)) | ||
24 | sys.exit(1) | ||
25 | else: | ||
26 | return None | ||
27 | |||
5 | def recordtype(typename, field_names, default=0): | 28 | def recordtype(typename, field_names, default=0): |
6 | ''' Mutable namedtuple. Recipe from George Sakkis of MIT.''' | 29 | ''' Mutable namedtuple. Recipe from George Sakkis of MIT.''' |
7 | field_names = tuple(map(str, field_names)) | 30 | field_names = tuple(map(str, field_names)) |
@@ -87,5 +110,3 @@ def load_params(fname): | |||
87 | raise IOError("Invalid param file: %s\n%s" % (fname, e)) | 110 | raise IOError("Invalid param file: %s\n%s" % (fname, e)) |
88 | 111 | ||
89 | return params | 112 | return params |
90 | |||
91 | |||
diff --git a/config/config.example.py b/config/config.example.py deleted file mode 100644 index 9f24097..0000000 --- a/config/config.example.py +++ /dev/null | |||
@@ -1,58 +0,0 @@ | |||
1 | from __future__ import print_function | ||
2 | import os | ||
3 | import sys | ||
4 | import itertools | ||
5 | |||
6 | ''' | ||
7 | These are paths to repository directories. | ||
8 | |||
9 | ''' | ||
10 | REPOS = {'liblitmus' : '/home/hermanjl/git/liblitmus', | ||
11 | 'sched_trace' : '/home/hermanjl/git/sched_trace', | ||
12 | 'ft_tools' : '/home/hermanjl/git/feather-trace-tools', | ||
13 | 'trace-cmd' : '/home/hermanjl/git/trace-cmd'} | ||
14 | |||
15 | BINS = {'rtspin' : '{}/rtspin'.format(REPOS['liblitmus']), | ||
16 | 'release' : '{}/release_ts'.format(REPOS['liblitmus']), | ||
17 | 'ftcat' : '{}/ftcat'.format(REPOS['ft_tools']), | ||
18 | 'ftsplit' : '{}/ft2csv'.format(REPOS['ft_tools']), | ||
19 | 'ftsort' : '{}/ftsort'.format(REPOS['ft_tools']), | ||
20 | 'st_trace' : '{}/st_trace'.format(REPOS['ft_tools']), | ||
21 | 'trace-cmd' : '{}/trace-cmd'.format(REPOS['trace-cmd']), | ||
22 | 'st_show' : '{}/st_show'.format(REPOS['sched_trace'])} | ||
23 | |||
24 | DEFAULTS = {'params_file' : 'params.py', | ||
25 | 'sched_file' : 'sched.py', | ||
26 | 'exps_file' : 'exps.py', | ||
27 | 'duration' : 10, | ||
28 | 'spin' : 'rtspin', | ||
29 | 'cycles' : 2000} | ||
30 | |||
31 | FILES = {'ft_data' : 'ft.bin', | ||
32 | 'linux_data' : 'trace.dat', | ||
33 | 'sched_data' : 'st-{}.bin', | ||
34 | 'log_data' : 'trace.slog',} | ||
35 | |||
36 | PARAMS = {'sched' : 'scheduler', | ||
37 | 'dur' : 'duration', | ||
38 | 'kernel': 'uname', | ||
39 | 'cycles' : 'cpu-frequency'} | ||
40 | |||
41 | SCHED_EVENTS = range(501, 513) | ||
42 | BASE_EVENTS = ['SCHED', 'RELEASE', 'SCHED2', 'TICK', 'CXS'] | ||
43 | ALL_EVENTS = ["%s_%s" % (e, t) for (e,t) in | ||
44 | itertools.product(BASE_EVENTS, ["START","END"])] | ||
45 | ALL_EVENTS += ['RELEASE_LATENCY'] | ||
46 | BASE_EVENTS += ['RELEASE_LATENCY'] | ||
47 | |||
48 | valid = True | ||
49 | for repo, loc in REPOS.items(): | ||
50 | if not os.path.isdir(loc): | ||
51 | valid = False | ||
52 | print("Cannot access repo '%s' at '%s'" % (repo, loc), file=sys.stderr) | ||
53 | for prog, loc in BINS.items(): | ||
54 | if not os.path.isfile(loc): | ||
55 | valid = False | ||
56 | print("Cannot access program '%s' at '%s'" % (prog, loc), file=sys.stderr) | ||
57 | if not valid: | ||
58 | print("Errors in config file", file=sys.stderr) | ||
diff --git a/config/config.py b/config/config.py new file mode 100644 index 0000000..3282705 --- /dev/null +++ b/config/config.py | |||
@@ -0,0 +1,45 @@ | |||
1 | from __future__ import print_function | ||
2 | import itertools | ||
3 | from common import get_executable | ||
4 | |||
5 | '''Paths to binaries.''' | ||
6 | BINS = {'rtspin' : get_executable('rtspin', 'liblitmus'), | ||
7 | 'release' : get_executable('release_ts', 'liblitmus'), | ||
8 | 'ftcat' : get_executable('ftcat', 'feather-trace-tools'), | ||
9 | 'ftsplit' : get_executable('ft2csv', 'feather-trace-tools'), | ||
10 | 'ftsort' : get_executable('ftsort', 'feather-trace-tools'), | ||
11 | 'st_trace' : get_executable('st_trace', 'feather-trace-tools'), | ||
12 | 'trace-cmd' : get_executable('trace-cmd', 'rt-kernelshark'), | ||
13 | # Optional, as sched_trace is not a publically supported repository | ||
14 | 'st_show' : get_executable('st_show', 'sched_trace', True)} | ||
15 | |||
16 | '''Names of output files.''' | ||
17 | FILES = {'ft_data' : 'ft.bin', | ||
18 | 'linux_data' : 'trace.dat', | ||
19 | 'sched_data' : 'st-{}.bin', | ||
20 | 'log_data' : 'trace.slog',} | ||
21 | |||
22 | '''Default parameter names in params.py.''' | ||
23 | PARAMS = {'sched' : 'scheduler', | ||
24 | 'dur' : 'duration', | ||
25 | 'kernel' : 'uname', | ||
26 | 'cycles' : 'cpu-frequency'} | ||
27 | |||
28 | '''Default values for program parameters.''' | ||
29 | DEFAULTS = {'params_file' : 'params.py', | ||
30 | 'sched_file' : 'sched.py', | ||
31 | 'exps_file' : 'exps.py', | ||
32 | 'duration' : 10, | ||
33 | 'spin' : 'rtspin', | ||
34 | 'cycles' : 2000} | ||
35 | |||
36 | '''Default sched_trace events (this is all of them).''' | ||
37 | SCHED_EVENTS = range(501, 513) | ||
38 | |||
39 | '''Overhead events.''' | ||
40 | OVH_BASE_EVENTS = ['SCHED', 'RELEASE', 'SCHED2', 'TICK', 'CXS'] | ||
41 | OVH_ALL_EVENTS = ["%s_%s" % (e, t) for (e,t) in | ||
42 | itertools.product(OVH_BASE_EVENTS, ["START","END"])] | ||
43 | OVH_ALL_EVENTS += ['RELEASE_LATENCY'] | ||
44 | # This event doesn't have a START and END | ||
45 | OVH_BASE_EVENTS += ['RELEASE_LATENCY'] | ||
diff --git a/parse/ft.py b/parse/ft.py index fea246a..a6596b7 100644 --- a/parse/ft.py +++ b/parse/ft.py | |||
@@ -71,7 +71,7 @@ def extract_ft_data(result, data_dir, work_dir, cycles): | |||
71 | with open("%s/%s" % (work_dir, FT_ERR_NAME), 'w') as err_file: | 71 | with open("%s/%s" % (work_dir, FT_ERR_NAME), 'w') as err_file: |
72 | sorted_bin = sort_ft(bin_file, err_file, work_dir) | 72 | sorted_bin = sort_ft(bin_file, err_file, work_dir) |
73 | 73 | ||
74 | for event in conf.BASE_EVENTS: | 74 | for event in conf.OVH_BASE_EVENTS: |
75 | parse_overhead(result, sorted_bin, event, cycles, | 75 | parse_overhead(result, sorted_bin, event, cycles, |
76 | work_dir, err_file) | 76 | work_dir, err_file) |
77 | 77 | ||
diff --git a/parse/sched.py b/parse/sched.py index ffc6224..512ac73 100644 --- a/parse/sched.py +++ b/parse/sched.py | |||
@@ -32,8 +32,8 @@ class TimeTracker: | |||
32 | self.job = record.job | 32 | self.job = record.job |
33 | 33 | ||
34 | # Data stored for each task | 34 | # Data stored for each task |
35 | TaskParams = namedtuple('TaskParams', ['wcet', 'period', 'cpu']) | 35 | TaskParams = namedtuple('TaskParams', ['wcet', 'period', 'cpu']) |
36 | TaskData = recordtype('TaskData', ['params', 'jobs', 'blocks', 'misses']) | 36 | TaskData = recordtype('TaskData', ['params', 'jobs', 'blocks', 'misses']) |
37 | 37 | ||
38 | # Map of event ids to corresponding class, binary format, and processing methods | 38 | # Map of event ids to corresponding class, binary format, and processing methods |
39 | RecordInfo = namedtuple('RecordInfo', ['clazz', 'fmt', 'method']) | 39 | RecordInfo = namedtuple('RecordInfo', ['clazz', 'fmt', 'method']) |
@@ -151,10 +151,12 @@ def extract_sched_data(result, data_dir, work_dir): | |||
151 | return | 151 | return |
152 | 152 | ||
153 | # Save an in-english version of the data for debugging | 153 | # Save an in-english version of the data for debugging |
154 | cmd_arr = [conf.BINS['st_show']] | 154 | # This is optional and will only be done if 'st_show' is in PATH |
155 | cmd_arr.extend(bins) | 155 | if conf.BINS['st_show']: |
156 | with open(output_file, "w") as f: | 156 | cmd_arr = [conf.BINS['st_show']] |
157 | subprocess.call(cmd_arr, cwd=data_dir, stdout=f) | 157 | cmd_arr.extend(bins) |
158 | with open(output_file, "w") as f: | ||
159 | subprocess.call(cmd_arr, cwd=data_dir, stdout=f) | ||
158 | 160 | ||
159 | task_dict = defaultdict(lambda : | 161 | task_dict = defaultdict(lambda : |
160 | TaskData(0, 0, TimeTracker(), TimeTracker())) | 162 | TaskData(0, 0, TimeTracker(), TimeTracker())) |
diff --git a/experiment/__init__.py b/run/__init__.py index e69de29..e69de29 100644 --- a/experiment/__init__.py +++ b/run/__init__.py | |||
diff --git a/experiment/executable/__init__.py b/run/executable/__init__.py index e69de29..e69de29 100644 --- a/experiment/executable/__init__.py +++ b/run/executable/__init__.py | |||
diff --git a/experiment/executable/executable.py b/run/executable/executable.py index 628f711..628f711 100644 --- a/experiment/executable/executable.py +++ b/run/executable/executable.py | |||
diff --git a/experiment/executable/ftcat.py b/run/executable/ftcat.py index 5da8fa7..5da8fa7 100644 --- a/experiment/executable/ftcat.py +++ b/run/executable/ftcat.py | |||
diff --git a/experiment/experiment.py b/run/experiment.py index 4bd47c6..4bd47c6 100644 --- a/experiment/experiment.py +++ b/run/experiment.py | |||
diff --git a/experiment/litmus_util.py b/run/litmus_util.py index fb2b341..fb2b341 100644 --- a/experiment/litmus_util.py +++ b/run/litmus_util.py | |||
diff --git a/experiment/proc_entry.py b/run/proc_entry.py index 0b7f9ce..0b7f9ce 100644 --- a/experiment/proc_entry.py +++ b/run/proc_entry.py | |||
diff --git a/experiment/tracer.py b/run/tracer.py index 4949927..5d00e86 100644 --- a/experiment/tracer.py +++ b/run/tracer.py | |||
@@ -19,24 +19,24 @@ class Tracer(object): | |||
19 | map(methodcaller('terminate'), self.bins) | 19 | map(methodcaller('terminate'), self.bins) |
20 | map(methodcaller('wait'), self.bins) | 20 | map(methodcaller('wait'), self.bins) |
21 | 21 | ||
22 | 22 | ||
23 | class LinuxTracer(Tracer): | 23 | class LinuxTracer(Tracer): |
24 | EVENT_ROOT = "/sys/kernel/debug/tracing" | 24 | EVENT_ROOT = "/sys/kernel/debug/tracing" |
25 | LITMUS_EVENTS = "%s/events/litmus" % EVENT_ROOT | 25 | LITMUS_EVENTS = "%s/events/litmus" % EVENT_ROOT |
26 | 26 | ||
27 | def __init__(self, output_dir): | 27 | def __init__(self, output_dir): |
28 | super(LinuxTracer, self).__init__("trace-cmd", output_dir) | 28 | super(LinuxTracer, self).__init__("trace-cmd", output_dir) |
29 | 29 | ||
30 | extra_args = ["record", # "-e", "sched:sched_switch", | 30 | extra_args = ["record", # "-e", "sched:sched_switch", |
31 | "-e", "litmus:*", | 31 | "-e", "litmus:*", |
32 | "-o", "%s/%s" % (output_dir, conf.FILES['linux_data'])] | 32 | "-o", "%s/%s" % (output_dir, conf.FILES['linux_data'])] |
33 | stdout = open('%s/trace-cmd-stdout.txt' % self.output_dir, 'w') | 33 | stdout = open('%s/trace-cmd-stdout.txt' % self.output_dir, 'w') |
34 | stderr = open('%s/trace-cmd-stderr.txt' % self.output_dir, 'w') | 34 | stderr = open('%s/trace-cmd-stderr.txt' % self.output_dir, 'w') |
35 | 35 | ||
36 | execute = Executable(conf.BINS['trace-cmd'], extra_args, stdout, stderr) | 36 | execute = Executable(conf.BINS['trace-cmd'], extra_args, stdout, stderr) |
37 | execute.cwd = output_dir | 37 | execute.cwd = output_dir |
38 | self.bins.append(execute) | 38 | self.bins.append(execute) |
39 | 39 | ||
40 | @staticmethod | 40 | @staticmethod |
41 | def enabled(): | 41 | def enabled(): |
42 | return os.path.exists(LinuxTracer.LITMUS_EVENTS) | 42 | return os.path.exists(LinuxTracer.LITMUS_EVENTS) |
@@ -45,13 +45,13 @@ class LinuxTracer(Tracer): | |||
45 | map(methodcaller('interrupt'), self.bins) | 45 | map(methodcaller('interrupt'), self.bins) |
46 | map(methodcaller('wait'), self.bins) | 46 | map(methodcaller('wait'), self.bins) |
47 | 47 | ||
48 | 48 | ||
49 | class LogTracer(Tracer): | 49 | class LogTracer(Tracer): |
50 | DEVICE_STR = '/dev/litmus/log' | 50 | DEVICE_STR = '/dev/litmus/log' |
51 | 51 | ||
52 | def __init__(self, output_dir): | 52 | def __init__(self, output_dir): |
53 | super(LogTracer, self).__init__("Logger", output_dir) | 53 | super(LogTracer, self).__init__("Logger", output_dir) |
54 | 54 | ||
55 | out_file = open("%s/%s" % (self.output_dir, conf.FILES['log_data']), 'w') | 55 | out_file = open("%s/%s" % (self.output_dir, conf.FILES['log_data']), 'w') |
56 | 56 | ||
57 | cat = (Executable("/bin/cat", [LogTracer.DEVICE_STR])) | 57 | cat = (Executable("/bin/cat", [LogTracer.DEVICE_STR])) |
@@ -62,7 +62,7 @@ class LogTracer(Tracer): | |||
62 | @staticmethod | 62 | @staticmethod |
63 | def enabled(): | 63 | def enabled(): |
64 | return litmus_util.is_device(LogTracer.DEVICE_STR) | 64 | return litmus_util.is_device(LogTracer.DEVICE_STR) |
65 | 65 | ||
66 | 66 | ||
67 | class SchedTracer(Tracer): | 67 | class SchedTracer(Tracer): |
68 | DEVICE_STR = '/dev/litmus/sched_trace' | 68 | DEVICE_STR = '/dev/litmus/sched_trace' |
@@ -84,7 +84,7 @@ class SchedTracer(Tracer): | |||
84 | def enabled(): | 84 | def enabled(): |
85 | return litmus_util.is_device("%s%d" % (SchedTracer.DEVICE_STR, 0)) | 85 | return litmus_util.is_device("%s%d" % (SchedTracer.DEVICE_STR, 0)) |
86 | 86 | ||
87 | 87 | ||
88 | class OverheadTracer(Tracer): | 88 | class OverheadTracer(Tracer): |
89 | DEVICE_STR = '/dev/litmus/ft_trace0' | 89 | DEVICE_STR = '/dev/litmus/ft_trace0' |
90 | 90 | ||
@@ -94,7 +94,7 @@ class OverheadTracer(Tracer): | |||
94 | stdout_f = open('{0}/{1}'.format(self.output_dir, conf.FILES['ft_data']), 'w') | 94 | stdout_f = open('{0}/{1}'.format(self.output_dir, conf.FILES['ft_data']), 'w') |
95 | stderr_f = open('{0}/{1}.stderr.txt'.format(self.output_dir, conf.FILES['ft_data']), 'w') | 95 | stderr_f = open('{0}/{1}.stderr.txt'.format(self.output_dir, conf.FILES['ft_data']), 'w') |
96 | ftc = FTcat(conf.BINS['ftcat'], stdout_f, stderr_f, | 96 | ftc = FTcat(conf.BINS['ftcat'], stdout_f, stderr_f, |
97 | OverheadTracer.DEVICE_STR, conf.ALL_EVENTS) | 97 | OverheadTracer.DEVICE_STR, conf.OVH_ALL_EVENTS) |
98 | 98 | ||
99 | self.bins.append(ftc) | 99 | self.bins.append(ftc) |
100 | 100 | ||