浏览代码

merge fixes

Andra Hugo 13 年之前
父节点
当前提交
87fae9aa61

+ 8 - 2
examples/cholesky/cholesky_implicit.c

@@ -17,7 +17,7 @@
  */
 
 #include "cholesky.h"
-
+#include "../sched_ctx_utils/sched_ctx_utils.h"
 /*
  *	Create the codelets
  */
@@ -193,6 +193,7 @@ static int cholesky(float *matA, unsigned size, unsigned ld, unsigned nblocks)
 
 static void execute_cholesky(unsigned size, unsigned nblocks)
 {
+	int ret;
 	float *mat;
 	starpu_malloc((void **)&mat, (size_t)size*size*sizeof(float));
 
@@ -320,7 +321,12 @@ int main(int argc, char **argv)
 	if(with_ctxs || with_noctxs || chole1 || chole2)
 		parse_args_ctx(argc, argv);
 
-	starpu_init(NULL);
+	int ret;
+	ret = starpu_init(NULL);
+
+	if (ret == -ENODEV)
+                return 77;
+        STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
 
 	starpu_helper_cublas_init();
 

+ 1 - 2
examples/sched_ctx_utils/sched_ctx_utils.c

@@ -27,7 +27,7 @@ typedef struct {
 	double avg_timing;
 } retvals;
 
-#define NSAMPLES 3
+#define NSAMPLES 1
 int first = 1;
 pthread_mutex_t mut;
 retvals rv[2];
@@ -92,7 +92,6 @@ void* start_bench(void *val){
 
 	rv[p->id].flops /= NSAMPLES;
 	rv[p->id].avg_timing /= NSAMPLES;
-	
 }
 
 void start_2benchs(void (*bench)(unsigned, unsigned))

+ 1 - 1
include/starpu.h

@@ -88,7 +88,7 @@ int starpu_conf_init(struct starpu_conf *conf);
 /* Initialization method: it must be called prior to any other StarPU call
  * Default configuration is used if NULL is passed as argument.
  */
-int starpu_init(struct starpu_conf *conf) STARPU_WARN_UNUSED_RESULT;
+int starpu_init(struct starpu_conf *conf);// STARPU_WARN_UNUSED_RESULT;
 
 /* Shutdown method: note that statistics are only generated once StarPU is
  * shutdown */

+ 1 - 1
include/starpu_scheduler.h

@@ -145,7 +145,7 @@ struct starpu_performance_counters {
 };
 
 #ifdef STARPU_BUILD_SCHED_CTX_HYPERVISOR
-unsigned starpu_create_sched_ctx_with_perf_counters(const char *policy_name, int *workerids_ctx, int nworkers_ctx, const char *sched_name, struct starpu_performance_counters **perf_counters);
+unsigned starpu_create_sched_ctx_with_perf_counters(const char *policy_name, int *workerids_ctx, int nworkers_ctx, const char *sched_name, struct starpu_performance_counters *perf_counters);
 void starpu_call_poped_task_cb(int workerid, unsigned sched_ctx_id, double flops);
 void starpu_call_pushed_task_cb(int workerid, unsigned sched_ctx_id);
 #endif //STARPU_BUILD_SCHED_CTX_HYPERVISOR

+ 2 - 2
include/starpu_task.h

@@ -300,14 +300,14 @@ struct starpu_task *starpu_task_create(void);
  * structure (default behaviour). Calling this function on a statically
  * allocated task results in an undefined behaviour. */
 void starpu_task_destroy(struct starpu_task *task);
-int starpu_task_submit(struct starpu_task *task) STARPU_WARN_UNUSED_RESULT;
+int starpu_task_submit(struct starpu_task *task);// STARPU_WARN_UNUSED_RESULT;
 
 /* This function blocks until the task was executed. It is not possible to
  * synchronize with a task more than once. It is not possible to wait
  * synchronous or detached tasks.
  * Upon successful completion, this function returns 0. Otherwise, -EINVAL
  * indicates that the waited task was either synchronous or detached. */
-int starpu_task_wait(struct starpu_task *task) STARPU_WARN_UNUSED_RESULT;
+int starpu_task_wait(struct starpu_task *task);// STARPU_WARN_UNUSED_RESULT;
 
 /* This function waits until all the tasks that were already submitted have
  * been executed. */

+ 1 - 1
sched_ctx_hypervisor/src/sched_ctx_hypervisor.c

@@ -97,7 +97,7 @@ static struct hypervisor_policy *_select_hypervisor_policy(struct hypervisor_pol
 
 
 /* initializez the performance counters that starpu will use to retrive hints for resizing */
-struct starpu_performance_counters** sched_ctx_hypervisor_init(struct hypervisor_policy *hypervisor_policy)
+struct starpu_performance_counters* sched_ctx_hypervisor_init(struct hypervisor_policy *hypervisor_policy)
 {
 	hypervisor.min_tasks = 0;
 	hypervisor.nsched_ctxs = 0;

+ 2 - 4
src/core/jobs.c

@@ -150,8 +150,6 @@ void _starpu_wait_job(struct _starpu_job *j)
 void _starpu_handle_job_termination(struct _starpu_job *j, int workerid)
 {
 	struct starpu_task *task = j->task;
-	unsigned sched_ctx = task->sched_ctx;
-
 	_STARPU_PTHREAD_MUTEX_LOCK(&j->sync_mutex);
 
 	task->status = STARPU_TASK_FINISHED;
@@ -210,7 +208,7 @@ void _starpu_handle_job_termination(struct _starpu_job *j, int workerid)
 	{
 	  _starpu_sched_post_exec_hook(task);
 #ifdef STARPU_USE_SCHED_CTX_HYPERVISOR
-	  starpu_call_poped_task_cb(workerid, sched_ctx, task->flops);
+	  starpu_call_poped_task_cb(workerid, task->sched_ctx, task->flops);
 #endif //STARPU_USE_SCHED_CTX_HYPERVISOR
 	}
 
@@ -255,7 +253,7 @@ void _starpu_handle_job_termination(struct _starpu_job *j, int workerid)
 	_starpu_decrement_nsubmitted_tasks();
 	_starpu_decrement_nready_tasks();
 
-	_starpu_decrement_nsubmitted_tasks_of_sched_ctx(sched_ctx);
+	_starpu_decrement_nsubmitted_tasks_of_sched_ctx(task->sched_ctx);
 
 	if(workerid >= 0)
 		_starpu_decrement_nsubmitted_tasks_of_worker(workerid);

+ 32 - 42
src/core/sched_ctx.c

@@ -141,12 +141,13 @@ static void _starpu_add_workers_to_sched_ctx(struct _starpu_sched_ctx *sched_ctx
 	return;
 }
 
-static void _starpu_remove_workers_from_sched_ctx(struct _starpu_sched_ctx *sched_ctx, int *workerids, unsigned nworkers, 
-					    int *removed_workers, int *n_removed_workers)
+static void _starpu_remove_workers_from_sched_ctx(struct _starpu_sched_ctx *sched_ctx, int *workerids, 
+						  int nworkers, int *removed_workers, int *n_removed_workers)
 {
 	struct worker_collection *workers = sched_ctx->workers;
 
 	int i = 0;
+
 	for(i = 0; i < nworkers; i++)
 	{
 		if(workers->nworkers > 0)
@@ -156,7 +157,9 @@ static void _starpu_remove_workers_from_sched_ctx(struct _starpu_sched_ctx *sche
 				removed_workers[(*n_removed_workers)++] = worker;
 		}
 	}
-					   
+
+	if(*n_removed_workers)
+		sched_ctx->sched_policy->remove_workers(sched_ctx->id, removed_workers, *n_removed_workers);
 	return;
 }
 
@@ -194,7 +197,7 @@ struct _starpu_sched_ctx*  _starpu_create_sched_ctx(const char *policy_name, int
 
 	
 	/*init the strategy structs and the worker_collection of the ressources of the context */
-	_starpu_init_sched_policy(config, sched_ctx, sched_name);
+	_starpu_init_sched_policy(config, sched_ctx, policy_name);
 
 	/* construct the collection of workers(list/tree/etc.) */
 	sched_ctx->workers->workerids = sched_ctx->workers->init(sched_ctx->workers);
@@ -227,13 +230,16 @@ unsigned starpu_create_sched_ctx(const char *policy_name, int *workerids,
 	struct _starpu_sched_ctx *sched_ctx = _starpu_create_sched_ctx(policy_name, workerids, nworkers_ctx, 0, sched_name);
 
 	_starpu_update_workers(sched_ctx->workers->workerids, sched_ctx->workers->nworkers, sched_ctx->id);
+#ifdef STARPU_USE_SCHED_CTX_HYPERVISOR
+	sched_ctx->perf_counters = NULL;
+#endif
 	return sched_ctx->id;
 }
 
 #ifdef STARPU_USE_SCHED_CTX_HYPERVISOR
 unsigned starpu_create_sched_ctx_with_perf_counters(const char *policy_name, int *workerids, 
 				 int nworkers_ctx, const char *sched_name,
-				 struct starpu_performance_counters **perf_counters)
+				 struct starpu_performance_counters *perf_counters)
 {
 	unsigned sched_ctx_id = starpu_create_sched_ctx(policy_name, workerids, nworkers_ctx, sched_name);
 	struct _starpu_sched_ctx *sched_ctx = _starpu_get_sched_ctx_struct(sched_ctx_id);
@@ -242,10 +248,10 @@ unsigned starpu_create_sched_ctx_with_perf_counters(const char *policy_name, int
 }
 #endif
 
-
 /* free all structures for the context */
-static void free_sched_ctx_mem(struct _starpu_sched_ctx *sched_ctx)
+static void _starpu_delete_sched_ctx(struct _starpu_sched_ctx *sched_ctx)
 {
+	_starpu_deinit_sched_policy(sched_ctx);		
 	free(sched_ctx->sched_policy);
 	free(sched_ctx->sched_mutex);
 	free(sched_ctx->sched_cond);
@@ -254,13 +260,14 @@ static void free_sched_ctx_mem(struct _starpu_sched_ctx *sched_ctx)
 	sched_ctx->sched_mutex = NULL;
 	sched_ctx->sched_cond = NULL;
 
+	_STARPU_PTHREAD_MUTEX_DESTROY(&sched_ctx->changing_ctx_mutex);
+	_STARPU_PTHREAD_MUTEX_DESTROY(&sched_ctx->empty_ctx_mutex);
 	_STARPU_PTHREAD_MUTEX_DESTROY(&sched_ctx->no_workers_mutex);
 	_STARPU_PTHREAD_COND_DESTROY(&sched_ctx->no_workers_cond);
 
 	struct _starpu_machine_config *config = _starpu_get_machine_config();
 	config->topology.nsched_ctxs--;
 	sched_ctx->id = STARPU_NMAX_SCHED_CTXS;
-
 }
 
 void starpu_delete_sched_ctx(unsigned sched_ctx_id, unsigned inheritor_sched_ctx_id)
@@ -281,14 +288,9 @@ void starpu_delete_sched_ctx(unsigned sched_ctx_id, unsigned inheritor_sched_ctx
 	{
 		starpu_add_workers_to_sched_ctx(sched_ctx->workers->workerids, sched_ctx->workers->nworkers, inheritor_sched_ctx_id);
 	}
-	
-	if(!starpu_wait_for_all_tasks_of_sched_ctx(sched_ctx_id))
-	{
-		_STARPU_PTHREAD_MUTEX_LOCK(&sched_ctx->changing_ctx_mutex);
-		free_sched_ctx_mem(sched_ctx);
-		_STARPU_PTHREAD_MUTEX_UNLOCK(&sched_ctx->changing_ctx_mutex);
-	}
 
+	if(!starpu_wait_for_all_tasks_of_sched_ctx(sched_ctx_id))
+		_starpu_delete_sched_ctx(sched_ctx);
 	return;	
 }
 
@@ -301,9 +303,8 @@ void _starpu_delete_all_sched_ctxs()
 		struct _starpu_sched_ctx *sched_ctx = _starpu_get_sched_ctx_struct(i);
 		if(sched_ctx->id != STARPU_NMAX_SCHED_CTXS)
 		{
-			_starpu_deinit_sched_policy(sched_ctx);		
 			_starpu_barrier_counter_destroy(&sched_ctx->tasks_barrier);
-			free_sched_ctx_mem(sched_ctx);
+			_starpu_delete_sched_ctx(sched_ctx);
 		}
 	}
 	return;
@@ -320,13 +321,11 @@ static void _starpu_check_workers(int *workerids, int nworkers)
 		/* take care the user does not ask for a resource that does not exist */
 		STARPU_ASSERT(workerids[i] >= 0 &&  workerids[i] <= nworkers_conf);
 	}		
-
 }
 
 void starpu_add_workers_to_sched_ctx(int *workers_to_add, int nworkers_to_add, unsigned sched_ctx_id)
 {
 	struct _starpu_sched_ctx *sched_ctx = _starpu_get_sched_ctx_struct(sched_ctx_id);
-	int init_workers = sched_ctx->workers->nworkers;
 	int added_workers[nworkers_to_add];
 	int n_added_workers = 0;
 
@@ -367,10 +366,9 @@ void starpu_add_workers_to_sched_ctx(int *workers_to_add, int nworkers_to_add, u
 void starpu_remove_workers_from_sched_ctx(int *workers_to_remove, int nworkers_to_remove, unsigned sched_ctx_id)
 {
 	struct _starpu_sched_ctx *sched_ctx = _starpu_get_sched_ctx_struct(sched_ctx_id);
-	int removed_workers[nworkers_to_remove];
+	int removed_workers[sched_ctx->workers->nworkers];
 	int n_removed_workers = 0;
 
-	STARPU_ASSERT(workers_to_remove != NULL && nworkers_to_remove > 0);
 	_starpu_check_workers(workers_to_remove, nworkers_to_remove);
 
 	_STARPU_PTHREAD_MUTEX_LOCK(&sched_ctx->changing_ctx_mutex);
@@ -519,20 +517,6 @@ void _starpu_increment_nsubmitted_tasks_of_sched_ctx(unsigned sched_ctx_id)
 	_starpu_barrier_counter_increment(&sched_ctx->tasks_barrier);
 }
 
-
-pthread_mutex_t *_starpu_get_sched_mutex(struct _starpu_sched_ctx *sched_ctx, int workerid)
-{
-	if(sched_ctx->sched_mutex)
-		return sched_ctx->sched_mutex[workerid];
-	else 
-		return NULL;
-}
-
-pthread_cond_t *_starpu_get_sched_cond(struct _starpu_sched_ctx *sched_ctx, int workerid)
-{
-	return sched_ctx->sched_cond[workerid];
-}
-
 void starpu_set_sched_ctx(unsigned *sched_ctx)
 {
 	pthread_setspecific(sched_ctx_key, (void*)sched_ctx);
@@ -543,7 +527,7 @@ unsigned starpu_get_sched_ctx()
 	unsigned *sched_ctx = (unsigned*)pthread_getspecific(sched_ctx_key);
 	if(sched_ctx == NULL)
 		return STARPU_NMAX_SCHED_CTXS;
-	STARPU_ASSERT(*sched_ctx >= 0 && *sched_ctx < STARPU_NMAX_SCHED_CTXS);
+	STARPU_ASSERT(*sched_ctx < STARPU_NMAX_SCHED_CTXS);
 	return *sched_ctx;
 }
 
@@ -565,6 +549,14 @@ void* starpu_get_sched_ctx_policy_data(unsigned sched_ctx_id)
 	return sched_ctx->policy_data;
 }
 
+pthread_mutex_t *_starpu_get_sched_mutex(struct _starpu_sched_ctx *sched_ctx, int workerid)
+{
+        if(sched_ctx->sched_mutex)
+                return sched_ctx->sched_mutex[workerid];
+	else
+                return NULL;
+}
+
 void starpu_worker_set_sched_condition(unsigned sched_ctx_id, int workerid, pthread_mutex_t *sched_mutex, pthread_cond_t *sched_cond)
 {
 	struct _starpu_sched_ctx *sched_ctx = _starpu_get_sched_ctx_struct(sched_ctx_id);
@@ -702,21 +694,19 @@ unsigned starpu_get_nshared_workers(unsigned sched_ctx_id, unsigned sched_ctx_id
 #ifdef STARPU_USE_SCHED_CTX_HYPERVISOR
 void starpu_call_poped_task_cb(int workerid, unsigned sched_ctx_id, double flops)
 {
-	struct _starpu_worker *worker =  _starpu_get_worker_struct(workerid);
 	struct _starpu_sched_ctx *sched_ctx = _starpu_get_sched_ctx_struct(sched_ctx_id);
 	if(sched_ctx != NULL && sched_ctx_id != 0 && sched_ctx_id != STARPU_NMAX_SCHED_CTXS
-		   && *sched_ctx->perf_counters != NULL)
-		(*sched_ctx->perf_counters)->notify_poped_task(sched_ctx_id, worker->workerid, flops);
+		   && sched_ctx->perf_counters != NULL)
+		sched_ctx->perf_counters->notify_poped_task(sched_ctx_id, workerid, flops);
 }
 
 void starpu_call_pushed_task_cb(int workerid, unsigned sched_ctx_id)
 {
-	struct _starpu_worker *worker =  _starpu_get_worker_struct(workerid);
 	struct _starpu_sched_ctx *sched_ctx = _starpu_get_sched_ctx_struct(sched_ctx_id);
 
 	if(sched_ctx != NULL && sched_ctx_id != 0)
-		if(*sched_ctx->perf_counters != NULL)
-			(*sched_ctx->perf_counters)->notify_pushed_task(sched_ctx_id, workerid);
+		if(sched_ctx->perf_counters != NULL)
+			sched_ctx->perf_counters->notify_pushed_task(sched_ctx_id, workerid);
 
 }
 

+ 1 - 1
src/core/sched_ctx.h

@@ -71,7 +71,7 @@ struct _starpu_sched_ctx {
 
 #ifdef STARPU_USE_SCHED_CTX_HYPERVISOR
 	/* a structure containing a series of performance counters determining the resize procedure */
-	struct starpu_performance_counters **perf_counters;
+	struct starpu_performance_counters *perf_counters;
 #endif //STARPU_USE_SCHED_CTX_HYPERVISOR
 };
 

+ 6 - 7
src/core/sched_policy.c

@@ -583,20 +583,19 @@ profiling:
 
 #ifdef STARPU_USE_SCHED_CTX_HYPERVISOR
 	struct _starpu_sched_ctx *sched_ctx = NULL;
-	struct starpu_performance_counters **perf_counters = NULL;
+	struct starpu_performance_counters *perf_counters = NULL;
 	for(i = 0; i < STARPU_NMAX_SCHED_CTXS; i++)
 	{
 		sched_ctx = worker->sched_ctx[i];
 		if(sched_ctx != NULL && sched_ctx->id != 0)
 		{
 			perf_counters = sched_ctx->perf_counters;
-			if(perf_counters != NULL && *perf_counters != NULL && 
-			   (*perf_counters)->notify_idle_cycle && (*perf_counters)->notify_idle_end)
+			if(perf_counters != NULL && perf_counters->notify_idle_cycle && perf_counters->notify_idle_end)
 			{
 				if(!task)
-					(*perf_counters)->notify_idle_cycle(sched_ctx->id, worker->workerid, 1.0);
+					perf_counters->notify_idle_cycle(sched_ctx->id, worker->workerid, 1.0);
 				else
-					(*perf_counters)->notify_idle_end(sched_ctx->id, worker->workerid);
+					perf_counters->notify_idle_end(sched_ctx->id, worker->workerid);
 			}
 		}
 	}
@@ -628,8 +627,8 @@ void _starpu_sched_post_exec_hook(struct starpu_task *task)
 
 #ifdef STARPU_USE_SCHED_CTX_HYPERVISOR
 	if(task->hypervisor_tag > 0 && sched_ctx != NULL && 
-	   sched_ctx->id != 0 && *sched_ctx->perf_counters != NULL)
-		(*sched_ctx->perf_counters)->notify_post_exec_hook(sched_ctx->id, task->hypervisor_tag);
+	   sched_ctx->id != 0 && sched_ctx->perf_counters != NULL)
+		sched_ctx->perf_counters->notify_post_exec_hook(sched_ctx->id, task->hypervisor_tag);
 #endif //STARPU_USE_SCHED_CTX_HYPERVISOR
 
 	if (sched_ctx->sched_policy->post_exec_hook)

+ 2 - 2
src/core/task.c

@@ -466,7 +466,7 @@ int _starpu_task_submit_nodeps(struct starpu_task *task)
 
 	struct _starpu_job *j = _starpu_get_job_associated_to_task(task);
 	_starpu_increment_nsubmitted_tasks();
-
+//	_starpu_increment_nsubmitted_tasks_of_sched_ctx(task->sched_ctx);
 	_STARPU_PTHREAD_MUTEX_LOCK(&j->sync_mutex);
 
 	j->submitted = 1;
@@ -508,6 +508,7 @@ int _starpu_task_submit_conversion_task(struct starpu_task *task,
 
 	struct _starpu_job *j = _starpu_get_job_associated_to_task(task);
 	_starpu_increment_nsubmitted_tasks();
+//	_starpu_increment_nsubmitted_tasks_of_sched_ctx(task->sched_ctx);
 	_STARPU_PTHREAD_MUTEX_LOCK(&j->sync_mutex);
 	j->submitted = 1;
 	_starpu_increment_nready_tasks();
@@ -579,7 +580,6 @@ int starpu_task_wait_for_all(void)
 	unsigned nsched_ctxs = _starpu_get_nsched_ctxs();
 	unsigned sched_ctx = nsched_ctxs == 1 ? 0 : starpu_get_sched_ctx();
 	starpu_wait_for_all_tasks_of_sched_ctx(sched_ctx);
-
 	return 0;
 }
 

+ 8 - 17
src/sched_policies/heft.c

@@ -219,7 +219,6 @@ static int push_task_on_best_worker(struct starpu_task *task, int best_workerid,
  {
 	/* make sure someone coule execute that task ! */
 	STARPU_ASSERT(best_workerid != -1);
-
 	_starpu_increment_nsubmitted_tasks_of_worker(best_workerid);
 
 	pthread_mutex_t *sched_mutex;
@@ -296,7 +295,7 @@ static void compute_all_performance_predictions(struct starpu_task *task,
 
 	/* A priori, we know all estimations */
 	int unknown = 0;
-	unsigned worker, worker_ctx = 0;
+	int worker, worker_ctx = 0;
 	unsigned nimpl;
 
 	struct worker_collection *workers = starpu_get_worker_collection_of_sched_ctx(sched_ctx_id);
@@ -304,7 +303,6 @@ static void compute_all_performance_predictions(struct starpu_task *task,
 	while(workers->has_next(workers))
 	{
 		worker = workers->get_next(workers);
-		unsigned incremented = 0;
 		for (nimpl = 0; nimpl <STARPU_MAXIMPLEMENTATIONS; nimpl++) 
 		{
 			/* Sometimes workers didn't take the tasks as early as we expected */
@@ -320,10 +318,7 @@ static void compute_all_performance_predictions(struct starpu_task *task,
 			if (!starpu_worker_can_execute_task(worker, task, nimpl))
 			{
 				/* no one on that queue may execute this task */
-
-				if(!incremented)
-					worker_ctx++;
-				incremented = 1;
+//				worker_ctx++;
 				continue;
 			}
 
@@ -389,8 +384,7 @@ static void compute_all_performance_predictions(struct starpu_task *task,
 				local_power[worker_ctx][nimpl] = 0.;
 
 		}
-		if(!incremented)
-			worker_ctx++;
+		worker_ctx++;
 	}
 
 	*forced_worker = unknown?ntasks_best:-1;
@@ -443,7 +437,8 @@ static int push_conversion_tasks(struct starpu_task *task, unsigned int workerid
 static int _heft_push_task(struct starpu_task *task, unsigned prio, unsigned sched_ctx_id)
 {
 	heft_data *hd = (heft_data*)starpu_get_sched_ctx_policy_data(sched_ctx_id);
-	unsigned worker, nimpl, worker_ctx = 0;
+	int worker, worker_ctx = 0;
+	unsigned nimpl;
 	int best = -1, best_in_ctx = -1;
 	int selected_impl= -1;
 
@@ -467,7 +462,7 @@ static int _heft_push_task(struct starpu_task *task, unsigned prio, unsigned sch
 	 *	and detect if there is some calibration that needs to be done.
 	 */
 
-	starpu_task_bundle_t bundle = task->bundle;
+	starpu_task_bundle_t bundle = NULL; //task->bundle;
 
 	if(workers->init_cursor)
 		workers->init_cursor(workers);
@@ -492,7 +487,6 @@ static int _heft_push_task(struct starpu_task *task, unsigned prio, unsigned sch
 			push_conversion_tasks(task, forced_worker);
 			prio = 0;
 		}
-
 		return push_task_on_best_worker(task, forced_worker, 0.0, 0.0, prio, sched_ctx_id);
 	}
 
@@ -508,14 +502,12 @@ static int _heft_push_task(struct starpu_task *task, unsigned prio, unsigned sch
 	while(workers->has_next(workers))
 	{
 		worker = workers->get_next(workers);
-		unsigned incremented = 0;
 		for (nimpl = 0; nimpl < STARPU_MAXIMPLEMENTATIONS; nimpl++)
 		{
 			if (!starpu_worker_can_execute_task(worker, task, nimpl))
 			{
 				/* no one on that queue may execute this task */
-				if(!incremented)
-					worker_ctx++;
+				//worker_ctx++;
 				continue;
 			}
 
@@ -539,8 +531,7 @@ static int _heft_push_task(struct starpu_task *task, unsigned prio, unsigned sch
 				selected_impl = nimpl;
 			}
 		}
-		if(!incremented)
-			worker_ctx++;
+		worker_ctx++;
 	}
 
 	/* By now, we must have found a solution */

+ 2 - 1
src/sched_policies/parallel_greedy.c

@@ -168,8 +168,9 @@ static void deinitialize_pgreedy_policy(unsigned sched_ctx_id)
 	free(data);	
 }
 
-static int push_task_pgreedy_policy(struct starpu_task *task, unsigned sched_ctx_id)
+static int push_task_pgreedy_policy(struct starpu_task *task)
 {
+	unsigned sched_ctx_id = task->sched_ctx;
 	pthread_mutex_t *changing_ctx_mutex = starpu_get_changing_ctx_mutex(sched_ctx_id);
 	unsigned nworkers;
         int ret_val = -1;