Browse Source

scheds: Drop one level of indirection for bitmaps

Samuel Thibault 5 years ago
parent
commit
1f8566b647

+ 9 - 5
include/starpu_bitmap.h

@@ -35,13 +35,15 @@ extern "C"
    @{
  */
 #ifndef _STARPU_LONG_BIT
-#define _STARPU_LONG_BIT (sizeof(unsigned long) * 8)
+#define _STARPU_LONG_BIT ((int)(sizeof(unsigned long) * 8))
 #endif
 
 #define _STARPU_BITMAP_SIZE ((STARPU_NMAXWORKERS - 1)/_STARPU_LONG_BIT) + 1
 
 /** create a empty starpu_bitmap */
 static inline struct starpu_bitmap *starpu_bitmap_create(void) STARPU_ATTRIBUTE_MALLOC;
+/** zero a starpu_bitmap */
+static inline void starpu_bitmap_init(struct starpu_bitmap *b);
 /** free \p b */
 static inline void starpu_bitmap_destroy(struct starpu_bitmap *b);
 
@@ -123,12 +125,14 @@ static inline struct starpu_bitmap *starpu_bitmap_create()
 	return (struct starpu_bitmap *) calloc(1, sizeof(struct starpu_bitmap));
 }
 
+static inline void starpu_bitmap_init(struct starpu_bitmap *b)
+{
+	memset(b, 0, sizeof(*b));
+}
+
 static inline void starpu_bitmap_destroy(struct starpu_bitmap * b)
 {
-	if(b)
-	{
-		free(b);
-	}
+	free(b);
 }
 
 static inline void starpu_bitmap_set(struct starpu_bitmap * b, int e)

+ 3 - 3
include/starpu_sched_component.h

@@ -69,14 +69,14 @@ struct starpu_sched_component
 	/** The tree containing the component*/
 	struct starpu_sched_tree *tree;
 	/** set of underlying workers */
-	struct starpu_bitmap *workers;
+	struct starpu_bitmap workers;
 	/**
 	   subset of starpu_sched_component::workers that is currently available in the context
 	   The push method should take this value into account, it is set with:
 	   component->workers UNION tree->workers UNION
 	   component->child[i]->workers_in_ctx iff exist x such as component->children[i]->parents[x] == component
 	*/
-	struct starpu_bitmap *workers_in_ctx;
+	struct starpu_bitmap workers_in_ctx;
 	/** private data */
 	void *data;
 	char *name;
@@ -188,7 +188,7 @@ struct starpu_sched_tree
 	/**
 	   set of workers available in this context, this value is used to mask workers in modules
 	*/
-	struct starpu_bitmap *workers;
+	struct starpu_bitmap workers;
 	/**
 	   context id of the scheduler
 	*/

+ 1 - 1
src/sched_policies/component_best_implementation.c

