Prechádzať zdrojové kódy

bug fixes
finish port to add_child and remove child
now both "static" scheduler build and "dynamic" are possible

Simon Archipoff 12 rokov pred
rodič
commit
cfcec97646

+ 18 - 4
include/starpu_sched_node.h

@@ -66,6 +66,9 @@ struct starpu_sched_node
 	 */
 	struct starpu_bitmap * workers;
 	/* the workers available in context
+	 * this member is set with : 
+	 * node->workers UNION tree->workers UNION
+	 * node->child[i]->workers_in_ctx iff exist x such as node->childs[i]->fathers[x] == node
 	 */
 	struct starpu_bitmap * workers_in_ctx;
 	
@@ -80,6 +83,9 @@ struct starpu_sched_node
 	void (*add_child)(struct starpu_sched_node * node, struct starpu_sched_node * child);
 	void (*remove_child)(struct starpu_sched_node * node, struct starpu_sched_node * child);
 
+	/* this function is called by starpu_sched_node_destroy just before freeing node
+	 */
+	void (*deinit_data)(struct starpu_sched_node * node);
 #ifdef STARPU_HAVE_HWLOC
 	/* in case of a hierarchical scheduler, this is set to the part of
 	 * topology that is binded to this node, eg: a numa node for a ws
@@ -94,6 +100,7 @@ struct starpu_sched_tree
 {
 	struct starpu_sched_node * root;
 	struct starpu_bitmap * workers;
+	unsigned sched_ctx_id;
 	/* this lock is used to protect the scheduler,
 	 * it is taken in read mode pushing a task
 	 * and in write mode for adding or removing workers
@@ -172,7 +179,7 @@ struct starpu_sched_node * starpu_sched_node_best_implementation_create(void * a
 struct starpu_sched_node * starpu_sched_node_calibration_create(void * arg STARPU_ATTRIBUTE_UNUSED);
 /*create an empty tree
  */
-struct starpu_sched_tree * starpu_sched_tree_create(void);
+struct starpu_sched_tree * starpu_sched_tree_create(unsigned sched_ctx_id);
 void starpu_sched_tree_destroy(struct starpu_sched_tree * tree, unsigned sched_ctx_id);
 
 /* destroy node and all his child
@@ -180,6 +187,15 @@ void starpu_sched_tree_destroy(struct starpu_sched_tree * tree, unsigned sched_c
  */
 void starpu_sched_node_destroy_rec(struct starpu_sched_node * node, unsigned sched_ctx_id);
 
+/* update all the node->workers member recursively
+ */
+void starpu_sched_tree_update_workers(struct starpu_sched_tree * t);
+/* 
+ *
+ */
+void starpu_sched_tree_update_workers_in_ctx(struct starpu_sched_tree * t);
+
+
 int starpu_sched_tree_push_task(struct starpu_task * task);
 struct starpu_task * starpu_sched_tree_pop_task(unsigned sched_ctx_id);
 void starpu_sched_tree_add_workers(unsigned sched_ctx_id, int *workerids, unsigned nworkers);
@@ -189,7 +205,7 @@ void starpu_sched_node_worker_post_exec_hook(struct starpu_task * task);
 
 /* return the bitmap of worker that are allowed to use in this scheduling context
  */
-struct starpu_bitmap * _starpu_get_worker_mask(struct starpu_task * task);
+struct starpu_bitmap * _starpu_get_worker_mask(unsigned sched_ctx_id);
 
 /* this function is called to initialize a scheduler tree
  */
@@ -206,8 +222,6 @@ void starpu_sched_tree_call_init_data(struct starpu_sched_tree * t);
 int starpu_sched_node_push_tasks_to_firsts_suitable_parent(struct starpu_sched_node * node, struct starpu_task_list * list, int sched_ctx_id);
 
 
