aboutsummaryrefslogtreecommitdiffstats
path: root/gen/generators.py
diff options
context:
space:
mode:
Diffstat (limited to 'gen/generators.py')
-rw-r--r--gen/generators.py22
1 files changed, 13 insertions, 9 deletions
diff --git a/gen/generators.py b/gen/generators.py
index 09ae979..dd6f1cc 100644
--- a/gen/generators.py
+++ b/gen/generators.py
@@ -53,7 +53,7 @@ GenOption = namedtuple('GenOption', ['name', 'types', 'default', 'help'])
53class BaseGenerator(object): 53class BaseGenerator(object):
54 '''Creates sporadic task sets with the most common Litmus options.''' 54 '''Creates sporadic task sets with the most common Litmus options.'''
55 def __init__(self, name, templates, options, params): 55 def __init__(self, name, templates, options, params):
56 self.options = self.__make_options() + options 56 self.options = self.__make_options(params) + options
57 57
58 self.__setup_params(params) 58 self.__setup_params(params)
59 59
@@ -61,11 +61,14 @@ class BaseGenerator(object):
61 self.template = "\n".join([TP_RM] + templates) 61 self.template = "\n".join([TP_RM] + templates)
62 self.name = name 62 self.name = name
63 63
64 def __make_options(self): 64 def __make_options(self, params):
65 '''Return generic Litmus options.''' 65 '''Return generic Litmus options.'''
66 66
67 # Guess defaults using the properties of this computer 67 # Guess defaults using the properties of this computer
68 cpus = lu.num_cpus() 68 if 'cpus' in params:
69 cpus = min(map(int, params['cpus']))
70 else:
71 cpus = lu.num_cpus()
69 try: 72 try:
70 config = get_config_option("RELEASE_MASTER") and True 73 config = get_config_option("RELEASE_MASTER") and True
71 except: 74 except:
@@ -127,9 +130,10 @@ class BaseGenerator(object):
127 f.write(str(Template(self.template, searchList=[exp_params]))) 130 f.write(str(Template(self.template, searchList=[exp_params])))
128 131
129 del exp_params['task_set'] 132 del exp_params['task_set']
133 del exp_params['num_tasks']
130 exp_params_file = out_dir + "/" + DEFAULTS['params_file'] 134 exp_params_file = out_dir + "/" + DEFAULTS['params_file']
131 with open(exp_params_file, 'wa') as f: 135 with open(exp_params_file, 'wa') as f:
132 exp_params['scheduler'] = 'CEDF' 136 exp_params['scheduler'] = self.name
133 f.write(str(exp_params)) 137 f.write(str(exp_params))
134 138
135 def __setup_params(self, params): 139 def __setup_params(self, params):
@@ -195,7 +199,7 @@ class BaseGenerator(object):
195 col_map = builder.build() 199 col_map = builder.build()
196 200
197 for dp in DesignPointGenerator(self.params): 201 for dp in DesignPointGenerator(self.params):
198 dir_leaf = "sched=%s_%s" % (self.name, col_map.get_encoding(dp)) 202 dir_leaf = "sched=%s_%s" % (self.name, col_map.encode(dp))
199 dir_path = "%s/%s" % (out_dir, dir_leaf.strip('_')) 203 dir_path = "%s/%s" % (out_dir, dir_leaf.strip('_'))
200 204
201 if os.path.exists(dir_path): 205 if os.path.exists(dir_path):
@@ -225,10 +229,10 @@ class BaseGenerator(object):
225 i+= len(word) 229 i+= len(word)
226 res += [word] 230 res += [word]
227 if i > 80: 231 if i > 80:
228 print ", ".join(res[:-1]) 232 print(", ".join(res[:-1]))
229 res = ["\t\t "+res[-1]] 233 res = ["\t\t "+res[-1]]
230 i = line.index("'") 234 i = line.index("'")
231 print ", ".join(res) 235 print(", ".join(res))
232 236
233class PartitionedGenerator(BaseGenerator): 237class PartitionedGenerator(BaseGenerator):
234 def __init__(self, name, templates, options, params): 238 def __init__(self, name, templates, options, params):
@@ -243,7 +247,7 @@ class PartitionedGenerator(BaseGenerator):
243 247
244class PedfGenerator(PartitionedGenerator): 248class PedfGenerator(PartitionedGenerator):
245 def __init__(self, params={}): 249 def __init__(self, params={}):
246 super(PedfGenerator, self).__init__("P-EDF", [], [], params) 250 super(PedfGenerator, self).__init__("PSN-EDF", [], [], params)
247 251
248class CedfGenerator(PartitionedGenerator): 252class CedfGenerator(PartitionedGenerator):
249 LEVEL_OPTION = GenOption('level', ['L2', 'L3', 'All'], ['L2'], 253 LEVEL_OPTION = GenOption('level', ['L2', 'L3', 'All'], ['L2'],
@@ -255,4 +259,4 @@ class CedfGenerator(PartitionedGenerator):
255 259
256class GedfGenerator(BaseGenerator): 260class GedfGenerator(BaseGenerator):
257 def __init__(self, params={}): 261 def __init__(self, params={}):
258 super(GedfGenerator, self).__init__("G-EDF", [TP_GLOB_TASK], [], params) 262 super(GedfGenerator, self).__init__("GSN-EDF", [TP_GLOB_TASK], [], params)