diff options
| author | Glenn Elliott <gelliott@cs.unc.edu> | 2014-01-15 18:57:15 -0500 |
|---|---|---|
| committer | Glenn Elliott <gelliott@cs.unc.edu> | 2014-01-15 18:57:15 -0500 |
| commit | 00ec439b11df7a38658ca0d6d52d18a0fab549d9 (patch) | |
| tree | 15a33e41a582fc8cf0d307ca87de76c7dbab2cb9 | |
| parent | c5fe932621cf82aaea03bc4d1c60378c66f5e52c (diff) | |
Retry-loop for task set generation
Task set generation put in a retry loop. if a task set fails
to be partitionable under any partition scheme, the entire task
set is retried.
| -rw-r--r-- | gen/generator.py | 110 |
1 files changed, 67 insertions, 43 deletions
diff --git a/gen/generator.py b/gen/generator.py index 2d0fbef..fcb21eb 100644 --- a/gen/generator.py +++ b/gen/generator.py | |||
| @@ -137,6 +137,8 @@ class Generator(object): | |||
| 137 | # make pgmrt arguments using graphs and tasks. | 137 | # make pgmrt arguments using graphs and tasks. |
| 138 | sched_file = self.out_dir + "/" + FILES['sched_file'] | 138 | sched_file = self.out_dir + "/" + FILES['sched_file'] |
| 139 | 139 | ||
| 140 | # task set is in microseconds. we must convert to milliseconds | ||
| 141 | |||
| 140 | graph_desc_arg = [] | 142 | graph_desc_arg = [] |
| 141 | rates_arg = [] | 143 | rates_arg = [] |
| 142 | exec_arg = [] | 144 | exec_arg = [] |
| @@ -153,12 +155,17 @@ class Generator(object): | |||
| 153 | split_arg_t = [] | 155 | split_arg_t = [] |
| 154 | 156 | ||
| 155 | for n in g.nodes: | 157 | for n in g.nodes: |
| 158 | # task set is in microseconds. we must convert to milliseconds | ||
| 159 | |||
| 156 | cluster_arg_t.append('node_' + str(n.id) + ':' + str(n.task.partition)) | 160 | cluster_arg_t.append('node_' + str(n.id) + ':' + str(n.task.partition)) |
| 157 | exec_arg_t.append('node_' + str(n.id) + ':' + str(n.task.cost)) | 161 | cost_str = format(n.task.cost/1000.0, '.4f').rstrip('0').rstrip('.') |
| 158 | split_arg_t.append('node_' + str(n.id) + ':' + str(n.task.split)) | 162 | exec_arg_t.append('node_' + str(n.id) + ':' + cost_str) |
| 163 | if n.task.split != 1: | ||
| 164 | split_arg_t.append('node_' + str(n.id) + ':' + str(n.task.split)) | ||
| 159 | if n.isSrc == True: | 165 | if n.isSrc == True: |
| 160 | # assume that x=1 | 166 | # assume that x=1 |
| 161 | rates_arg_t.append('node_' + str(n.id) + ':1:' + str(n.task.period)) | 167 | period_str = format(n.task.period/1000.0, '.4f').rstrip('0').rstrip('.') |
| 168 | rates_arg_t.append('node_' + str(n.id) + ':1:' + period_str) | ||
| 162 | # get cluster size | 169 | # get cluster size |
| 163 | clustersz_arg_t = str(pgm_params['cpus'] / pgm_params['nr_clusters']) | 170 | clustersz_arg_t = str(pgm_params['cpus'] / pgm_params['nr_clusters']) |
| 164 | if len(g.nodes) == 1: | 171 | if len(g.nodes) == 1: |
| @@ -167,7 +174,8 @@ class Generator(object): | |||
| 167 | graph_desc_arg_t.append('node_' + str(n.id) + ':node_' + str(succ.id)) | 174 | graph_desc_arg_t.append('node_' + str(n.id) + ':node_' + str(succ.id)) |
| 168 | # wss parameter | 175 | # wss parameter |
| 169 | for e in n.outEdges: | 176 | for e in n.outEdges: |
| 170 | wss_arg_t.append('node_' + str(n.id) + ':node_' + str(e.s.id) + ':' + str(e.wss)) | 177 | wss_kb_str = format(e.wss, '.4f').rstrip('0').rstrip('.') |
| 178 | wss_arg_t.append('node_' + str(n.id) + ':node_' + str(e.s.id) + ':' + wss_kb_str) | ||
| 171 | 179 | ||
| 172 | # combine arguments to a comma-separated string | 180 | # combine arguments to a comma-separated string |
| 173 | cluster_arg_t = ','.join(cluster_arg_t) | 181 | cluster_arg_t = ','.join(cluster_arg_t) |
| @@ -192,7 +200,8 @@ class Generator(object): | |||
| 192 | pgm_args_t = ''; | 200 | pgm_args_t = ''; |
| 193 | pgm_args_t += '--wait --cluster ' + cluster_arg[i] + ' --clusterSize ' + clustersz_arg[i] + ' --name graph_' + str(i) | 201 | pgm_args_t += '--wait --cluster ' + cluster_arg[i] + ' --clusterSize ' + clustersz_arg[i] + ' --name graph_' + str(i) |
| 194 | pgm_args_t += ' --graph ' + graph_desc_arg[i] + ' --rates ' + rates_arg[i] + ' --execution ' + exec_arg[i] | 202 | pgm_args_t += ' --graph ' + graph_desc_arg[i] + ' --rates ' + rates_arg[i] + ' --execution ' + exec_arg[i] |
| 195 | pgm_args_t += ' --split ' + split_arg[i] | 203 | if len(split_arg[i]) != 0: |
| 204 | pgm_args_t += ' --split ' + split_arg[i] | ||
| 196 | if len(wss_arg[i]) != 0: | 205 | if len(wss_arg[i]) != 0: |
| 197 | pgm_args_t += ' --wss ' + wss_arg[i] | 206 | pgm_args_t += ' --wss ' + wss_arg[i] |
| 198 | 207 | ||
| @@ -366,44 +375,59 @@ class Generator(object): | |||
| 366 | dp.nr_sink = graph.uniform(opts.nr_sink, opts.nr_sink) | 375 | dp.nr_sink = graph.uniform(opts.nr_sink, opts.nr_sink) |
| 367 | dp.wss = NAMED_EDGE_WSS[dp.wss] | 376 | dp.wss = NAMED_EDGE_WSS[dp.wss] |
| 368 | 377 | ||
| 369 | # Generate a task set | 378 | last_failed = '' |
| 370 | ts, graphs, subts = self._create_tasks(dp) | 379 | tries = 0 |
| 371 | dp.tasks = len(ts) | 380 | success = False |
| 372 | 381 | while tries < 100 and not success: | |
| 373 | #for dp in PgmDesignPointGenerator(exp): | 382 | created_dirs = [] |
| 374 | for pm in partition_method: | 383 | tries += 1 |
| 375 | dp.partitions = pm | 384 | |
| 376 | # Create directory name from relevant parameters | 385 | # Generate a task set |
| 377 | dir_leaf = "sched=%s_%s" % (self.scheduler, col_map.encode(dp)) | 386 | ts, graphs, subts = self._create_tasks(dp) |
| 378 | dir_leaf = dir_leaf.strip('_') # If there are none | 387 | dp.tasks = len(ts) |
| 379 | dir_leaf += ("_trial=%s" % trial) if trials > 1 else "" | 388 | |
| 380 | 389 | try: | |
| 381 | dir_path = "%s/%s" % (out_dir, dir_leaf.strip('_')) | 390 | for pm in partition_method: |
| 382 | 391 | dp.partitions = pm | |
| 383 | if os.path.exists(dir_path): | 392 | # Create directory name from relevant parameters |
| 384 | if force: | 393 | dir_leaf = "sched=%s_%s" % (self.scheduler, col_map.encode(dp)) |
| 385 | sh.rmtree(dir_path) | 394 | dir_leaf = dir_leaf.strip('_') # If there are none |
| 386 | else: | 395 | dir_leaf += ("_trial=%s" % trial) if trials > 1 else "" |
| 387 | print("Skipping existing experiment: '%s'" % dir_path) | 396 | |
| 388 | continue | 397 | dir_path = "%s/%s" % (out_dir, dir_leaf.strip('_')) |
| 389 | 398 | ||
| 390 | os.mkdir(dir_path) | 399 | if os.path.exists(dir_path): |
| 391 | 400 | if force: | |
| 392 | if trials > 1: | 401 | sh.rmtree(dir_path) |
| 393 | dp[PARAMS['trial']] = trial | 402 | else: |
| 394 | self.out_dir = dir_path | 403 | print("Skipping existing experiment: '%s'" % dir_path) |
| 395 | 404 | continue | |
| 396 | dp.system = topology.Topology(machines[dp.host]) | 405 | |
| 397 | 406 | os.mkdir(dir_path) | |
| 398 | # Write a sched.py and param.py for each partition method | 407 | created_dirs.append(dir_path) |
| 399 | ret = self._create_exp(dp, ts, graphs, subts) | 408 | |
| 400 | if not ret: | 409 | if trials > 1: |
| 401 | print("Bin-packing fails for " + dir_leaf) | 410 | dp[PARAMS['trial']] = trial |
| 402 | os.rmdir(dir_path) | 411 | self.out_dir = dir_path |
| 403 | 412 | ||
| 404 | del(self.out_dir) | 413 | dp.system = topology.Topology(machines[dp.host]) |
| 405 | if PARAMS['trial'] in dp: | 414 | |
| 406 | del dp[PARAMS['trial']] | 415 | # Write a sched.py and param.py for each partition method |
| 416 | ret = self._create_exp(dp, ts, graphs, subts) | ||
| 417 | if not ret: | ||
| 418 | print("Bin-packing fails for " + dir_leaf) | ||
| 419 | last_failed = dir_leaf | ||
| 420 | raise Exception("Failed to partition.") | ||
| 421 | del(self.out_dir) | ||
| 422 | if PARAMS['trial'] in dp: | ||
| 423 | del dp[PARAMS['trial']] | ||
| 424 | success = True | ||
| 425 | except Exception, e: | ||
| 426 | for d in created_dirs: | ||
| 427 | sh.rmtree(d) | ||
| 428 | if not success: | ||
| 429 | print("Failed to generate experiments. Last failed: %s" % last_failed) | ||
| 430 | |||
| 407 | 431 | ||
| 408 | def print_help(self): | 432 | def print_help(self): |
| 409 | display_options = [o for o in self.options if not o.hidden] | 433 | display_options = [o for o in self.options if not o.hidden] |
