aboutsummaryrefslogtreecommitdiffstats
path: root/gen
diff options
context:
space:
mode:
authorNamhoon Kim <namhoonk@cs.unc.edu>2017-04-03 23:35:59 -0400
committerNamhoon Kim <namhoonk@cs.unc.edu>2017-04-03 23:35:59 -0400
commitfb72dd09cfc16d0260363d38df1225b6663bc084 (patch)
treedb1472467249286171d3e35c4b7a77c165571892 /gen
parente15736509ab36e33bc71a0fe1120f2974e389725 (diff)
Diffstat (limited to 'gen')
-rw-r--r--gen/__init__.py7
-rw-r--r--gen/edf_generators.py33
-rw-r--r--gen/generator.py9
3 files changed, 41 insertions, 8 deletions
diff --git a/gen/__init__.py b/gen/__init__.py
index 8c60b46..07bbc91 100644
--- a/gen/__init__.py
+++ b/gen/__init__.py
@@ -1,6 +1,7 @@
1import generator as gen 1import generator as gen
2import edf_generators as edf 2import edf_generators as edf
3 3
4gen.register_generator("G-EDF", edf.GedfGenerator) 4#gen.register_generator("G-EDF", edf.GedfGenerator)
5gen.register_generator("P-EDF", edf.PedfGenerator) 5#gen.register_generator("P-EDF", edf.PedfGenerator)
6gen.register_generator("C-EDF", edf.CedfGenerator) 6gen.register_generator("MC2", edf.Mc2Generator)
7#gen.register_generator("C-EDF", edf.CedfGenerator)
diff --git a/gen/edf_generators.py b/gen/edf_generators.py
index 8e4b8df..c769e46 100644
--- a/gen/edf_generators.py
+++ b/gen/edf_generators.py
@@ -6,6 +6,7 @@ TP_TBASE = """#for $t in $task_set
6#end for""" 6#end for"""
7TP_GLOB_TASK = TP_TBASE.format("") 7TP_GLOB_TASK = TP_TBASE.format("")
8TP_PART_TASK = TP_TBASE.format("-p $t.cpu") 8TP_PART_TASK = TP_TBASE.format("-p $t.cpu")
9TP_MC_TASK = TP_TBASE.format("-p $t.cpu -m $t.crit -i $t.id")
9 10
10class EdfGenerator(gen.Generator): 11class EdfGenerator(gen.Generator):
11 '''Creates sporadic task sets with the most common Litmus options.''' 12 '''Creates sporadic task sets with the most common Litmus options.'''
@@ -16,7 +17,7 @@ class EdfGenerator(gen.Generator):
16 17
17 def __make_options(self): 18 def __make_options(self):
18 '''Return generic EDF options.''' 19 '''Return generic EDF options.'''
19 return [gen.Generator._dist_option('utils', 'uni-medium', 20 return [gen.Generator._dist_option('utils', 'uni-very-light',
20 gen.NAMED_UTILIZATIONS, 21 gen.NAMED_UTILIZATIONS,
21 'Task utilization distributions.'), 22 'Task utilization distributions.'),
22 gen.Generator._dist_option('periods', 'harmonic', 23 gen.Generator._dist_option('periods', 'harmonic',
@@ -87,3 +88,33 @@ class GedfGenerator(EdfGenerator):
87 def __init__(self, params={}): 88 def __init__(self, params={}):
88 super(GedfGenerator, self).__init__("GSN-EDF", [TP_GLOB_TASK], 89 super(GedfGenerator, self).__init__("GSN-EDF", [TP_GLOB_TASK],
89 [], params) 90 [], params)
91
92class Mc2Generator(EdfGenerator):
93 def __init__(self, params={}):
94 super(Mc2Generator, self).__init__("MC2", [TP_MC_TASK],
95 [], params)
96
97 def _customize(self, taskset, exp_params):
98 cpus = exp_params['cpus']
99 start = 0
100
101 # Partition using worst-fit for most even distribution
102 utils = [0]*cpus
103 tasks = [0]*cpus
104 index = [1]*cpus
105 taskset = sorted(taskset, key=lambda task: task.period)
106 for t in taskset:
107 t.cpu = utils.index(min(utils))
108 t.id = index[t.cpu]
109 if utils[t.cpu] < 0.05:
110 t.crit = 0
111 elif utils[t.cpu] < 0.10:
112 t.crit = 1
113 else:
114 t.crit = 2
115 utils[t.cpu] += t.utilization()
116 tasks[t.cpu] += 1
117 index[t.cpu] += 1
118
119 # Increment by one so release master has no tasks
120 t.cpu += start
diff --git a/gen/generator.py b/gen/generator.py
index 0999e84..909c730 100644
--- a/gen/generator.py
+++ b/gen/generator.py
@@ -75,13 +75,14 @@ class Generator(object):
75 release_master = list(set([False, bool(rm_config)])) 75 release_master = list(set([False, bool(rm_config)]))
76 76
77 77
78 return [GenOption('tasks', int, range(cpus, 5*cpus, cpus), 78 return [GenOption('tasks', int, range(cpus, 10*cpus, cpus),
79 'Number of tasks per experiment.'), 79 'Number of tasks per experiment.'),
80 GenOption('cpus', int, [cpus], 80 GenOption('cpus', int, [cpus],
81 'Number of processors on target system.'), 81 'Number of processors on target system.'),
82 GenOption('release_master', [True,False], release_master, 82 GenOption('release_master', [True,False], release_master,
83 'Redirect release interrupts to a single CPU.'), 83 'Redirect release interrupts to a single CPU.'),
84 GenOption('duration', float, [30], 'Experiment duration.')] 84 #GenOption('post', str, ['refill.sh'], 'Post script.'),
85 GenOption('duration', float, [10], 'Experiment duration.')]
85 86
86 @staticmethod 87 @staticmethod
87 def _dist_option(name, default, distribution, help): 88 def _dist_option(name, default, distribution, help):
@@ -113,9 +114,9 @@ class Generator(object):
113 print(("Only created task set of size %d < %d for params %s. " + 114 print(("Only created task set of size %d < %d for params %s. " +
114 "Switching to light utilization.") % 115 "Switching to light utilization.") %
115 (len(ts), params['tasks'], params)) 116 (len(ts), params['tasks'], params))
116 print("Switching to light util. This usually means the " + 117 print("Switching to very-light util. This usually means the " +
117 "utilization distribution is too agressive.") 118 "utilization distribution is too agressive.")
118 return self._create_taskset(params, periods, NAMED_UTILIZATIONS['uni-light'], 119 return self._create_taskset(params, periods, NAMED_UTILIZATIONS['uni-very-light'],
119 max_util) 120 max_util)
120 return ts 121 return ts
121 122