aboutsummaryrefslogtreecommitdiffstats
path: root/example/driver.py
blob: 6c4c29668517e052fd654e34325e6e4c417b09ad (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#Necessary includes and stuff

from example.generator import generate_taskset_files, \
                              generate_lock_taskset_files
from example.mapping import partition_tasks
from example.overheads import get_oh_object, bound_cfl_with_oh
from example.locking import bound_cfl_with_locks

from schedcat.model.serialize import load

import os

def get_script_dir():
    return os.path.dirname(os.path.realpath(__file__))

def example_overheads():
    script_dir = get_script_dir()
    return get_oh_object(
        script_dir + "/oh_host=ludwig_scheduler=C-FL-L2-RM_stat=avg.csv",
        script_dir +
        "/oh_host=ludwig_scheduler=C-FL-L2-RM_locks=MX-Q_stat=avg.csv",
        script_dir + "/pmo_host=ludwig_background=load_stat=avg.csv",
        "L2")

def nolock_example(task_files):
    oheads = example_overheads()
    for task_file in task_files:
        ts = load(task_file)
        for task in ts:
            task.wss = 256
        clusts = partition_tasks(2, 12, True, ts)
        if clusts and bound_cfl_with_oh(oheads, True, clusts):
            yield (task_file, clusts)
        else:
            yield (task_file, None)

def lock_example(task_files):
    oheads = example_overheads()
    for task_file in task_files:
        ts = load(task_file)
        for task in ts:
            task.wss = 256
        clusts = partition_tasks(2, 12, True, ts)
        if clusts:
            clusts2 = bound_cfl_with_locks(ts, clusts, oheads, 2)
            if clusts2:
                yield (task_file, clusts2)
            else:
                yield (task_file, None)
        else:
            yield (task_file, None)

def generate_random_nolock_sets():
    return generate_taskset_files("uni-medium", "uni-moderate", 12, 2)

def generate_random_lock_sets():
    return generate_lock_taskset_files("uni-medium", "uni-moderate", 6,
                                       "medium", 6, 0.1, 2)

def print_bounds(results_list):
    for task_file, clusts in results_list:
        print "Processed {}".format(task_file)
        if clusts is not None:
            for clust in clusts:
                for task in clust:
                    print task.response_time - task.deadline