aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Herman <hermanjl@cs.unc.edu>2013-04-19 11:52:51 -0400
committerJonathan Herman <hermanjl@cs.unc.edu>2013-04-19 11:52:51 -0400
commitdaa0e3a92e03a89baf7ea3750df374df79123245 (patch)
tree7ff49a80b4ba06f1dd6324264c10746a9eff6e01
parentc0405807b7f7f75fa1cf93265e6b2a739e449596 (diff)
Made default generator behavior more intuitive.
GenOption defaults can be specified as a single value in addition to a list of values. PartitionedEdfGenerator's now use worst-fit partitioning for the most even distribution of tasks.
-rw-r--r--gen/edf_generators.py24
-rw-r--r--gen/generator.py11
2 files changed, 25 insertions, 10 deletions
diff --git a/gen/edf_generators.py b/gen/edf_generators.py
index 3f05b76..a722c21 100644
--- a/gen/edf_generators.py
+++ b/gen/edf_generators.py
@@ -16,10 +16,10 @@ class EdfGenerator(gen.Generator):
16 16
17 def __make_options(self): 17 def __make_options(self):
18 '''Return generic EDF options.''' 18 '''Return generic EDF options.'''
19 return [gen.Generator._dist_option('utils', ['uni-medium'], 19 return [gen.Generator._dist_option('utils', 'uni-medium',
20 gen.NAMED_UTILIZATIONS, 20 gen.NAMED_UTILIZATIONS,
21 'Task utilization distributions.'), 21 'Task utilization distributions.'),
22 gen.Generator._dist_option('periods', ['harmonic'], 22 gen.Generator._dist_option('periods', 'harmonic',
23 gen.NAMED_PERIODS, 23 gen.NAMED_PERIODS,
24 'Task period distributions.')] 24 'Task period distributions.')]
25 25
@@ -50,10 +50,22 @@ class PartitionedGenerator(EdfGenerator):
50 templates + [TP_PART_TASK], options, params) 50 templates + [TP_PART_TASK], options, params)
51 51
52 def _customize(self, taskset, exp_params): 52 def _customize(self, taskset, exp_params):
53 start = 1 if exp_params['release_master'] else 0 53 cpus = exp_params['cpus']
54 # Random partition for now: could do a smart partitioning 54 start = 0
55 if exp_params['release_master']:
56 cpus -= 1
57 start = 1
58
59 # Partition using worst-fit for most even distribution
60 utils = [0]*cpus
61 tasks = [0]*cpus
55 for t in taskset: 62 for t in taskset:
56 t.cpu = random.randint(start, exp_params['cpus'] - 1) 63 t.cpu = utils.index(min(utils))
64 utils[t.cpu] += t.utilization()
65 tasks[t.cpu] += 1
66
67 # Increment by one so release master has no tasks
68 t.cpu += start
57 69
58class PedfGenerator(PartitionedGenerator): 70class PedfGenerator(PartitionedGenerator):
59 def __init__(self, params={}): 71 def __init__(self, params={}):
@@ -61,7 +73,7 @@ class PedfGenerator(PartitionedGenerator):
61 73
62class CedfGenerator(PartitionedGenerator): 74class CedfGenerator(PartitionedGenerator):
63 TP_CLUSTER = "plugins/C-EDF/cluster{$level}" 75 TP_CLUSTER = "plugins/C-EDF/cluster{$level}"
64 CLUSTER_OPTION = gen.GenOption('level', ['L2', 'L3', 'All'], ['L2'], 76 CLUSTER_OPTION = gen.GenOption('level', ['L2', 'L3', 'All'], 'L2',
65 'Cache clustering level.',) 77 'Cache clustering level.',)
66 78
67 def __init__(self, params={}): 79 def __init__(self, params={}):
diff --git a/gen/generator.py b/gen/generator.py
index f35a22b..6a07616 100644
--- a/gen/generator.py
+++ b/gen/generator.py
@@ -69,10 +69,10 @@ class Generator(object):
69 else: 69 else:
70 cpus = num_cpus() 70 cpus = num_cpus()
71 try: 71 try:
72 config = get_config_option("RELEASE_MASTER") and True 72 rm_config = get_config_option("RELEASE_MASTER") and True
73 except: 73 except:
74 config = False 74 rm_config = False
75 release_master = list(set([False, 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, 5*cpus, cpus),
@@ -147,7 +147,10 @@ class Generator(object):
147 '''Set default parameter values and check that values are valid.''' 147 '''Set default parameter values and check that values are valid.'''
148 for option in self.options: 148 for option in self.options:
149 if option.name not in params: 149 if option.name not in params:
150 params[option.name] = option.default 150 val = option.default
151 val = val if type(val) == type([]) else [val]
152
153 params[option.name] = val
151 else: 154 else:
152 option.hidden = True 155 option.hidden = True
153 params[option.name] = self._check_value(option.name, 156 params[option.name] = self._check_value(option.name,