From daa0e3a92e03a89baf7ea3750df374df79123245 Mon Sep 17 00:00:00 2001 From: Jonathan Herman Date: Fri, 19 Apr 2013 11:52:51 -0400 Subject: 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. --- gen/edf_generators.py | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'gen/edf_generators.py') 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): def __make_options(self): '''Return generic EDF options.''' - return [gen.Generator._dist_option('utils', ['uni-medium'], + return [gen.Generator._dist_option('utils', 'uni-medium', gen.NAMED_UTILIZATIONS, 'Task utilization distributions.'), - gen.Generator._dist_option('periods', ['harmonic'], + gen.Generator._dist_option('periods', 'harmonic', gen.NAMED_PERIODS, 'Task period distributions.')] @@ -50,10 +50,22 @@ class PartitionedGenerator(EdfGenerator): templates + [TP_PART_TASK], options, params) def _customize(self, taskset, exp_params): - start = 1 if exp_params['release_master'] else 0 - # Random partition for now: could do a smart partitioning + cpus = exp_params['cpus'] + start = 0 + if exp_params['release_master']: + cpus -= 1 + start = 1 + + # Partition using worst-fit for most even distribution + utils = [0]*cpus + tasks = [0]*cpus for t in taskset: - t.cpu = random.randint(start, exp_params['cpus'] - 1) + t.cpu = utils.index(min(utils)) + utils[t.cpu] += t.utilization() + tasks[t.cpu] += 1 + + # Increment by one so release master has no tasks + t.cpu += start class PedfGenerator(PartitionedGenerator): def __init__(self, params={}): @@ -61,7 +73,7 @@ class PedfGenerator(PartitionedGenerator): class CedfGenerator(PartitionedGenerator): TP_CLUSTER = "plugins/C-EDF/cluster{$level}" - CLUSTER_OPTION = gen.GenOption('level', ['L2', 'L3', 'All'], ['L2'], + CLUSTER_OPTION = gen.GenOption('level', ['L2', 'L3', 'All'], 'L2', 'Cache clustering level.',) def __init__(self, params={}): -- cgit v1.2.2