diff options
author | Jeremy Erickson <jerickso@cs.unc.edu> | 2013-11-25 16:00:17 -0500 |
---|---|---|
committer | Bjoern Brandenburg <bbb@mpi-sws.org> | 2013-11-26 18:14:57 -0500 |
commit | eff718df52ffeb21bff6b59a5584e5b641887832 (patch) | |
tree | 2bcafa03fb5688e112c019095c9d23eca02a7bc5 /example/driver.py | |
parent | 972ff75fcdddf59db00b50e8a28414cf0894cc24 (diff) |
Add example code and related end-to-end tests.
Diffstat (limited to 'example/driver.py')
-rw-r--r-- | example/driver.py | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/example/driver.py b/example/driver.py new file mode 100644 index 0000000..6c4c296 --- /dev/null +++ b/example/driver.py | |||
@@ -0,0 +1,66 @@ | |||
1 | #Necessary includes and stuff | ||
2 | |||
3 | from example.generator import generate_taskset_files, \ | ||
4 | generate_lock_taskset_files | ||
5 | from example.mapping import partition_tasks | ||
6 | from example.overheads import get_oh_object, bound_cfl_with_oh | ||
7 | from example.locking import bound_cfl_with_locks | ||
8 | |||
9 | from schedcat.model.serialize import load | ||
10 | |||
11 | import os | ||
12 | |||
13 | def get_script_dir(): | ||
14 | return os.path.dirname(os.path.realpath(__file__)) | ||
15 | |||
16 | def example_overheads(): | ||
17 | script_dir = get_script_dir() | ||
18 | return get_oh_object( | ||
19 | script_dir + "/oh_host=ludwig_scheduler=C-FL-L2-RM_stat=avg.csv", | ||
20 | script_dir + | ||
21 | "/oh_host=ludwig_scheduler=C-FL-L2-RM_locks=MX-Q_stat=avg.csv", | ||
22 | script_dir + "/pmo_host=ludwig_background=load_stat=avg.csv", | ||
23 | "L2") | ||
24 | |||
25 | def nolock_example(task_files): | ||
26 | oheads = example_overheads() | ||
27 | for task_file in task_files: | ||
28 | ts = load(task_file) | ||
29 | for task in ts: | ||
30 | task.wss = 256 | ||
31 | clusts = partition_tasks(2, 12, True, ts) | ||
32 | if clusts and bound_cfl_with_oh(oheads, True, clusts): | ||
33 | yield (task_file, clusts) | ||
34 | else: | ||
35 | yield (task_file, None) | ||
36 | |||
37 | def lock_example(task_files): | ||
38 | oheads = example_overheads() | ||
39 | for task_file in task_files: | ||
40 | ts = load(task_file) | ||
41 | for task in ts: | ||
42 | task.wss = 256 | ||
43 | clusts = partition_tasks(2, 12, True, ts) | ||
44 | if clusts: | ||
45 | clusts2 = bound_cfl_with_locks(ts, clusts, oheads, 2) | ||
46 | if clusts2: | ||
47 | yield (task_file, clusts2) | ||
48 | else: | ||
49 | yield (task_file, None) | ||
50 | else: | ||
51 | yield (task_file, None) | ||
52 | |||
53 | def generate_random_nolock_sets(): | ||
54 | return generate_taskset_files("uni-medium", "uni-moderate", 12, 2) | ||
55 | |||
56 | def generate_random_lock_sets(): | ||
57 | return generate_lock_taskset_files("uni-medium", "uni-moderate", 6, | ||
58 | "medium", 6, 0.1, 2) | ||
59 | |||
60 | def print_bounds(results_list): | ||
61 | for task_file, clusts in results_list: | ||
62 | print "Processed {}".format(task_file) | ||
63 | if clusts is not None: | ||
64 | for clust in clusts: | ||
65 | for task in clust: | ||
66 | print task.response_time - task.deadline | ||