-struct starpu_bitmap;
-
 struct starpu_bitmap * starpu_bitmap_create(void);
 void starpu_bitmap_destroy(struct starpu_bitmap *);
 

+ 38 - 23
src/sched_policies/node_composed.c

@@ -46,9 +46,11 @@ struct composed_node
 {
 	struct starpu_sched_node *top,*bottom;
 };
-struct composed_node create_composed_node(struct starpu_sched_node * sched_ctx_ids_father[STARPU_NMAX_SCHED_CTXS], struct starpu_bitmap * workers, struct _starpu_composed_sched_node_recipe * recipe
+struct composed_node create_composed_node(struct starpu_bitmap * workers,
+					  struct starpu_bitmap * workers_in_ctx,
+					  struct _starpu_composed_sched_node_recipe * recipe
 #ifdef STARPU_HAVE_HWLOC
-					    ,hwloc_obj_t obj
+					  ,hwloc_obj_t obj
 #endif
 )
 {
@@ -66,8 +68,6 @@ struct composed_node create_composed_node(struct starpu_sched_node * sched_ctx_i
 #ifdef STARPU_HAVE_HWLOC
 	c.top->obj = obj;
 #endif
-	memcpy(c.top->fathers, sched_ctx_ids_father, sizeof(sched_ctx_ids_father));
-
 	for(i  = fun_create_node_list_next(i);
 	    i != fun_create_node_list_end(list);
 	    i  = fun_create_node_list_next(i))
@@ -81,9 +81,11 @@ struct composed_node create_composed_node(struct starpu_sched_node * sched_ctx_i
 //we want to be able to to traverse scheduler bottom up for all sched ctxs
 		int j;
 		for(j = 0; j < STARPU_NMAX_SCHED_CTXS; j++)
-			if(sched_ctx_ids_father[j])
-				starpu_sched_node_set_father(node, c.bottom,(unsigned)j);
+			starpu_sched_node_set_father(node, c.bottom,(unsigned)j);
+		starpu_bitmap_destroy(node->workers);
 		node->workers = workers;
+		starpu_bitmap_destroy(node->workers_in_ctx);
+		node->workers = workers_in_ctx;
 		c.bottom = node;
 	}
 	STARPU_ASSERT(!starpu_sched_node_is_worker(c.bottom));
@@ -96,12 +98,19 @@ static int composed_node_push_task(struct starpu_sched_node * node, struct starp
 	struct composed_node *c = node->data;
 	return c->top->push_task(c->top,task);
 }
-struct starpu_task * composed_node_pop_task(struct starpu_sched_node *node,
-					    unsigned sched_ctx_id)
+struct starpu_task * composed_node_pop_task(struct starpu_sched_node *node, unsigned sched_ctx_id)
 {
 	struct composed_node *c = node->data;
-	return c->bottom->pop_task(c->bottom, sched_ctx_id);
+	struct starpu_task * t = c->bottom->pop_task(c->bottom, sched_ctx_id);
+	if(t)
+		return t;
+
+	if(node->fathers[sched_ctx_id])
+		return node->fathers[sched_ctx_id]->pop_task(node->fathers[sched_ctx_id], sched_ctx_id);
+	return NULL;
 }
+
+
 void composed_node_available(struct starpu_sched_node *node)
 {
 	struct composed_node * c = node->data;
@@ -114,19 +123,15 @@ double composed_node_estimated_load(struct starpu_sched_node * node)
 	return c->top->estimated_load(c->top);
 }
 
-
-
-void composed_node_init_data(struct starpu_sched_node *node)
+static void composed_node_add_child(struct starpu_sched_node * node, struct starpu_sched_node * child)
 {
-	struct _starpu_composed_sched_node_recipe * recipe = node->data;
-	struct composed_node * c = malloc(sizeof(struct composed_node));
-	*c = create_composed_node(node->fathers, node->workers, recipe
-#ifdef STARPU_HAVE_HWLOC
-				   ,node->obj
-#endif 
-);
-	c->bottom->nchilds = node->nchilds;
-	c->bottom->childs = node->childs;
+	struct composed_node * c = node->data;
+	c->bottom->add_child(c->bottom, child);
+}
+static void composed_node_remove_child(struct starpu_sched_node * node, struct starpu_sched_node * child)
+{
+	struct composed_node * c = node->data;
+	c->bottom->remove_child(c->bottom, child);
 }
 
 void composed_node_deinit_data(struct starpu_sched_node * _node)
@@ -154,11 +159,21 @@ struct starpu_sched_node * starpu_sched_node_composed_node_create(struct _starpu
 		return l->_head->create_node(l->_head->arg);
 	struct starpu_sched_node * node = starpu_sched_node_create();
 
-	node->data = recipe;
+	struct composed_node * c = malloc(sizeof(struct composed_node));
+	*c = create_composed_node(node->workers, node->workers_in_ctx, recipe
+#ifdef STARPU_HAVE_HWLOC
+				   ,node->obj
+#endif 
+);
+	c->bottom->nchilds = node->nchilds;
+	c->bottom->childs = node->childs;
+
+	node->data = c;
 	node->push_task = composed_node_push_task;
 	node->pop_task = composed_node_pop_task;
 	node->available = composed_node_available;
 	node->estimated_load = composed_node_estimated_load;
-
+	node->add_child = composed_node_add_child;
+	node->remove_child = composed_node_remove_child;
 	return node;
 }

+ 6 - 7
src/sched_policies/node_eager.c

@@ -8,20 +8,19 @@
 static void initialize_eager_center_policy(unsigned sched_ctx_id)
 {
 	starpu_sched_ctx_create_worker_collection(sched_ctx_id, STARPU_WORKER_LIST);
-	struct starpu_sched_tree *data = malloc(sizeof(struct starpu_sched_tree));
-	STARPU_PTHREAD_RWLOCK_INIT(&data->lock,NULL);
- 	data->root = starpu_sched_node_fifo_create(NULL);
-	data->workers = starpu_bitmap_create();
+	struct starpu_sched_tree *t = starpu_sched_tree_create(sched_ctx_id);
+ 	t->root = starpu_sched_node_fifo_create(NULL);
 	unsigned i;
 	for(i = 0; i < starpu_worker_get_count() + starpu_combined_worker_get_count(); i++)
 	{
 		struct starpu_sched_node * node = starpu_sched_node_worker_get(i);
 		if(!node)
 			continue;
-		node->fathers[sched_ctx_id] = data->root;
-		data->root->add_child(data->root, node);
+		node->fathers[sched_ctx_id] = t->root;
+		t->root->add_child(t->root, node);
 	}
-	starpu_sched_ctx_set_policy_data(sched_ctx_id, (void*)data);
+	starpu_sched_tree_update_workers(t);
+	starpu_sched_ctx_set_policy_data(sched_ctx_id, (void*)t);
 }
 
 static void deinitialize_eager_center_policy(unsigned sched_ctx_id)

+ 4 - 4
src/sched_policies/node_heft.c

@@ -204,7 +204,7 @@ static void initialize_heft_center_policy(unsigned sched_ctx_id)
 #endif /* !STARPU_USE_TOP */
 
 	
-	struct starpu_sched_tree * t = starpu_sched_tree_create();
+	struct starpu_sched_tree * t = starpu_sched_tree_create(sched_ctx_id);
 	struct starpu_heft_data data =
 		{
 			.alpha = alpha,
@@ -225,14 +225,14 @@ static void initialize_heft_center_policy(unsigned sched_ctx_id)
 		STARPU_ASSERT(worker_node);
 
 		struct starpu_sched_node * impl_node = starpu_sched_node_best_implementation_create(NULL);
-		starpu_sched_node_add_child(impl_node, worker_node);
+		impl_node->add_child(impl_node, worker_node);
 		starpu_sched_node_set_father(worker_node, impl_node, sched_ctx_id);
 
-		starpu_sched_node_add_child(t->root, impl_node);
+		t->root->add_child(t->root, impl_node);
 		starpu_sched_node_set_father(impl_node, t->root, sched_ctx_id);
 	}
 
-	starpu_sched_node_init_rec(t->root);
+	starpu_sched_tree_update_workers(t);
 	starpu_sched_ctx_set_policy_data(sched_ctx_id, (void*)t);
 }
 

+ 7 - 7
src/sched_policies/node_random.c

@@ -20,6 +20,7 @@ static double compute_relative_speedup(struct starpu_sched_node * node)
 
 static int push_task(struct starpu_sched_node * node, struct starpu_task * task)
 {
+	STARPU_ASSERT(node->nchilds > 0);
 	int indexes_nodes[node->nchilds];
 	double speedup[node->nchilds];
 	int size=0,i;
@@ -83,10 +84,8 @@ int starpu_sched_node_is_random(struct starpu_sched_node *node)
 static void initialize_random_center_policy(unsigned sched_ctx_id)
 {
 	starpu_sched_ctx_create_worker_collection(sched_ctx_id, STARPU_WORKER_LIST);
-	struct starpu_sched_tree *data = malloc(sizeof(struct starpu_sched_tree));
-	STARPU_PTHREAD_RWLOCK_INIT(&data->lock,NULL);
- 	data->root = starpu_sched_node_random_create(NULL);
-	data->workers = starpu_bitmap_create();
+	struct starpu_sched_tree *t = starpu_sched_tree_create(sched_ctx_id);
+ 	t->root = starpu_sched_node_random_create(NULL);
 
 	unsigned i;
 	for(i = 0; i < starpu_worker_get_count() + starpu_combined_worker_get_count(); i++)
@@ -94,10 +93,11 @@ static void initialize_random_center_policy(unsigned sched_ctx_id)
 		struct starpu_sched_node * node = starpu_sched_node_worker_get(i);
 		if(!node)
 			continue;
-		node->fathers[sched_ctx_id] = data->root;
-		starpu_sched_node_add_child(data->root, node);
+		node->fathers[sched_ctx_id] = t->root;
+		t->root->add_child(t->root, node);
 	}
-	starpu_sched_ctx_set_policy_data(sched_ctx_id, (void*)data);
+	starpu_sched_tree_update_workers(t);
+	starpu_sched_ctx_set_policy_data(sched_ctx_id, (void*)t);
 }
 static void deinitialize_random_center_policy(unsigned sched_ctx_id)
 {

+ 69 - 22
src/sched_policies/node_sched.c

@@ -78,15 +78,6 @@ int push_task(struct starpu_task * task)
 	return ret;
 }
 
-void _update_worker_bits(struct starpu_sched_node * node, struct starpu_bitmap * workers_in_ctx)
-{
-	if(starpu_sched_node_is_worker(node))
-		return;
-	starpu_bitmap_unset_and(node->workers_in_ctx, node->workers, workers_in_ctx);
-	int i;
-	for(i = 0; i < node->nchilds; i++)
-		_update_worker_bits(node->childs[i], workers_in_ctx);
-}
 
 
 void starpu_sched_tree_add_workers(unsigned sched_ctx_id, int *workerids, unsigned nworkers)
@@ -96,7 +87,7 @@ void starpu_sched_tree_add_workers(unsigned sched_ctx_id, int *workerids, unsign
 	unsigned i;
 	for(i = 0; i < nworkers; i++)
 		starpu_bitmap_set(t->workers, workerids[i]);
-	_update_worker_bits(t->root, t->workers);
+	starpu_sched_tree_update_workers_in_ctx(t);
 	STARPU_PTHREAD_RWLOCK_UNLOCK(&t->lock);
 }
 
@@ -107,7 +98,7 @@ void starpu_sched_tree_remove_workers(unsigned sched_ctx_id, int *workerids, uns
 	unsigned i;
 	for(i = 0; i < nworkers; i++)
 		starpu_bitmap_unset(t->workers, workerids[i]);
-	_update_worker_bits(t->root, t->workers);
+	starpu_sched_tree_update_workers_in_ctx(t);
 	STARPU_PTHREAD_RWLOCK_UNLOCK(&t->lock);
 }
 
@@ -159,10 +150,11 @@ void starpu_sched_node_destroy_rec(struct starpu_sched_node * node, unsigned sch
 	}
 	free(stack);
 }
-struct starpu_sched_tree * starpu_sched_tree_create(void)
+struct starpu_sched_tree * starpu_sched_tree_create(unsigned sched_ctx_id)
 {
 	struct starpu_sched_tree * t = malloc(sizeof(*t));
 	memset(t, 0, sizeof(*t));
+	t->sched_ctx_id = sched_ctx_id;
 	t->workers = starpu_bitmap_create();
 	STARPU_PTHREAD_RWLOCK_INIT(&t->lock,NULL);
 	return t;
@@ -199,9 +191,9 @@ void starpu_sched_node_remove_child(struct starpu_sched_node * node, struct star
 	node->childs[pos] = node->childs[--node->nchilds];
 }
 
-struct starpu_bitmap * _starpu_get_worker_mask(struct starpu_task * task)
+struct starpu_bitmap * _starpu_get_worker_mask(unsigned sched_ctx_id)
 {
-	struct starpu_sched_tree * t = starpu_sched_ctx_get_policy_data(task->sched_ctx);
+	struct starpu_sched_tree * t = starpu_sched_ctx_get_policy_data(sched_ctx_id);
 	return t->workers;
 }
 
@@ -397,6 +389,8 @@ struct starpu_sched_node * starpu_sched_node_create(void)
 }
 void starpu_sched_node_destroy(struct starpu_sched_node *node)
 {
+	if(starpu_sched_node_is_worker(node))
+		return;
 	int i,j;
 	for(i = 0; i < node->nchilds; i++)
 	{
@@ -415,15 +409,13 @@ void starpu_sched_node_destroy(struct starpu_sched_node *node)
 
 static void set_is_homogeneous(struct starpu_sched_node * node)
 {
-	STARPU_ASSERT(starpu_bitmap_cardinal(node->workers) > 0);
-	if(starpu_bitmap_cardinal(node->workers) == 1)
+	STARPU_ASSERT(starpu_bitmap_cardinal(node->workers_in_ctx) > 0);
+	if(starpu_bitmap_cardinal(node->workers_in_ctx) == 1)
 		node->is_homogeneous = 1;
-	int worker = starpu_bitmap_first(node->workers);
+	int worker = starpu_bitmap_first(node->workers_in_ctx);
 	uint32_t last_worker = _starpu_get_worker_struct(worker)->worker_mask;
-	for(;
-	    worker != -1;
-	    worker = starpu_bitmap_next(node->workers, worker))
-		
+	
+	do
 	{
 		if(last_worker != _starpu_get_worker_struct(worker)->worker_mask)
 		{
@@ -431,10 +423,65 @@ static void set_is_homogeneous(struct starpu_sched_node * node)
 			return;
 		}
 		last_worker = _starpu_get_worker_struct(worker)->worker_mask;
-	}
+		worker = starpu_bitmap_next(node->workers_in_ctx, worker);
+	}while(worker != -1);
 	node->is_homogeneous = 1;
 }
 
+void _starpu_sched_node_update_workers(struct starpu_sched_node * node)
+{
+	if(starpu_sched_node_is_worker(node))
+		return;
+	starpu_bitmap_unset_all(node->workers);
+	int i;
+	for(i = 0; i < node->nchilds; i++)
+	{
+		_starpu_sched_node_update_workers(node->childs[i]);
+		starpu_bitmap_or(node->workers, node->childs[i]->workers);
+	}
+}
+
+void _starpu_sched_node_update_workers_in_ctx(struct starpu_sched_node * node, unsigned sched_ctx_id)
+{
+	if(starpu_sched_node_is_worker(node))
+		return;
+	struct starpu_bitmap * workers_in_ctx = _starpu_get_worker_mask(sched_ctx_id);
+	starpu_bitmap_unset_and(node->workers_in_ctx,node->workers, workers_in_ctx);
+	int i,j;
+	for(i = 0; i < node->nchilds; i++)
+	{
+		struct starpu_sched_node * child = node->childs[i];
+		_starpu_sched_node_update_workers_in_ctx(child, sched_ctx_id);
+		for(j = 0; j < STARPU_NMAX_SCHED_CTXS; j++)
+			if(child->fathers[j] == node)
+			{
+				starpu_bitmap_or(node->workers_in_ctx, child->workers_in_ctx);
+				break;
+			}
+	}
+	set_is_homogeneous(node);
+}
+
+void starpu_sched_tree_update_workers_in_ctx(struct starpu_sched_tree * t)
+{
+	_starpu_sched_node_update_workers_in_ctx(t->root, t->sched_ctx_id);
+}
+
+void starpu_sched_tree_update_workers(struct starpu_sched_tree * t)
+{
+	_starpu_sched_node_update_workers(t->root);
+}
+
+void _update_worker_bits(struct starpu_sched_node * node, struct starpu_bitmap * workers_in_ctx)
+{
+	if(starpu_sched_node_is_worker(node))
+		return;
+	starpu_bitmap_unset_and(node->workers_in_ctx, node->workers, workers_in_ctx);
+	int i;
+	for(i = 0; i < node->nchilds; i++)
+		_update_worker_bits(node->childs[i], workers_in_ctx);
+}
+
 
 
 void starpu_sched_node_init_rec(struct starpu_sched_node * node)

+ 7 - 6
src/sched_policies/node_work_stealing.c

@@ -243,6 +243,7 @@ struct starpu_sched_node * starpu_sched_node_work_stealing_create(void)
 	node->push_task = push_task;
 	node->add_child = _ws_add_child;
 	node->remove_child = _ws_remove_child;
+	node->data = wsd;
 	return  node;
 }
 
@@ -256,11 +257,10 @@ int starpu_sched_node_is_work_stealing(struct starpu_sched_node * node)
 static void initialize_ws_center_policy(unsigned sched_ctx_id)
 {
 	starpu_sched_ctx_create_worker_collection(sched_ctx_id, STARPU_WORKER_LIST);
-	struct starpu_sched_tree *data = malloc(sizeof(struct starpu_sched_tree));
-	STARPU_PTHREAD_RWLOCK_INIT(&data->lock,NULL);
+	struct starpu_sched_tree *t = starpu_sched_tree_create(sched_ctx_id);
 	struct starpu_sched_node * ws;
- 	data->root = ws = starpu_sched_node_work_stealing_create();
-	data->workers = starpu_bitmap_create();
+ 	t->root = ws = starpu_sched_node_work_stealing_create();
+	t->workers = starpu_bitmap_create();
 	unsigned i;
 	for(i = 0; i < starpu_worker_get_count(); i++)
 	{
@@ -268,9 +268,10 @@ static void initialize_ws_center_policy(unsigned sched_ctx_id)
 		if(!node)
 			continue;
 		node->fathers[sched_ctx_id] = ws;
-		starpu_sched_node_add_child(ws, node);
+		ws->add_child(ws, node);
 	}
-	starpu_sched_ctx_set_policy_data(sched_ctx_id, (void*)data);
+	starpu_sched_tree_update_workers(t);
+	starpu_sched_ctx_set_policy_data(sched_ctx_id, (void*)t);
 }
 
 static void deinitialize_ws_center_policy(unsigned sched_ctx_id)

+ 2 - 5
src/sched_policies/node_worker.c

@@ -481,7 +481,6 @@ static double combined_worker_estimated_load(struct starpu_sched_node * node)
 	return load;
 }
 
