diff options
author | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-04-05 14:24:33 -0400 |
---|---|---|
committer | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-04-15 11:42:33 -0400 |
commit | f659a11e1c888b01cce64fee5ae064a67aa4d777 (patch) | |
tree | 4e33cbaa54a697c119e5f30b1bf84fb22db94cba /gen/generator.py | |
parent | 7cef798367892aff5ae76780b15c3a0f135d0234 (diff) |
Added ColorMcGenerator.
Diffstat (limited to 'gen/generator.py')
-rw-r--r-- | gen/generator.py | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/gen/generator.py b/gen/generator.py index f35a22b..1205490 100644 --- a/gen/generator.py +++ b/gen/generator.py | |||
@@ -51,38 +51,44 @@ class Generator(object): | |||
51 | This class also performs checks of parameter values and prints out help. | 51 | This class also performs checks of parameter values and prints out help. |
52 | All subclasses must implement _create_exp. | 52 | All subclasses must implement _create_exp. |
53 | ''' | 53 | ''' |
54 | def __init__(self, scheduler, templates, options, params): | 54 | def __init__(self, name, templates, options, params): |
55 | self.__make_defaults(params) | ||
56 | |||
55 | self.options = self.__make_options(params) + options | 57 | self.options = self.__make_options(params) + options |
56 | 58 | ||
57 | self.__setup_params(params) | 59 | self.__setup_params(params) |
58 | 60 | ||
59 | self.params = params | 61 | self.params = params |
60 | self.template = "\n".join([TP_RM] + templates) | 62 | self.template = "\n".join([TP_RM] + templates) |
61 | self.scheduler = scheduler | 63 | self.scheduler = name |
62 | |||
63 | def __make_options(self, params): | ||
64 | '''Return generic Litmus options.''' | ||
65 | 64 | ||
66 | # Guess defaults using the properties of this computer | 65 | def __make_defaults(self, params): |
66 | '''Guess defaults using the properties of this computer''' | ||
67 | if 'cpus' in params: | 67 | if 'cpus' in params: |
68 | cpus = min(map(int, params['cpus'])) | 68 | self.cpus = min(map(int, params['cpus'])) |
69 | else: | 69 | else: |
70 | cpus = num_cpus() | 70 | self.cpus = num_cpus() |
71 | try: | 71 | try: |
72 | config = get_config_option("RELEASE_MASTER") and True | 72 | config = get_config_option("RELEASE_MASTER") and True |
73 | except: | 73 | except: |
74 | config = False | 74 | config = False |
75 | release_master = list(set([False, config])) | 75 | self.release_master = list(set([False, config])) |
76 | 76 | ||
77 | 77 | ||
78 | return [GenOption('tasks', int, range(cpus, 5*cpus, cpus), | 78 | def __make_options(self, params): |
79 | 'Number of tasks per experiment.'), | 79 | '''Return generic Litmus options.''' |
80 | GenOption('cpus', int, [cpus], | 80 | return [GenOption('num_tasks', int, |
81 | range(self.cpus, 5*self.cpus, self.cpus), | ||
82 | 'Number of tasks per experiment.'), | ||
83 | GenOption('cpus', int, [self.cpus], | ||
81 | 'Number of processors on target system.'), | 84 | 'Number of processors on target system.'), |
82 | GenOption('release_master', [True,False], release_master, | 85 | GenOption('release_master', [True,False], self.release_master, |
83 | 'Redirect release interrupts to a single CPU.'), | 86 | 'Redirect release interrupts to a single CPU.'), |
84 | GenOption('duration', float, [30], 'Experiment duration.')] | 87 | GenOption('duration', float, [30], 'Experiment duration.')] |
85 | 88 | ||
89 | def _num_cpus(self): | ||
90 | return self.cpus | ||
91 | |||
86 | @staticmethod | 92 | @staticmethod |
87 | def _dist_option(name, default, distribution, help): | 93 | def _dist_option(name, default, distribution, help): |
88 | return GenOption(name, [str, float, type([])] + distribution.keys(), | 94 | return GenOption(name, [str, float, type([])] + distribution.keys(), |
@@ -119,6 +125,9 @@ class Generator(object): | |||
119 | max_util) | 125 | max_util) |
120 | return ts | 126 | return ts |
121 | 127 | ||
128 | def _out_dir(self): | ||
129 | return self.out_dir | ||
130 | |||
122 | def _write_schedule(self, params): | 131 | def _write_schedule(self, params): |
123 | '''Write schedule file using current template for @params.''' | 132 | '''Write schedule file using current template for @params.''' |
124 | sched_file = self.out_dir + "/" + DEFAULTS['sched_file'] | 133 | sched_file = self.out_dir + "/" + DEFAULTS['sched_file'] |