aboutsummaryrefslogtreecommitdiffstats
path: root/run/experiment.py
diff options
context:
space:
mode:
Diffstat (limited to 'run/experiment.py')
-rw-r--r--run/experiment.py56
1 files changed, 22 insertions, 34 deletions
diff --git a/run/experiment.py b/run/experiment.py
index 03d6ab6..3dd4866 100644
--- a/run/experiment.py
+++ b/run/experiment.py
@@ -3,7 +3,6 @@ import time
3import run.litmus_util as lu 3import run.litmus_util as lu
4import shutil as sh 4import shutil as sh
5from operator import methodcaller 5from operator import methodcaller
6from run.tracer import SchedTracer, LogTracer, PerfTracer, LinuxTracer, OverheadTracer
7 6
8class ExperimentException(Exception): 7class ExperimentException(Exception):
9 '''Used to indicate when there are problems with an experiment.''' 8 '''Used to indicate when there are problems with an experiment.'''
@@ -32,7 +31,8 @@ class Experiment(object):
32 '''Execute one task-set and save the results. Experiments have unique IDs.''' 31 '''Execute one task-set and save the results. Experiments have unique IDs.'''
33 INTERRUPTED_DIR = ".interrupted" 32 INTERRUPTED_DIR = ".interrupted"
34 33
35 def __init__(self, name, scheduler, working_dir, finished_dir, proc_entries, executables): 34 def __init__(self, name, scheduler, working_dir, finished_dir,
35 proc_entries, executables, tracer_types):
36 '''Run an experiment, optionally wrapped in tracing.''' 36 '''Run an experiment, optionally wrapped in tracing.'''
37 37
38 self.name = name 38 self.name = name
@@ -46,27 +46,17 @@ class Experiment(object):
46 46
47 self.__make_dirs() 47 self.__make_dirs()
48 self.__assign_executable_cwds() 48 self.__assign_executable_cwds()
49 self.__setup_tracers(tracer_types)
49 50
50 self.tracers = [] 51
51 if SchedTracer.enabled(): 52 def __setup_tracers(self, tracer_types):
52 self.log("Enabling sched_trace") 53 tracers = [ t(self.working_dir) for t in tracer_types ]
53 self.tracers.append( SchedTracer(working_dir) ) 54
54 if LinuxTracer.enabled(): 55 self.regular_tracers = [t for t in tracers if not t.is_exact()]
55 self.log("Enabling trace-cmd") 56 self.exact_tracers = [t for t in tracers if t.is_exact()]
56 self.tracers.append( LinuxTracer(working_dir) ) 57
57 if LogTracer.enabled(): 58 for t in tracers:
58 self.log("Enabling logging") 59 self.log("Enabling %s" % t.get_name())
59 self.tracers.append( LogTracer(working_dir) )
60 if PerfTracer.enabled():
61 self.log("Tracking CPU performance counters")
62 self.tracers.append( PerfTracer(working_dir) )
63
64 # Overhead trace must be handled seperately, see __run_tasks
65 if OverheadTracer.enabled():
66 self.log("Enabling overhead tracing")
67 self.overhead_trace = OverheadTracer(working_dir)
68 else:
69 self.overhead_trace = None
70 60
71 def __make_dirs(self): 61 def __make_dirs(self):
72 interrupted = None 62 interrupted = None
@@ -111,11 +101,10 @@ class Experiment(object):
111 raise Exception("Too much time has passed waiting for tasks!") 101 raise Exception("Too much time has passed waiting for tasks!")
112 time.sleep(1) 102 time.sleep(1)
113 103
114 # Overhead tracer must be started right after release or overhead 104 # Exact tracers (like overheads) must be started right after release or
115 # measurements will be full of irrelevant records 105 # measurements will be full of irrelevant records
116 if self.overhead_trace: 106 self.log("Starting %d released tracers" % len(self.exact_tracers))
117 self.log("Starting overhead trace") 107 map(methodcaller('start_tracing'), self.exact_tracers)
118 self.overhead_trace.start_tracing()
119 108
120 self.log("Releasing %d tasks" % len(self.executables)) 109 self.log("Releasing %d tasks" % len(self.executables))
121 released = lu.release_tasks() 110 released = lu.release_tasks()
@@ -145,10 +134,9 @@ class Experiment(object):
145 if not e.wait(): 134 if not e.wait():
146 ret = False 135 ret = False
147 136
148 # And it must be stopped here for the same reason 137 # And these must be stopped here for the same reason
149 if self.overhead_trace: 138 self.log("Stopping exact tracers")
150 self.log("Stopping overhead trace") 139 map(methodcaller('stop_tracing'), self.exact_tracers)
151 self.overhead_trace.stop_tracing()
152 140
153 if not ret: 141 if not ret:
154 raise ExperimentFailed(self.name) 142 raise ExperimentFailed(self.name)
@@ -186,8 +174,8 @@ class Experiment(object):
186 self.log("Switching to %s" % self.scheduler) 174 self.log("Switching to %s" % self.scheduler)
187 lu.switch_scheduler(self.scheduler) 175 lu.switch_scheduler(self.scheduler)
188 176
189 self.log("Starting %d tracers" % len(self.tracers)) 177 self.log("Starting %d regular tracers" % len(self.regular_tracers))
190 map(methodcaller('start_tracing'), self.tracers) 178 map(methodcaller('start_tracing'), self.regular_tracers)
191 179
192 self.exec_out = open('%s/exec-out.txt' % self.working_dir, 'w') 180 self.exec_out = open('%s/exec-out.txt' % self.working_dir, 'w')
193 self.exec_err = open('%s/exec-err.txt' % self.working_dir, 'w') 181 self.exec_err = open('%s/exec-err.txt' % self.working_dir, 'w')
@@ -200,6 +188,6 @@ class Experiment(object):
200 self.exec_out and self.exec_out.close() 188 self.exec_out and self.exec_out.close()
201 self.exec_err and self.exec_err.close() 189 self.exec_err and self.exec_err.close()
202 190
203 self.log("Stopping tracers") 191 self.log("Stopping regular tracers")
204 map(methodcaller('stop_tracing'), self.tracers) 192 map(methodcaller('stop_tracing'), self.regular_tracers)
205 193