-
 static int starpu_sched_node_combined_worker_push_task(struct starpu_sched_node * node, struct starpu_task *task)
 {
 	STARPU_ASSERT(starpu_sched_node_is_combined_worker(node));
@@ -573,7 +572,6 @@ static struct starpu_sched_node * starpu_sched_node_worker_create(int workerid)
 	node->estimated_end = simple_worker_estimated_end;
 	node->estimated_load = simple_worker_estimated_load;
 	node->available = simple_worker_available;
-	node->workers = starpu_bitmap_create();
 	starpu_bitmap_set(node->workers, workerid);
 	starpu_bitmap_or(node->workers_in_ctx, node->workers);
 	_worker_nodes[workerid] = node;
@@ -611,7 +609,6 @@ static struct starpu_sched_node  * starpu_sched_node_combined_worker_create(int
 	node->estimated_end = combined_worker_estimated_end;
 	node->estimated_load = combined_worker_estimated_load;
 	node->available = combined_worker_available;
-	node->workers = starpu_bitmap_create();
 	starpu_bitmap_set(node->workers, workerid);
 	starpu_bitmap_or(node->workers_in_ctx, node->workers);
 	_worker_nodes[workerid] = node;
@@ -716,7 +713,7 @@ void starpu_sched_node_worker_post_exec_hook(struct starpu_task * task)
 	STARPU_PTHREAD_MUTEX_UNLOCK(&list->mutex);
 }
 
-static void starpu_sched_node_worker_push_task_notify(struct starpu_task *task, int workerid, unsigned sched_ctx_id)
+static void starpu_sched_node_worker_push_task_notify(struct starpu_task *task, int workerid, unsigned sched_ctx_id STARPU_ATTRIBUTE_UNUSED)
 {
 
 	struct starpu_sched_node * worker_node = starpu_sched_node_worker_get(workerid);
@@ -746,7 +743,7 @@ static void starpu_sched_node_worker_push_task_notify(struct starpu_task *task,
 	{
 		if (starpu_timing_now() + predicted_transfer < list->exp_end)
 		{
-			/* We may hope that the transfer will be finished by
+			/* We may hope that the transfer will be finshied by
 			 * the start of the task. */
 			predicted_transfer = 0;
 		}

+ 3 - 3
src/sched_policies/scheduler_maker.c

@@ -222,9 +222,7 @@ static void helper_display_scheduler(FILE* out, unsigned depth, struct starpu_sc
 #endif //STARPU_DEVEL
 struct starpu_sched_tree * _starpu_make_scheduler(unsigned sched_ctx_id, struct starpu_sched_specs specs)
 {
-	struct starpu_sched_tree * tree = malloc(sizeof(*tree));
-	STARPU_PTHREAD_RWLOCK_INIT(&tree->lock,NULL);
-	tree->workers = starpu_bitmap_create();
+	struct starpu_sched_tree * tree = starpu_sched_tree_create(sched_ctx_id);
 	
 	struct _starpu_machine_config *config = _starpu_get_machine_config();
 	hwloc_topology_t topology = config->topology.hwtopology;
@@ -244,6 +242,8 @@ struct starpu_sched_tree * _starpu_make_scheduler(unsigned sched_ctx_id, struct
 		set_worker_leaf(tree->root,worker_node, sched_ctx_id, specs);
 	}
 
+
+	starpu_sched_tree_update_workers(t);
 #ifdef STARPU_DEVEL
 	fprintf(stderr, "scheduler created :\n");
 	helper_display_scheduler(stderr, 0, tree->root);