def random_field_space(task_name, settings): name = next_name('field_space') num_fields = randint(1, settings.max_fields) field_ids = [] for i in xrange(num_fields): field_ids.append(name + '_' + str(i)) return FieldSpace(name, task_name, field_ids)
def random_index_partition(task_name, depth, start, end, settings): num_colors = randint(1, settings.max_colors_per_partition) subspaces = {} for i in xrange(0, num_colors): subspaces[i] = random_index_subspace(task_name, depth+1, start, end, settings) part_name = next_name('index_partition') return IndexPartition(part_name, task_name, subspaces)
def random_task(regions, settings, depth): name = next_name('task') rrs = random_region_requirements_no_alias(regions, settings) t = Task(name, rrs) t.logical_regions_created = random_logical_region_trees(t.name, settings) child_tasks = random_tasks(t.logical_regions_created, settings, depth+1) t.child_tasks = child_tasks return t
def random_index_tree(task_name, settings): start = randint(settings.ind_min, settings.ind_max) end = randint(start, settings.ind_max) name = next_name('index_space') if should_stop(0, settings): partitions = [] else: partitions = random_index_partitions(task_name, 0, start, end, settings) return IndexSpace(name, task_name, start, end, partitions)
def random_index_subspace(task_name, depth, start, end, settings): sub_start = randint(start, end) sub_end = randint(sub_start, end) name = next_name('index_subspace') if should_stop(depth, settings): partitions = [] else: partitions = random_index_partitions(task_name, depth+1, sub_start, sub_end, settings) return IndexSubspace(name, task_name, sub_start, sub_end, partitions)
def random_task(regions, settings, depth, parent_rrs=[], parent_name=None): name = next_name( 'task' ) region_requirements = random_region_requirements_no_alias(regions, settings) region_requirements += random_region_requirements_from_rrs_no_alias(parent_rrs, settings) # if parent_rrs: # region_requirements += parent_rrs # num_region_requirements_to_pass_on = int(len(region_requirements) * 0.5) # region_requirements = sample(region_requirements, num_region_requirements_to_pass_on) # Create task t = Task(name, region_requirements, parent_rrs) created_regions = random_logical_region_trees(t.name, settings) t.logical_regions_created = created_regions child_tasks = random_tasks(created_regions, settings, depth+1, parent_rrs=region_requirements, parent_name=name) t.child_tasks = child_tasks return t
def make_logical_subspace(task_name, field_space, index_subspace): name = next_name('logical_subregion') partitions = [] for p in index_subspace.partitions: partitions.append(make_logical_partition(task_name, field_space, p)) return LogicalSubspace(name, task_name, field_space, index_subspace, partitions)
def make_logical_partition(task_name, field_space, partition): name = next_name('logical_partition') logical_subspaces = {} for i in partition.subspaces: logical_subspaces[i] = make_logical_subspace(task_name, field_space, partition.subspaces[i]) return LogicalPartition(name, task_name, partition, logical_subspaces)
def make_logical_region_tree(task_name, field_space, index_tree): name = next_name('logical_region') partitions = [] for p in index_tree.partitions: partitions.append(make_logical_partition(task_name, field_space, p)) return LogicalRegion(name, task_name, field_space, index_tree, partitions)