Explorar o código

Reduce overhead of tree worker lists

Samuel Thibault %!s(int64=8) %!d(string=hai) anos
pai
achega
becda370e9
Modificáronse 3 ficheiros con 17 adicións e 5 borrados
  1. 1 0
      include/starpu_tree.h
  2. 9 5
      src/core/tree.c
  3. 7 0
      src/core/workers.c

+ 1 - 0
include/starpu_tree.h

@@ -35,6 +35,7 @@ struct starpu_tree
 
 void starpu_tree_reset_visited(struct starpu_tree *tree, char *visited);
 
+void starpu_tree_prepare_children(unsigned arity, struct starpu_tree *father);
 void starpu_tree_insert(struct starpu_tree *tree, int id, int level, int is_pu, int arity, struct starpu_tree *father);
 
 struct starpu_tree *starpu_tree_get(struct starpu_tree *tree, int id);

+ 9 - 5
src/core/tree.c

@@ -35,15 +35,19 @@ void starpu_tree_reset_visited(struct starpu_tree *tree, char *visited)
 		starpu_tree_reset_visited(tree->nodes[i], visited);
 }
 
+void starpu_tree_prepare_children(unsigned arity, struct starpu_tree *father)
+{
+	unsigned i;
+	father->nodes = (struct starpu_tree**)malloc(arity*sizeof(struct starpu_tree*));
+	for(i = 0; i < arity; i++)
+		father->nodes[i] = (struct starpu_tree*)malloc(sizeof(struct starpu_tree));
+}
+
 void starpu_tree_insert(struct starpu_tree *tree, int id, int level, int is_pu, int arity, struct starpu_tree *father)
 {
 	tree->level = level;
 	tree->arity = arity;
-	tree->nodes = (struct starpu_tree**)malloc(arity*sizeof(struct starpu_tree*));
-	int i;
-	for(i = 0; i < arity; i++)
-		tree->nodes[i] = (struct starpu_tree*)malloc(sizeof(struct starpu_tree));
-
+	tree->nodes = NULL;
 	tree->id = is_pu ? id : level;
 	tree->is_pu = is_pu;
 	tree->father = father;

+ 7 - 0
src/core/workers.c

@@ -1007,6 +1007,13 @@ struct starpu_tree* starpu_workers_get_tree(void)
 static void _fill_tree(struct starpu_tree *tree, hwloc_obj_t curr_obj, unsigned depth, hwloc_topology_t topology)
 {
 	unsigned i;
+	if (curr_obj->arity == 1)
+	{
+		/* Nothing interestin here, skip level */
+		_fill_tree(tree, curr_obj->children[0], depth+1, topology);
+		return;
+	}
+	starpu_tree_prepare_children(curr_obj->arity, tree);
 	for(i = 0; i < curr_obj->arity; i++)
 	{
 		starpu_tree_insert(tree->nodes[i], curr_obj->children[i]->logical_index, depth, curr_obj->children[i]->type == HWLOC_OBJ_PU, curr_obj->children[i]->arity, tree);