@@ -85,7 +85,7 @@ static void select_best_implementation_and_set_preds(unsigned sched_ctx_id, stru
 static int best_implementation_push_task(struct starpu_sched_component * component, struct starpu_task * task)
 {
 	STARPU_ASSERT(component->nchildren == 1);
-	select_best_implementation_and_set_preds(component->tree->sched_ctx_id, component->workers_in_ctx, task);
+	select_best_implementation_and_set_preds(component->tree->sched_ctx_id, &component->workers_in_ctx, task);
 	return starpu_sched_component_push_task(component,component->children[0],task);
 }
 

+ 6 - 7
src/sched_policies/component_composed.c

@@ -168,16 +168,16 @@ static void composed_component_remove_child(struct starpu_sched_component * comp
 static void composed_component_notify_change_workers(struct starpu_sched_component * component)
 {
 	struct composed_component * c = component->data;
-	struct starpu_bitmap * workers = component->workers;
-	struct starpu_bitmap * workers_in_ctx = component->workers_in_ctx;
+	struct starpu_bitmap * workers = &component->workers;
+	struct starpu_bitmap * workers_in_ctx = &component->workers_in_ctx;
 	struct starpu_sched_component * n;
 	for(n = c->top; ;n = n->children[0])
 	{
-		starpu_bitmap_unset_all(n->workers);
-		starpu_bitmap_or(n->workers, workers);
+		starpu_bitmap_unset_all(&n->workers);
+		starpu_bitmap_or(&n->workers, workers);
 
-		starpu_bitmap_unset_all(n->workers_in_ctx);
-		starpu_bitmap_or(n->workers_in_ctx, workers_in_ctx);
+		starpu_bitmap_unset_all(&n->workers_in_ctx);
+		starpu_bitmap_or(&n->workers_in_ctx, workers_in_ctx);
 
 		n->properties = component->properties;
 		if(n == c->bottom)
@@ -195,7 +195,6 @@ void composed_component_deinit_data(struct starpu_sched_component * _component)
 	do
 	{
 		component = next;
-		component->workers = NULL;
 		next = component->children ? component->children[0] : NULL;
 		starpu_sched_component_destroy(component);
 	}

+ 6 - 6
src/sched_policies/component_eager.c

@@ -35,9 +35,9 @@ static int eager_push_task(struct starpu_sched_component * component, struct sta
 	{
 		/* target told us we could push to it, try to */
 		int idworker;
-		for(idworker = starpu_bitmap_first(target->workers);
+		for(idworker = starpu_bitmap_first(&target->workers);
 			idworker != -1;
-			idworker = starpu_bitmap_next(target->workers, idworker))
+			idworker = starpu_bitmap_next(&target->workers, idworker))
 		{
 			int nimpl;
 			for(nimpl = 0; nimpl < STARPU_MAXIMPLEMENTATIONS; nimpl++)
@@ -55,9 +55,9 @@ static int eager_push_task(struct starpu_sched_component * component, struct sta
 
 	/* FIXME: should rather just loop over children before looping over its workers */
 	int workerid;
-	for(workerid = starpu_bitmap_first(component->workers_in_ctx);
+	for(workerid = starpu_bitmap_first(&component->workers_in_ctx);
 	    workerid != -1;
-	    workerid = starpu_bitmap_next(component->workers_in_ctx, workerid))
+	    workerid = starpu_bitmap_next(&component->workers_in_ctx, workerid))
 	{
 		int nimpl;
 		for(nimpl = 0; nimpl < STARPU_MAXIMPLEMENTATIONS; nimpl++)
@@ -70,9 +70,9 @@ static int eager_push_task(struct starpu_sched_component * component, struct sta
 				for (i = 0; i < component->nchildren; i++)
 				{
 					int idworker;
-					for(idworker = starpu_bitmap_first(component->children[i]->workers);
+					for(idworker = starpu_bitmap_first(&component->children[i]->workers);
 						idworker != -1;
-						idworker = starpu_bitmap_next(component->children[i]->workers, idworker))
+						idworker = starpu_bitmap_next(&component->children[i]->workers, idworker))
 					{
 						if (idworker == workerid)
 						{

+ 4 - 4
src/sched_policies/component_eager_calibration.c

@@ -25,9 +25,9 @@ static int eager_calibration_push_task(struct starpu_sched_component * component
 	starpu_task_bundle_t bundle = task->bundle;
 
 	int workerid;
-	for(workerid = starpu_bitmap_first(component->workers_in_ctx);
+	for(workerid = starpu_bitmap_first(&component->workers_in_ctx);
 	    workerid != -1;
-	    workerid = starpu_bitmap_next(component->workers_in_ctx, workerid))
+	    workerid = starpu_bitmap_next(&component->workers_in_ctx, workerid))
 	{
 		struct starpu_perfmodel_arch* archtype = starpu_worker_get_perf_archtype(workerid, component->tree->sched_ctx_id);
 		int nimpl;
@@ -49,9 +49,9 @@ static int eager_calibration_push_task(struct starpu_sched_component * component
 					for (i = 0; i < component->nchildren; i++)
 					{
 						int idworker;
-						for(idworker = starpu_bitmap_first(component->children[i]->workers);
+						for(idworker = starpu_bitmap_first(&component->children[i]->workers);
 							idworker != -1;
-							idworker = starpu_bitmap_next(component->children[i]->workers, idworker))
+							idworker = starpu_bitmap_next(&component->children[i]->workers, idworker))
 						{
 							if (idworker == workerid)
 							{

+ 4 - 4
src/sched_policies/component_eager_prio.c

@@ -50,9 +50,9 @@ static int eager_prio_progress_one(struct starpu_sched_component *component)
 
 	/* FIXME: should rather just loop over children before looping over its workers */
 	int workerid;
-	for(workerid = starpu_bitmap_first(component->workers_in_ctx);
+	for(workerid = starpu_bitmap_first(&component->workers_in_ctx);
 	    workerid != -1;
-	    workerid = starpu_bitmap_next(component->workers_in_ctx, workerid))
+	    workerid = starpu_bitmap_next(&component->workers_in_ctx, workerid))
 	{
 		int nimpl;
 		for(nimpl = 0; nimpl < STARPU_MAXIMPLEMENTATIONS; nimpl++)
@@ -65,9 +65,9 @@ static int eager_prio_progress_one(struct starpu_sched_component *component)
 				for (i = 0; i < component->nchildren; i++)
 				{
 					int idworker;
-					for(idworker = starpu_bitmap_first(component->children[i]->workers);
+					for(idworker = starpu_bitmap_first(&component->children[i]->workers);
 						idworker != -1;
-						idworker = starpu_bitmap_next(component->children[i]->workers, idworker))
+						idworker = starpu_bitmap_next(&component->children[i]->workers, idworker))
 					{
 						if (idworker == workerid)
 						{

+ 6 - 6
src/sched_policies/component_fifo.c

@@ -51,7 +51,7 @@ static double fifo_estimated_end(struct starpu_sched_component * component)
 static double fifo_estimated_load(struct starpu_sched_component * component)
 {
 	STARPU_ASSERT(component && component->data);
-	STARPU_ASSERT(starpu_bitmap_cardinal(component->workers_in_ctx) != 0);
+	STARPU_ASSERT(starpu_bitmap_cardinal(&component->workers_in_ctx) != 0);
 	struct _starpu_fifo_data * data = component->data;
 	struct _starpu_fifo_taskq * queue = data->fifo;
 	starpu_pthread_mutex_t * mutex = &data->mutex;
@@ -59,7 +59,7 @@ static double fifo_estimated_load(struct starpu_sched_component * component)
 	double load = starpu_sched_component_estimated_load(component);
 	if(STARPU_SCHED_COMPONENT_IS_HOMOGENEOUS(component))
 	{
-		int first_worker = starpu_bitmap_first(component->workers_in_ctx);
+		int first_worker = starpu_bitmap_first(&component->workers_in_ctx);
 		relative_speedup = starpu_worker_get_relative_speedup(starpu_worker_get_perf_archtype(first_worker, component->tree->sched_ctx_id));
 		STARPU_COMPONENT_MUTEX_LOCK(mutex);
 		load += queue->ntasks / relative_speedup;
@@ -69,11 +69,11 @@ static double fifo_estimated_load(struct starpu_sched_component * component)
 	else
 	{
 		int i;
-		for(i = starpu_bitmap_first(component->workers_in_ctx);
+		for(i = starpu_bitmap_first(&component->workers_in_ctx);
 		    i != -1;
-		    i = starpu_bitmap_next(component->workers_in_ctx, i))
+		    i = starpu_bitmap_next(&component->workers_in_ctx, i))
 			relative_speedup += starpu_worker_get_relative_speedup(starpu_worker_get_perf_archtype(i, component->tree->sched_ctx_id));
-		relative_speedup /= starpu_bitmap_cardinal(component->workers_in_ctx);
+		relative_speedup /= starpu_bitmap_cardinal(&component->workers_in_ctx);
 		STARPU_ASSERT(!_STARPU_IS_ZERO(relative_speedup));
 		STARPU_COMPONENT_MUTEX_LOCK(mutex);
 		load += queue->ntasks / relative_speedup;
@@ -182,7 +182,7 @@ static struct starpu_task * fifo_pull_task(struct starpu_sched_component * compo
 	STARPU_COMPONENT_MUTEX_LOCK(mutex);
 	struct starpu_task * task;
 	if (data->ready && to->properties & STARPU_SCHED_COMPONENT_SINGLE_MEMORY_NODE)
-		task = _starpu_fifo_pop_first_ready_task(queue, starpu_bitmap_first(to->workers_in_ctx), -1);
+		task = _starpu_fifo_pop_first_ready_task(queue, starpu_bitmap_first(&to->workers_in_ctx), -1);
 	else
 		task = _starpu_fifo_pop_task(queue, starpu_worker_get_id_check());
 	if(task && data->exp)

+ 6 - 6
src/sched_policies/component_heteroprio.c

@@ -128,9 +128,9 @@ static int heteroprio_progress_accel(struct starpu_sched_component *component, s
 		for (i = 0; i < component->nchildren; i++)
 		{
 			int idworker;
-			for(idworker = starpu_bitmap_first(component->children[i]->workers);
+			for(idworker = starpu_bitmap_first(&component->children[i]->workers);
 				idworker != -1;
-				idworker = starpu_bitmap_next(component->children[i]->workers, idworker))
+				idworker = starpu_bitmap_next(&component->children[i]->workers, idworker))
 			{
 				if (starpu_worker_get_type(idworker) == archtype)
 					break;
@@ -173,9 +173,9 @@ static int heteroprio_progress_accel(struct starpu_sched_component *component, s
 	best_component = component->children[best_icomponent];
 
 	int idworker;
-	for(idworker = starpu_bitmap_first(best_component->workers);
+	for(idworker = starpu_bitmap_first(&best_component->workers);
 		idworker != -1;
-		idworker = starpu_bitmap_next(best_component->workers, idworker))
+		idworker = starpu_bitmap_next(&best_component->workers, idworker))
 	{
 		if (starpu_worker_get_type(idworker) == archtype)
 			break;
@@ -356,9 +356,9 @@ static int heteroprio_push_task(struct starpu_sched_component * component, struc
 
 	/* Compute acceleration between best-performing arch and least-performing arch */
 	int workerid;
-	for(workerid = starpu_bitmap_first(component->workers_in_ctx);
+	for(workerid = starpu_bitmap_first(&component->workers_in_ctx);
 	    workerid != -1;
-	    workerid = starpu_bitmap_next(component->workers_in_ctx, workerid))
+	    workerid = starpu_bitmap_next(&component->workers_in_ctx, workerid))
 	{
 		unsigned impl_mask;
 		if (!starpu_worker_can_execute_task_impl(workerid, task, &impl_mask))

+ 6 - 6
src/sched_policies/component_prio.c

@@ -70,7 +70,7 @@ static double prio_estimated_end(struct starpu_sched_component * component)
 static double prio_estimated_load(struct starpu_sched_component * component)
 {
 	STARPU_ASSERT(component && component->data);
-	STARPU_ASSERT(starpu_bitmap_cardinal(component->workers_in_ctx) != 0);
+	STARPU_ASSERT(starpu_bitmap_cardinal(&component->workers_in_ctx) != 0);
 	struct _starpu_prio_data * data = component->data;
 	struct _starpu_prio_deque * queue = &data->prio;
 	starpu_pthread_mutex_t * mutex = &data->mutex;
@@ -78,7 +78,7 @@ static double prio_estimated_load(struct starpu_sched_component * component)
 	double load = starpu_sched_component_estimated_load(component);
 	if(STARPU_SCHED_COMPONENT_IS_HOMOGENEOUS(component))
 	{
-		int first_worker = starpu_bitmap_first(component->workers_in_ctx);
+		int first_worker = starpu_bitmap_first(&component->workers_in_ctx);
 		relative_speedup = starpu_worker_get_relative_speedup(starpu_worker_get_perf_archtype(first_worker, component->tree->sched_ctx_id));
 		STARPU_COMPONENT_MUTEX_LOCK(mutex);
 		load += queue->ntasks / relative_speedup;
@@ -88,11 +88,11 @@ static double prio_estimated_load(struct starpu_sched_component * component)
 	else
 	{
 		int i;
-		for(i = starpu_bitmap_first(component->workers_in_ctx);
+		for(i = starpu_bitmap_first(&component->workers_in_ctx);
 		    i != -1;
-		    i = starpu_bitmap_next(component->workers_in_ctx, i))
+		    i = starpu_bitmap_next(&component->workers_in_ctx, i))
 			relative_speedup += starpu_worker_get_relative_speedup(starpu_worker_get_perf_archtype(i, component->tree->sched_ctx_id));
-		relative_speedup /= starpu_bitmap_cardinal(component->workers_in_ctx);
+		relative_speedup /= starpu_bitmap_cardinal(&component->workers_in_ctx);
 		STARPU_ASSERT(!_STARPU_IS_ZERO(relative_speedup));
 		STARPU_COMPONENT_MUTEX_LOCK(mutex);
 		load += queue->ntasks / relative_speedup;
@@ -204,7 +204,7 @@ static struct starpu_task * prio_pull_task(struct starpu_sched_component * compo
 	STARPU_COMPONENT_MUTEX_LOCK(mutex);
 	struct starpu_task * task;
 	if (data->ready && to->properties & STARPU_SCHED_COMPONENT_SINGLE_MEMORY_NODE)
-		task = _starpu_prio_deque_deque_first_ready_task(queue, starpu_bitmap_first(to->workers_in_ctx));
+		task = _starpu_prio_deque_deque_first_ready_task(queue, starpu_bitmap_first(&to->workers_in_ctx));
 	else
 		task = _starpu_prio_deque_pop_task(queue);
 	if(task && data->exp)

+ 2 - 2
src/sched_policies/component_random.c

@@ -24,9 +24,9 @@ static double compute_relative_speedup(struct starpu_sched_component * component
 {
 	double sum = 0.0;
 	int id;
-	for(id = starpu_bitmap_first(component->workers_in_ctx);
+	for(id = starpu_bitmap_first(&component->workers_in_ctx);
 	    id != -1;
-	    id = starpu_bitmap_next(component->workers_in_ctx, id))
+	    id = starpu_bitmap_next(&component->workers_in_ctx, id))
 	{
 		struct starpu_perfmodel_arch* perf_arch = starpu_worker_get_perf_archtype(id, component->tree->sched_ctx_id);
 		sum += starpu_worker_get_relative_speedup(perf_arch);

+ 23 - 26
src/sched_policies/component_sched.c

@@ -45,9 +45,9 @@ int starpu_sched_component_execute_preds(struct starpu_sched_component * compone
 
 
 	int workerid;
-	for(workerid = starpu_bitmap_first(component->workers_in_ctx);
+	for(workerid = starpu_bitmap_first(&component->workers_in_ctx);
 	    workerid != -1;
-	    workerid = starpu_bitmap_next(component->workers_in_ctx, workerid))
+	    workerid = starpu_bitmap_next(&component->workers_in_ctx, workerid))
 	{
 		int nimpl;
 		for(nimpl = 0; nimpl < STARPU_MAXIMPLEMENTATIONS; nimpl++)
@@ -100,9 +100,9 @@ int starpu_sched_component_can_execute_task(struct starpu_sched_component * comp
 	unsigned nimpl;
 	int worker;
 	for (nimpl = 0; nimpl < STARPU_MAXIMPLEMENTATIONS; nimpl++)
-		for(worker = starpu_bitmap_first(component->workers_in_ctx);
+		for(worker = starpu_bitmap_first(&component->workers_in_ctx);
 		    -1 != worker;
-		    worker = starpu_bitmap_next(component->workers_in_ctx, worker))
+		    worker = starpu_bitmap_next(&component->workers_in_ctx, worker))
 			if (starpu_worker_can_execute_task(worker, task, nimpl)
 			     || starpu_combined_worker_can_execute_task(worker, task, nimpl))
 			    return 1;
@@ -115,21 +115,21 @@ int starpu_sched_component_can_execute_task(struct starpu_sched_component * comp
 double starpu_sched_component_transfer_length(struct starpu_sched_component * component, struct starpu_task * task)
 {
 	STARPU_ASSERT(component && task);
-	int nworkers = starpu_bitmap_cardinal(component->workers_in_ctx);
+	int nworkers = starpu_bitmap_cardinal(&component->workers_in_ctx);
 	double sum = 0.0;
 	int worker;
 	if(STARPU_SCHED_COMPONENT_IS_SINGLE_MEMORY_NODE(component))
 	{
-		unsigned memory_node  = starpu_worker_get_memory_node(starpu_bitmap_first(component->workers_in_ctx));
+		unsigned memory_node  = starpu_worker_get_memory_node(starpu_bitmap_first(&component->workers_in_ctx));
 		if(task->bundle)
 			return starpu_task_bundle_expected_data_transfer_time(task->bundle,memory_node);
 		else
 			return starpu_task_expected_data_transfer_time(memory_node, task);
 	}
 
-	for(worker = starpu_bitmap_first(component->workers_in_ctx);
+	for(worker = starpu_bitmap_first(&component->workers_in_ctx);
 	    worker != -1;
-	    worker = starpu_bitmap_next(component->workers_in_ctx, worker))
+	    worker = starpu_bitmap_next(&component->workers_in_ctx, worker))
 	{
 		unsigned memory_node  = starpu_worker_get_memory_node(worker);
 		if(task->bundle)
@@ -156,7 +156,7 @@ void starpu_sched_component_prefetch_on_node(struct starpu_sched_component * com
 	if (starpu_get_prefetch_flag() && (!task->prefetched)
 		&& (component->properties & STARPU_SCHED_COMPONENT_SINGLE_MEMORY_NODE))
 	{
-		int worker = starpu_bitmap_first(component->workers_in_ctx);
+		int worker = starpu_bitmap_first(&component->workers_in_ctx);
 		unsigned memory_node = starpu_worker_get_memory_node(worker);
 		starpu_prefetch_task_input_on_node(task, memory_node);
 		task->prefetched = 1;
@@ -195,8 +195,6 @@ void starpu_sched_component_destroy(struct starpu_sched_component *component)
 	free(component->children);
 	free(component->parents);
 	free(component->name);
-	starpu_bitmap_destroy(component->workers);
-	starpu_bitmap_destroy(component->workers_in_ctx);
 	free(component);
 }
 
@@ -223,7 +221,7 @@ void set_properties(struct starpu_sched_component * component)
 	STARPU_ASSERT(component);
 	component->properties = 0;
 
-	int worker = starpu_bitmap_first(component->workers_in_ctx);
+	int worker = starpu_bitmap_first(&component->workers_in_ctx);
 	if (worker == -1)
 		return;
 	if (starpu_worker_is_combined_worker(worker))
@@ -237,7 +235,7 @@ void set_properties(struct starpu_sched_component * component)
 	int is_all_same_component = 1;
 	for(;
 	    worker != -1;
-	    worker = starpu_bitmap_next(component->workers_in_ctx, worker))
+	    worker = starpu_bitmap_next(&component->workers_in_ctx, worker))
 	{
 		if(starpu_worker_is_combined_worker(worker))
 			continue;
@@ -262,12 +260,12 @@ void _starpu_sched_component_update_workers(struct starpu_sched_component * comp
 	STARPU_ASSERT(component);
 	if(starpu_sched_component_is_worker(component))
 		return;
-	starpu_bitmap_unset_all(component->workers);
+	starpu_bitmap_unset_all(&component->workers);
 	unsigned i;
 	for(i = 0; i < component->nchildren; i++)
 	{
 		_starpu_sched_component_update_workers(component->children[i]);
-		starpu_bitmap_or(component->workers, component->children[i]->workers);
+		starpu_bitmap_or(&component->workers, &component->children[i]->workers);
 	}
 	component->notify_change_workers(component);
 }
@@ -282,11 +280,11 @@ void _starpu_sched_component_update_workers_in_ctx(struct starpu_sched_component
 	if(starpu_sched_component_is_worker(component))
 		return;
 	struct starpu_bitmap * workers_in_ctx = _starpu_get_worker_mask(sched_ctx_id);
-	starpu_bitmap_unset_and(component->workers_in_ctx,component->workers, workers_in_ctx);
+	starpu_bitmap_unset_and(&component->workers_in_ctx,&component->workers, workers_in_ctx);
 	unsigned i,j;
 	for(i = starpu_worker_get_count(); i < starpu_worker_get_count() + starpu_combined_worker_get_count(); i++)
 	{
-		if (starpu_bitmap_get(component->workers, i))
+		if (starpu_bitmap_get(&component->workers, i))
 		{
 			/* Component has this combined worker, check whether the
 			 * context has all the corresponding workers */
@@ -297,7 +295,7 @@ void _starpu_sched_component_update_workers_in_ctx(struct starpu_sched_component
 				if (!starpu_bitmap_get(workers_in_ctx, combined_workerid[j]))
 					goto nocombined;
 			/* We have all workers, add it */
-			starpu_bitmap_set(component->workers_in_ctx, i);
+			starpu_bitmap_set(&component->workers_in_ctx, i);
 		}
 nocombined:
 		(void)0;
@@ -324,7 +322,7 @@ struct starpu_bitmap * _starpu_get_worker_mask(unsigned sched_ctx_id)
 	STARPU_ASSERT(sched_ctx_id < STARPU_NMAX_SCHED_CTXS);
 	struct starpu_sched_tree * t = starpu_sched_ctx_get_policy_data(sched_ctx_id);
 	STARPU_ASSERT(t);
-	return t->workers;
+	return &t->workers;
 }
 
 void starpu_sched_tree_update_workers_in_ctx(struct starpu_sched_tree * t)
@@ -442,7 +440,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]);
+		starpu_bitmap_set(&t->workers, workerids[i]);
 
 	starpu_sched_tree_update_workers_in_ctx(t);
 
@@ -461,7 +459,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]);
+		starpu_bitmap_unset(&t->workers, workerids[i]);
 
 	starpu_sched_tree_update_workers_in_ctx(t);
 
@@ -478,7 +476,7 @@ struct starpu_sched_tree * starpu_sched_tree_create(unsigned sched_ctx_id)
 	struct starpu_sched_tree *t;
 	_STARPU_CALLOC(t, 1, sizeof(*t));
 	t->sched_ctx_id = sched_ctx_id;
-	t->workers = starpu_bitmap_create();
+	starpu_bitmap_init(&t->workers);
 	STARPU_PTHREAD_MUTEX_INIT(&t->lock,NULL);
 	trees[sched_ctx_id] = t;
 	return t;
@@ -491,7 +489,6 @@ void starpu_sched_tree_destroy(struct starpu_sched_tree * tree)
 	trees[tree->sched_ctx_id] = NULL;
 	if(tree->root)
 		starpu_sched_component_destroy_rec(tree->root);
-	starpu_bitmap_destroy(tree->workers);
 	STARPU_PTHREAD_MUTEX_DESTROY(&tree->lock);
 	free(tree);
 }
@@ -694,7 +691,7 @@ double starpu_sched_component_estimated_end_min_add(struct starpu_sched_componen
 	{
 		/* We don't know which workers will do this, assume it will be
 		 * evenly distributed to existing work */
-		int card = starpu_bitmap_cardinal(component->workers_in_ctx);
+		int card = starpu_bitmap_cardinal(&component->workers_in_ctx);
 		if (card == 0)
 			/* Oops, no resources to compute our tasks. Let's just hope that
 			 * we will be given one at some point */
@@ -732,8 +729,8 @@ struct starpu_sched_component * starpu_sched_component_create(struct starpu_sche
 	struct starpu_sched_component *component;
 	_STARPU_CALLOC(component, 1, sizeof(*component));
 	component->tree = tree;
-	component->workers = starpu_bitmap_create();
-	component->workers_in_ctx = starpu_bitmap_create();
+	starpu_bitmap_init(&component->workers);
+	starpu_bitmap_init(&component->workers_in_ctx);
 	component->add_child = starpu_sched_component_add_child;
 	component->remove_child = starpu_sched_component_remove_child;
 	component->add_parent = starpu_sched_component_add_parent;

+ 6 - 6
src/sched_policies/component_work_stealing.c

@@ -123,7 +123,7 @@ static inline unsigned select_worker(struct starpu_sched_component * component)
 
 static int is_worker_of_component(struct starpu_sched_component * component, int workerid)
 {
-	return starpu_bitmap_get(component->workers, workerid);
+	return starpu_bitmap_get(&component->workers, workerid);
 }
 
 
@@ -202,7 +202,7 @@ double _ws_estimated_end(struct starpu_sched_component * component)
 		STARPU_COMPONENT_MUTEX_UNLOCK(wsd->mutexes[i]);
 
 	}
-	int nb_workers = starpu_bitmap_cardinal(component->workers_in_ctx);
+	int nb_workers = starpu_bitmap_cardinal(&component->workers_in_ctx);
 
 	return (sum_start + sum_len) / nb_workers;
 }
@@ -221,9 +221,9 @@ double _ws_estimated_load(struct starpu_sched_component * component)
 	}
 	double speedup = 0.0;
 	int workerid;
-	for(workerid = starpu_bitmap_first(component->workers_in_ctx);
+	for(workerid = starpu_bitmap_first(&component->workers_in_ctx);
 	    -1 != workerid;
-	    workerid = starpu_bitmap_next(component->workers_in_ctx, workerid))
+	    workerid = starpu_bitmap_next(&component->workers_in_ctx, workerid))
 	{
 		speedup += starpu_worker_get_relative_speedup(starpu_worker_get_perf_archtype(workerid, component->tree->sched_ctx_id));
 	}
@@ -243,9 +243,9 @@ static int push_task(struct starpu_sched_component * component, struct starpu_ta
 	while(1)
 	{
 		int workerid;
-		for(workerid = starpu_bitmap_first(component->children[i]->workers_in_ctx);
+		for(workerid = starpu_bitmap_first(&component->children[i]->workers_in_ctx);
 		    -1 != workerid;
-		    workerid = starpu_bitmap_next(component->children[i]->workers_in_ctx, workerid))
+		    workerid = starpu_bitmap_next(&component->children[i]->workers_in_ctx, workerid))
 		{
 			unsigned impl;
 			int can_execute = starpu_worker_can_execute_task_first_impl(workerid, task, &impl);

+ 9 - 9
src/sched_policies/component_worker.c

@@ -408,7 +408,7 @@ static int simple_worker_push_task(struct starpu_sched_component * component, st
 	t->task = task;
 	t->ntasks = 1;
 
-	task->workerid = starpu_bitmap_first(component->workers);
+	task->workerid = starpu_bitmap_first(&component->workers);
 #if 1 /* dead lock problem? */
 	if (starpu_get_prefetch_flag() && !task->prefetched)
 		starpu_prefetch_task_input_for(task, task->workerid);
@@ -522,7 +522,7 @@ static double simple_worker_estimated_load(struct starpu_sched_component * compo
 	int ntasks_in_fifo = l ? l->ntasks : 0;
 	return (double) (nb_task + ntasks_in_fifo)
 		/ starpu_worker_get_relative_speedup(
-				starpu_worker_get_perf_archtype(starpu_bitmap_first(component->workers), component->tree->sched_ctx_id));
+				starpu_worker_get_perf_archtype(starpu_bitmap_first(&component->workers), component->tree->sched_ctx_id));
 }
 
 static void _worker_component_deinit_data(struct starpu_sched_component * component)
@@ -567,8 +567,8 @@ static struct starpu_sched_component * starpu_sched_component_worker_create(stru
 	component->estimated_end = simple_worker_estimated_end;
 	component->estimated_load = simple_worker_estimated_load;
 	component->deinit_data = _worker_component_deinit_data;
-	starpu_bitmap_set(component->workers, workerid);
-	starpu_bitmap_or(component->workers_in_ctx, component->workers);
+	starpu_bitmap_set(&component->workers, workerid);
+	starpu_bitmap_or(&component->workers_in_ctx, &component->workers);
 	_worker_components[tree->sched_ctx_id][workerid] = component;
 
 	/*
@@ -616,7 +616,7 @@ static int combined_worker_push_task(struct starpu_sched_component * component,
 	struct _starpu_worker_component_data * data = component->data;
 	STARPU_ASSERT(data->parallel_worker.worker_size >= 1);
 	struct _starpu_task_grid * task_alias[data->parallel_worker.worker_size];
-	starpu_parallel_task_barrier_init(task, starpu_bitmap_first(component->workers));
+	starpu_parallel_task_barrier_init(task, starpu_bitmap_first(&component->workers));
 	task_alias[0] = _starpu_task_grid_create();
 	task_alias[0]->task = starpu_task_dup(task);
 	task_alias[0]->task->workerid = data->parallel_worker.workerids[0];
@@ -750,8 +750,8 @@ static struct starpu_sched_component  * starpu_sched_component_combined_worker_c
 
 	struct starpu_sched_component *component = starpu_sched_component_parallel_worker_create(tree, combined_worker->worker_size, (unsigned *) combined_worker->combined_workerid);
 
-	starpu_bitmap_set(component->workers, workerid);
-	starpu_bitmap_or(component->workers_in_ctx, component->workers);
+	starpu_bitmap_set(&component->workers, workerid);
+	starpu_bitmap_or(&component->workers_in_ctx, &component->workers);
 
 	_worker_components[tree->sched_ctx_id][workerid] = component;
 
@@ -803,8 +803,8 @@ int starpu_sched_component_worker_get_workerid(struct starpu_sched_component * w
 #ifndef STARPU_NO_ASSERT
 	STARPU_ASSERT(_worker_consistant(worker_component));
 #endif
-	STARPU_ASSERT(1 == starpu_bitmap_cardinal(worker_component->workers));
-	return starpu_bitmap_first(worker_component->workers);
+	STARPU_ASSERT(1 == starpu_bitmap_cardinal(&worker_component->workers));
+	return starpu_bitmap_first(&worker_component->workers);
 }
 
 void starpu_sched_component_worker_pre_exec_hook(struct starpu_task * task, unsigned sched_ctx_id STARPU_ATTRIBUTE_UNUSED)

+ 6 - 7
src/sched_policies/eager_central_policy.c

@@ -31,7 +31,7 @@ struct _starpu_eager_center_policy_data
 {
 	struct _starpu_fifo_taskq *fifo;
 	starpu_pthread_mutex_t policy_mutex;
-	struct starpu_bitmap *waiters;
+	struct starpu_bitmap waiters;
 };
 
 static void initialize_eager_center_policy(unsigned sched_ctx_id)
@@ -41,7 +41,7 @@ static void initialize_eager_center_policy(unsigned sched_ctx_id)
 
 	/* there is only a single queue in that trivial design */
 	data->fifo =  _starpu_create_fifo();
-	data->waiters = starpu_bitmap_create();
+	starpu_bitmap_init(&data->waiters);
 
 	 /* Tell helgrind that it's fine to check for empty fifo in
 	  * pop_task_eager_policy without actual mutex (it's just an integer)
@@ -61,7 +61,6 @@ static void deinitialize_eager_center_policy(unsigned sched_ctx_id)
 
 	/* deallocate the job queue */
 	_starpu_destroy_fifo(fifo);
-	starpu_bitmap_destroy(data->waiters);
 
 	STARPU_PTHREAD_MUTEX_DESTROY(&data->policy_mutex);
 	free(data);
@@ -105,7 +104,7 @@ static int push_task_eager_policy(struct starpu_task *task)
 		unsigned worker = workers->get_next(workers, &it);
 
 #ifdef STARPU_NON_BLOCKING_DRIVERS
-		if (!starpu_bitmap_get(data->waiters, worker))
+		if (!starpu_bitmap_get(&data->waiters, worker))
 			/* This worker is not waiting for a task */
 			continue;
 #endif
@@ -114,7 +113,7 @@ static int push_task_eager_policy(struct starpu_task *task)
 		{
 			/* It can execute this one, tell him! */
 #ifdef STARPU_NON_BLOCKING_DRIVERS
-			starpu_bitmap_unset(data->waiters, worker);
+			starpu_bitmap_unset(&data->waiters, worker);
 			/* We really woke at least somebody, no need to wake somebody else */
 			break;
 #else
@@ -169,7 +168,7 @@ static struct starpu_task *pop_task_eager_policy(unsigned sched_ctx_id)
 	}
 
 #ifdef STARPU_NON_BLOCKING_DRIVERS
-	if (!STARPU_RUNNING_ON_VALGRIND && starpu_bitmap_get(data->waiters, workerid))
+	if (!STARPU_RUNNING_ON_VALGRIND && starpu_bitmap_get(&data->waiters, workerid))
 		/* Nobody woke us, avoid bothering the mutex */
 	{
 		return NULL;
@@ -183,7 +182,7 @@ static struct starpu_task *pop_task_eager_policy(unsigned sched_ctx_id)
 	chosen_task = _starpu_fifo_pop_task(data->fifo, workerid);
 	if (!chosen_task)
 		/* Tell pushers that we are waiting for tasks for us */
-		starpu_bitmap_set(data->waiters, workerid);
+		starpu_bitmap_set(&data->waiters, workerid);
 
 	STARPU_PTHREAD_MUTEX_UNLOCK(&data->policy_mutex);
 	if(chosen_task &&_starpu_get_nsched_ctxs() > 1)

+ 7 - 8
src/sched_policies/eager_central_priority_policy.c

@@ -35,7 +35,7 @@ struct _starpu_eager_central_prio_data
 {
 	struct _starpu_prio_deque taskq;
 	starpu_pthread_mutex_t policy_mutex;
-	struct starpu_bitmap *waiters;
+	struct starpu_bitmap waiters;
 };
 
 /*
@@ -49,7 +49,7 @@ static void initialize_eager_center_priority_policy(unsigned sched_ctx_id)
 
 	/* only a single queue (even though there are several internaly) */
 	_starpu_prio_deque_init(&data->taskq);
-	data->waiters = starpu_bitmap_create();
+	starpu_bitmap_init(&data->waiters);
 
 	/* Tell helgrind that it's fine to check for empty fifo in
 	 * _starpu_priority_pop_task without actual mutex (it's just an
@@ -72,7 +72,6 @@ static void deinitialize_eager_center_priority_policy(unsigned sched_ctx_id)
 
 	/* deallocate the job queue */
 	_starpu_prio_deque_destroy(&data->taskq);
-	starpu_bitmap_destroy(data->waiters);
 
 	STARPU_PTHREAD_MUTEX_DESTROY(&data->policy_mutex);
 	free(data);
@@ -115,7 +114,7 @@ static int _starpu_priority_push_task(struct starpu_task *task)
 		unsigned worker = workers->get_next(workers, &it);
 
 #ifdef STARPU_NON_BLOCKING_DRIVERS
-		if (!starpu_bitmap_get(data->waiters, worker))
+		if (!starpu_bitmap_get(&data->waiters, worker))
 			/* This worker is not waiting for a task */
 			continue;
 #endif
@@ -124,7 +123,7 @@ static int _starpu_priority_push_task(struct starpu_task *task)
 		{
 			/* It can execute this one, tell him! */
 #ifdef STARPU_NON_BLOCKING_DRIVERS
-			starpu_bitmap_unset(data->waiters, worker);
+			starpu_bitmap_unset(&data->waiters, worker);
 			/* We really woke at least somebody, no need to wake somebody else */
 			break;
 #else
@@ -170,7 +169,7 @@ static struct starpu_task *_starpu_priority_pop_task(unsigned sched_ctx_id)
 	}
 
 #ifdef STARPU_NON_BLOCKING_DRIVERS
-	if (!STARPU_RUNNING_ON_VALGRIND && starpu_bitmap_get(data->waiters, workerid))
+	if (!STARPU_RUNNING_ON_VALGRIND && starpu_bitmap_get(&data->waiters, workerid))
 		/* Nobody woke us, avoid bothering the mutex */
 	{
 		return NULL;
@@ -197,7 +196,7 @@ static struct starpu_task *_starpu_priority_pop_task(unsigned sched_ctx_id)
 			if(worker != workerid)
 			{
 #ifdef STARPU_NON_BLOCKING_DRIVERS
-				starpu_bitmap_unset(data->waiters, worker);
+				starpu_bitmap_unset(&data->waiters, worker);
 #else
 				starpu_wake_worker_relax_light(worker);
 #endif
@@ -208,7 +207,7 @@ static struct starpu_task *_starpu_priority_pop_task(unsigned sched_ctx_id)
 
 	if (!chosen_task)
 		/* Tell pushers that we are waiting for tasks for us */
-		starpu_bitmap_set(data->waiters, workerid);
+		starpu_bitmap_set(&data->waiters, workerid);
 
 	STARPU_PTHREAD_MUTEX_UNLOCK(&data->policy_mutex);
 	if(chosen_task &&_starpu_get_nsched_ctxs() > 1)

+ 7 - 8
src/sched_policies/graph_test_policy.c

@@ -40,7 +40,7 @@ struct _starpu_graph_test_policy_data
 	struct _starpu_prio_deque prio_cpu;
 	struct _starpu_prio_deque prio_gpu;
 	starpu_pthread_mutex_t policy_mutex;
-	struct starpu_bitmap *waiters;
+	struct starpu_bitmap waiters;
 	unsigned computed;
 	unsigned descendants;			/* Whether we use descendants, or depths, for priorities */
 };
@@ -54,7 +54,7 @@ static void initialize_graph_test_policy(unsigned sched_ctx_id)
 	data->fifo =  _starpu_create_fifo();
 	 _starpu_prio_deque_init(&data->prio_cpu);
 	 _starpu_prio_deque_init(&data->prio_gpu);
-	data->waiters = starpu_bitmap_create();
+	starpu_bitmap_init(&data->waiters);
 	data->computed = 0;
 	data->descendants = starpu_get_env_number_default("STARPU_SCHED_GRAPH_TEST_DESCENDANTS", 0);
 
@@ -80,7 +80,6 @@ static void deinitialize_graph_test_policy(unsigned sched_ctx_id)
 	_starpu_destroy_fifo(fifo);
 	 _starpu_prio_deque_destroy(&data->prio_cpu);
 	 _starpu_prio_deque_destroy(&data->prio_gpu);
-	starpu_bitmap_destroy(data->waiters);
 
 	_starpu_graph_record = 0;
 	STARPU_PTHREAD_MUTEX_DESTROY(&data->policy_mutex);
@@ -210,7 +209,7 @@ static void do_schedule_graph_test_policy(unsigned sched_ctx_id)
 	{
 		/* Tell each worker is shouldn't sleep any more */
 		unsigned worker = workers->get_next(workers, &it);
-		starpu_bitmap_unset(data->waiters, worker);
+		starpu_bitmap_unset(&data->waiters, worker);
 	}
 #endif
 	STARPU_PTHREAD_MUTEX_UNLOCK(&data->policy_mutex);
@@ -266,7 +265,7 @@ static int push_task_graph_test_policy(struct starpu_task *task)
 		unsigned worker = workers->get_next(workers, &it);
 
 #ifdef STARPU_NON_BLOCKING_DRIVERS
-		if (!starpu_bitmap_get(data->waiters, worker))
+		if (!starpu_bitmap_get(&data->waiters, worker))
 			/* This worker is not waiting for a task */
 			continue;
 #endif
@@ -281,7 +280,7 @@ static int push_task_graph_test_policy(struct starpu_task *task)
 		{
 			/* It can execute this one, tell him! */
 #ifdef STARPU_NON_BLOCKING_DRIVERS
-			starpu_bitmap_unset(data->waiters, worker);
+			starpu_bitmap_unset(&data->waiters, worker);
 			/* We really woke at least somebody, no need to wake somebody else */
 			break;
 #else
@@ -333,7 +332,7 @@ static struct starpu_task *pop_task_graph_test_policy(unsigned sched_ctx_id)
 	if (!STARPU_RUNNING_ON_VALGRIND && !data->computed)
 		/* Not computed yet */
 		return NULL;
-	if (!STARPU_RUNNING_ON_VALGRIND && starpu_bitmap_get(data->waiters, workerid))
+	if (!STARPU_RUNNING_ON_VALGRIND && starpu_bitmap_get(&data->waiters, workerid))
 		/* Nobody woke us, avoid bothering the mutex */
 		return NULL;
 #endif
@@ -350,7 +349,7 @@ static struct starpu_task *pop_task_graph_test_policy(unsigned sched_ctx_id)
 	chosen_task = _starpu_prio_deque_pop_task_for_worker(prio, workerid, NULL);
 	if (!chosen_task)
 		/* Tell pushers that we are waiting for tasks for us */
-		starpu_bitmap_set(data->waiters, workerid);
+		starpu_bitmap_set(&data->waiters, workerid);
 
 	STARPU_PTHREAD_MUTEX_UNLOCK(&data->policy_mutex);
 

+ 6 - 8
src/sched_policies/heteroprio.c

@@ -88,7 +88,7 @@ struct _heteroprio_worker_wrapper
 struct _starpu_heteroprio_data
 {
 	starpu_pthread_mutex_t policy_mutex;
-	struct starpu_bitmap *waiters;
+	struct starpu_bitmap waiters;
 	/* The bucket to store the tasks */
 	struct _heteroprio_bucket buckets[STARPU_HETEROPRIO_MAX_PRIO];
 	/* The number of buckets for each arch */
@@ -216,7 +216,7 @@ static void initialize_heteroprio_policy(unsigned sched_ctx_id)
 	_STARPU_MALLOC(hp, sizeof(struct _starpu_heteroprio_data));
 	memset(hp, 0, sizeof(*hp));
 
-	hp->waiters = starpu_bitmap_create();
+	starpu_bitmap_init(&hp->waiters);
 
 	starpu_sched_ctx_set_policy_data(sched_ctx_id, (void*)hp);
 
@@ -295,8 +295,6 @@ static void deinitialize_heteroprio_policy(unsigned sched_ctx_id)
 		_heteroprio_bucket_release(&hp->buckets[idx_prio]);
 	}
 
-	starpu_bitmap_destroy(hp->waiters);
-
 	STARPU_PTHREAD_MUTEX_DESTROY(&hp->policy_mutex);
 	free(hp);
 }
@@ -404,7 +402,7 @@ static int push_task_heteroprio_policy(struct starpu_task *task)
 		unsigned worker = workers->get_next(workers, &it);
 
 #ifdef STARPU_NON_BLOCKING_DRIVERS
-		if (!starpu_bitmap_get(hp->waiters, worker))
+		if (!starpu_bitmap_get(&hp->waiters, worker))
 			/* This worker is not waiting for a task */
 			continue;
 #endif
@@ -413,7 +411,7 @@ static int push_task_heteroprio_policy(struct starpu_task *task)
 		{
 			/* It can execute this one, tell him! */
 #ifdef STARPU_NON_BLOCKING_DRIVERS
-			starpu_bitmap_unset(hp->waiters, worker);
+			starpu_bitmap_unset(&hp->waiters, worker);
 			/* We really woke at least somebody, no need to wake somebody else */
 			break;
 #else
@@ -455,7 +453,7 @@ static struct starpu_task *pop_task_heteroprio_policy(unsigned sched_ctx_id)
 		return NULL;
 	}
 
-	if (!STARPU_RUNNING_ON_VALGRIND && starpu_bitmap_get(hp->waiters, workerid))
+	if (!STARPU_RUNNING_ON_VALGRIND && starpu_bitmap_get(&hp->waiters, workerid))
 	{
 		/* Nobody woke us, avoid bothering the mutex */
 		return NULL;
@@ -602,7 +600,7 @@ done:		;
 	if (!task)
 	{
 		/* Tell pushers that we are waiting for tasks_queue for us */
-		starpu_bitmap_set(hp->waiters, workerid);
+		starpu_bitmap_set(&hp->waiters, workerid);
 	}
 	STARPU_PTHREAD_MUTEX_UNLOCK(&hp->policy_mutex);
 

+ 4 - 4
src/sched_policies/modular_gemm.c

@@ -119,9 +119,9 @@ static int gemm_push_task(struct starpu_sched_component * component, struct star
 
 	int workerid;
 	/* It's not a GEMM, or no GPU wanted to take it, find somebody else */
-	for(workerid = starpu_bitmap_first(component->workers_in_ctx);
+	for(workerid = starpu_bitmap_first(&component->workers_in_ctx);
 	    workerid != -1;
-	    workerid = starpu_bitmap_next(component->workers_in_ctx, workerid))
+	    workerid = starpu_bitmap_next(&component->workers_in_ctx, workerid))
 	{
 		int nimpl;
 		for(nimpl = 0; nimpl < STARPU_MAXIMPLEMENTATIONS; nimpl++)
@@ -133,9 +133,9 @@ static int gemm_push_task(struct starpu_sched_component * component, struct star
 				{
 					struct starpu_sched_component *child = component->children[i];
 					int idworker;
-					for(idworker = starpu_bitmap_first(component->children[i]->workers);
+					for(idworker = starpu_bitmap_first(&component->children[i]->workers);
 						idworker != -1;
-						idworker = starpu_bitmap_next(component->children[i]->workers, idworker))
+						idworker = starpu_bitmap_next(&component->children[i]->workers, idworker))
 					{
 						if (idworker == workerid)
 						{