Prechádzať zdrojové kódy

fix bugs detected by coverity

Nathalie Furmento 9 rokov pred
rodič
commit
6cc8dcb563

+ 25 - 25
sc_hypervisor/src/hypervisor_policies/feft_lp_policy.c

@@ -33,7 +33,7 @@ static void _try_resizing(unsigned *sched_ctxs, int nsched_ctxs, int *workers, i
 
 	unsigned *curr_sched_ctxs = sched_ctxs == NULL ? sc_hypervisor_get_sched_ctxs() : sched_ctxs;
 	unsigned curr_nworkers = nworkers == -1 ? starpu_worker_get_count() : (unsigned)nworkers;
-	
+
 	struct types_of_workers *tw = sc_hypervisor_get_types_of_workers(workers, curr_nworkers);
 	int nw = tw->nw;
 	double nworkers_per_ctx[ns][nw];
@@ -41,17 +41,17 @@ static void _try_resizing(unsigned *sched_ctxs, int nsched_ctxs, int *workers, i
 	int total_nw[nw];
 	sc_hypervisor_group_workers_by_type(tw, total_nw);
 
-	
+
 	struct timeval start_time;
 	struct timeval end_time;
 	gettimeofday(&start_time, NULL);
-	
+
 	double vmax = sc_hypervisor_lp_get_nworkers_per_ctx(ns, nw, nworkers_per_ctx, total_nw, tw, sched_ctxs);
 	gettimeofday(&end_time, NULL);
-	
+
 	long diff_s = end_time.tv_sec  - start_time.tv_sec;
 	long diff_us = end_time.tv_usec  - start_time.tv_usec;
-	
+
 	__attribute__((unused))	float timing = (float)(diff_s*1000000 + diff_us)/1000.0;
 
 	if(vmax != -1.0)
@@ -88,7 +88,7 @@ static void _try_resizing_hierarchically(unsigned levels, unsigned current_level
 			int *pus_father;
 			unsigned npus_father = 0;
 			npus_father = starpu_sched_ctx_get_workers_list(sched_ctxs[s], &pus_father);
-			
+
 			_try_resizing_hierarchically(levels-1, current_level+1, sched_ctxs_child, nsched_ctxs_child, pus_father, npus_father);
 
 			free(pus_father);
@@ -133,7 +133,7 @@ static void _resize(unsigned *sched_ctxs, int nsched_ctxs, int *workers, int nwo
 			unsigned *sched_ctxs2;
 			int nsched_ctxs2;
 			sc_hypervisor_get_ctxs_on_level(&sched_ctxs2, &nsched_ctxs2, 0, STARPU_NMAX_SCHED_CTXS);
-			
+
 			if(nsched_ctxs2  > 0)
 			{
 				_try_resizing_hierarchically(nhierarchy_levels, 0, sched_ctxs2, nsched_ctxs2, workers, nworkers);
@@ -145,7 +145,7 @@ static void _resize(unsigned *sched_ctxs, int nsched_ctxs, int *workers, int nwo
 			unsigned first_level[nsched_ctxs];
 			int nsched_ctxs_first_level = 0;
 			int min = _get_first_level(sched_ctxs, nsched_ctxs, first_level, &nsched_ctxs_first_level);
-			
+
 			_try_resizing_hierarchically(nhierarchy_levels, min, first_level, nsched_ctxs_first_level, workers, nworkers);
 		}
 	}
@@ -159,11 +159,11 @@ static void _resize_if_speed_diff(unsigned sched_ctx, int worker)
 	unsigned nhierarchy_levels = sc_hypervisor_get_nhierarchy_levels();
 	if(nhierarchy_levels > 1)
 	{
-		
+
 		unsigned current_level = starpu_sched_ctx_get_hierarchy_level(sched_ctx);
 		if(current_level == 0)
 		{
-			_resize(NULL, -1, NULL, -1);			
+			_resize(NULL, -1, NULL, -1);
 			return;
 		}
 
@@ -181,8 +181,8 @@ static void _resize_if_speed_diff(unsigned sched_ctx, int worker)
 			int npus_father = -1;
 			if(level > 0)
 				npus_father = starpu_sched_ctx_get_workers_list(father, &pus_father);
-			
-			
+
+
 			unsigned *sched_ctxs = NULL;
 			int nsched_ctxs = 0;
 			is_speed_diff = sc_hypervisor_check_speed_gap_btw_ctxs_on_level(level, pus_father, npus_father, father, &sched_ctxs, &nsched_ctxs);
@@ -217,17 +217,17 @@ static void _resize_if_speed_diff(unsigned sched_ctx, int worker)
 					sched_ctxs = NULL;
 					break;
 				}
-			}	
+			}
 			if(pus_father_old)
 				free(pus_father_old);
 			if(sched_ctxs_old)
 				free(sched_ctxs_old);
-			
+
 			pus_father_old = pus_father;
 			sched_ctxs_old = sched_ctxs;
 			npus_father_old = npus_father;
 			nsched_ctxs_old = nsched_ctxs;
-			
+
 			father = level > 1 ? starpu_sched_ctx_get_inheritor(father) : STARPU_NMAX_SCHED_CTXS;
 		}
 		if(is_speed_diff)
@@ -240,7 +240,7 @@ static void _resize_if_speed_diff(unsigned sched_ctx, int worker)
 			_resize(NULL, -1, NULL, -1);
 		}
 	}
-	else 
+	else
 	{
 		unsigned criteria = sc_hypervisor_get_resize_criteria();
 		if(criteria != SC_NOTHING && criteria == SC_IDLE)
@@ -257,7 +257,7 @@ static void _resize_if_speed_diff(unsigned sched_ctx, int worker)
 	return;
 }
 
-static void feft_lp_handle_poped_task(unsigned sched_ctx, int worker, 
+static void feft_lp_handle_poped_task(unsigned sched_ctx, int worker,
 				      __attribute__((unused))struct starpu_task *task, __attribute__((unused))uint32_t footprint)
 {
 	if(worker == -2) return;
@@ -269,14 +269,14 @@ static void feft_lp_handle_poped_task(unsigned sched_ctx, int worker,
 		if(ret != EBUSY)
 		{
 			_resize_if_speed_diff(sched_ctx, worker);
-			starpu_pthread_mutex_unlock(&act_hypervisor_mutex);
+			STARPU_PTHREAD_MUTEX_UNLOCK(&act_hypervisor_mutex);
 		}
 	}
 }
 
 static void feft_lp_size_ctxs(unsigned *sched_ctxs, int nsched_ctxs, int *workers, int nworkers)
 {
-	starpu_pthread_mutex_lock(&act_hypervisor_mutex);
+	STARPU_PTHREAD_MUTEX_LOCK(&act_hypervisor_mutex);
 
 	struct sc_hypervisor_wrapper* sc_w  = NULL;
 	int s = 0;
@@ -290,7 +290,7 @@ static void feft_lp_size_ctxs(unsigned *sched_ctxs, int nsched_ctxs, int *worker
 #ifdef STARPU_SC_HYPERVISOR_DEBUG
 	printf("finished size ctxs\n");
 #endif
-	starpu_pthread_mutex_unlock(&act_hypervisor_mutex);
+	STARPU_PTHREAD_MUTEX_UNLOCK(&act_hypervisor_mutex);
 }
 
 static void _resize_leaves(int worker)
@@ -329,12 +329,12 @@ static void feft_lp_handle_idle_cycle(unsigned sched_ctx, int worker)
 		if(ret != EBUSY)
 		{
 			_resize_leaves(worker);
-			starpu_pthread_mutex_unlock(&act_hypervisor_mutex);
+			STARPU_PTHREAD_MUTEX_UNLOCK(&act_hypervisor_mutex);
 		}
 	}
 }
 
-static void feft_lp_resize_ctxs(unsigned *sched_ctxs, int nsched_ctxs , 
+static void feft_lp_resize_ctxs(unsigned *sched_ctxs, int nsched_ctxs ,
 				int *workers, int nworkers)
 {
 	int ret = starpu_pthread_mutex_trylock(&act_hypervisor_mutex);
@@ -345,17 +345,17 @@ static void feft_lp_resize_ctxs(unsigned *sched_ctxs, int nsched_ctxs ,
 		for(s = 0; s < nsched_ctxs; s++)
 		{
 			 sc_w = sc_hypervisor_get_wrapper(sched_ctxs[s]);
-			
+
 			 if((sc_w->submitted_flops + (0.1*sc_w->total_flops)) < sc_w->total_flops)
 			 {
-				 starpu_pthread_mutex_unlock(&act_hypervisor_mutex);
+				 STARPU_PTHREAD_MUTEX_UNLOCK(&act_hypervisor_mutex);
 				 return;
 			 }
 		}
 
 		_resize(sched_ctxs, nsched_ctxs, workers, nworkers);
 
-		starpu_pthread_mutex_unlock(&act_hypervisor_mutex);
+		STARPU_PTHREAD_MUTEX_UNLOCK(&act_hypervisor_mutex);
 	}
 }
 

+ 2 - 2
sc_hypervisor/src/hypervisor_policies/gflops_rate_policy.c

@@ -138,7 +138,7 @@ static unsigned _gflops_rate_resize(unsigned sender_sched_ctx, unsigned receiver
 {
         int ret = 1;
         if(force_resize)
-                starpu_pthread_mutex_lock(&act_hypervisor_mutex);
+                STARPU_PTHREAD_MUTEX_LOCK(&act_hypervisor_mutex);
         else
                 ret = starpu_pthread_mutex_trylock(&act_hypervisor_mutex);
         if(ret != EBUSY)
@@ -156,7 +156,7 @@ static unsigned _gflops_rate_resize(unsigned sender_sched_ctx, unsigned receiver
 
                         free(workers_to_move);
                 }
-                starpu_pthread_mutex_unlock(&act_hypervisor_mutex);
+                STARPU_PTHREAD_MUTEX_UNLOCK(&act_hypervisor_mutex);
                 return 1;
         }
         return 0;

+ 10 - 10
sc_hypervisor/src/hypervisor_policies/hard_coded_policy.c

@@ -35,7 +35,7 @@ void hard_coded_handle_idle_cycle(unsigned sched_ctx, int worker)
 	unsigned criteria = sc_hypervisor_get_resize_criteria();
         if(criteria != SC_NOTHING)// && criteria == SC_SPEED)
         {
-		
+
 		int ret = starpu_pthread_mutex_trylock(&act_hypervisor_mutex);
 		if(ret != EBUSY)
 		{
@@ -50,8 +50,8 @@ void hard_coded_handle_idle_cycle(unsigned sched_ctx, int worker)
 					//	sc_hypervisor_policy_resize_to_unknown_receiver(sched_ctx, 0);
 					unsigned *sched_ctxs = sc_hypervisor_get_sched_ctxs();
 					int ns = sc_hypervisor_get_nsched_ctxs();
-					
-				
+
+
 					int nworkers = (int)starpu_worker_get_count();
 					struct types_of_workers *tw = sc_hypervisor_get_types_of_workers(NULL, nworkers);
 					int nw = tw->nw;
@@ -66,8 +66,8 @@ void hard_coded_handle_idle_cycle(unsigned sched_ctx, int worker)
 					sc_hypervisor_lp_distribute_floating_no_resources_in_ctxs(sched_ctxs, ns, tw->nw, w_in_s, NULL, nworkers, tw);
 					free(tw);
 				}
-			}	
-			starpu_pthread_mutex_unlock(&act_hypervisor_mutex);
+			}
+			STARPU_PTHREAD_MUTEX_UNLOCK(&act_hypervisor_mutex);
 		}
 	}
 }
@@ -80,27 +80,27 @@ static void hard_coded_handle_poped_task(unsigned sched_ctx, __attribute__((unus
 		int ret = starpu_pthread_mutex_trylock(&act_hypervisor_mutex);
 		if(ret != EBUSY)
 		{
-			
+
 			if(sc_hypervisor_criteria_fulfilled(sched_ctx, worker))
-			{	
+			{
 				//	sc_hypervisor_policy_resize_to_unknown_receiver(sched_ctx, 0);
 				unsigned *sched_ctxs = sc_hypervisor_get_sched_ctxs();
 				int ns = sc_hypervisor_get_nsched_ctxs();
-				
+
 				int nworkers = (int)starpu_worker_get_count();
 				struct types_of_workers *tw = sc_hypervisor_get_types_of_workers(NULL, nworkers);
 				int nw = tw->nw;
 				double w_in_s[ns][nw];
 				w_in_s[0][0] = 1;
 				w_in_s[0][1] = 3;
-				
+
 				w_in_s[1][0] = 8;
 				w_in_s[1][1] = 0;
 //				sc_hypervisor_lp_place_resources_in_ctx(ns, nw, w_in_s, sched_ctxs, NULL, 1, tw);
 				sc_hypervisor_lp_distribute_floating_no_resources_in_ctxs(sched_ctxs, ns, tw->nw, w_in_s, NULL, nworkers, tw);
 				free(tw);
 			}
-			starpu_pthread_mutex_unlock(&act_hypervisor_mutex);
+			STARPU_PTHREAD_MUTEX_UNLOCK(&act_hypervisor_mutex);
 		}
 	}
 }

+ 3 - 3
sc_hypervisor/src/hypervisor_policies/ispeed_lp_policy.c

@@ -196,7 +196,7 @@ static void ispeed_lp_handle_poped_task(__attribute__((unused))unsigned sched_ct
                                 _try_resizing(NULL, -1, NULL, -1);
                         }
                 }
-                starpu_pthread_mutex_unlock(&act_hypervisor_mutex);
+                STARPU_PTHREAD_MUTEX_UNLOCK(&act_hypervisor_mutex);
         }
 }
 
@@ -214,7 +214,7 @@ static void ispeed_lp_handle_idle_cycle(unsigned sched_ctx, int worker)
                                 _try_resizing(NULL, -1, NULL, -1);
                         }
                 }
-                starpu_pthread_mutex_unlock(&act_hypervisor_mutex);
+                STARPU_PTHREAD_MUTEX_UNLOCK(&act_hypervisor_mutex);
         }
 }
 
@@ -224,7 +224,7 @@ static void ispeed_lp_resize_ctxs(unsigned *sched_ctxs, int nsched_ctxs , int *w
 	if(ret != EBUSY)
 	{
 		_try_resizing(sched_ctxs, nsched_ctxs, workers, nworkers);
-		starpu_pthread_mutex_unlock(&act_hypervisor_mutex);
+		STARPU_PTHREAD_MUTEX_UNLOCK(&act_hypervisor_mutex);
 	}
 }
 

+ 4 - 4
sc_hypervisor/src/hypervisor_policies/ispeed_policy.c

@@ -138,7 +138,7 @@ static int* _get_slowest_workers(unsigned sched_ctx, int *nworkers, enum starpu_
 		}
 	}
 	return curr_workers;
-}			
+}
 
 static void ispeed_handle_poped_task(unsigned sched_ctx, int worker, __attribute__((unused))struct starpu_task *task, __attribute__((unused))uint32_t footprint)
 {
@@ -163,20 +163,20 @@ static void ispeed_handle_poped_task(unsigned sched_ctx, int worker, __attribute
 							new_speed += sc_hypervisor_get_speed_per_worker(sc_hypervisor_get_wrapper(fastest_sched_ctx), workers_to_move[i]);
 						double fastest_speed = sc_hypervisor_get_ctx_speed(sc_hypervisor_get_wrapper(fastest_sched_ctx));
 						double slowest_speed = sc_hypervisor_get_ctx_speed(sc_hypervisor_get_wrapper(slowest_sched_ctx));
-//						printf("fast_speed(%d) %lf slow_speed(%d) %lf new speed(%d) %lf \n", fastest_sched_ctx, fastest_speed, slowest_sched_ctx, 
+//						printf("fast_speed(%d) %lf slow_speed(%d) %lf new speed(%d) %lf \n", fastest_sched_ctx, fastest_speed, slowest_sched_ctx,
 //						       slowest_speed, workers_to_move[0], new_speed);
 						if(fastest_speed != -1.0 && slowest_speed != -1.0 && (slowest_speed + new_speed) <= (fastest_speed - new_speed))
 						{
 							sc_hypervisor_move_workers(fastest_sched_ctx, slowest_sched_ctx, workers_to_move, nworkers_to_move, 0);
 						}
 					}
-					
+
 					free(workers_to_move);
 				}
 
 			}
 		}
-		starpu_pthread_mutex_unlock(&act_hypervisor_mutex);
+		STARPU_PTHREAD_MUTEX_UNLOCK(&act_hypervisor_mutex);
 	}
 }
 

+ 38 - 38
sc_hypervisor/src/hypervisor_policies/teft_lp_policy.c

@@ -24,7 +24,7 @@ static struct sc_hypervisor_policy_task_pool *task_pools = NULL;
 
 static starpu_pthread_mutex_t mutex = STARPU_PTHREAD_MUTEX_INITIALIZER;
 
-struct teft_lp_data 
+struct teft_lp_data
 {
 	int nt;
 	double **tasks;
@@ -34,7 +34,7 @@ struct teft_lp_data
 	unsigned size_ctxs;
 };
 
-static double _compute_workers_distrib(int ns, int nw, double final_w_in_s[ns][nw], 
+static double _compute_workers_distrib(int ns, int nw, double final_w_in_s[ns][nw],
 			   unsigned is_integer, double tmax, void *specific_data)
 {
 	struct teft_lp_data *sd = (struct teft_lp_data *)specific_data;
@@ -45,14 +45,14 @@ static double _compute_workers_distrib(int ns, int nw, double final_w_in_s[ns][n
 	int *workers = sd->workers;
 	struct sc_hypervisor_policy_task_pool *tmp_task_pools = sd->tmp_task_pools;
 	unsigned size_ctxs = sd->size_ctxs;
-		
+
 	if(tmp_task_pools == NULL)
 		return 0.0;
 
 	double w_in_s[ns][nw];
 	double tasks[nw][nt];
 	double times[nw][nt];
-	
+
 	/* times in ms */
 	sc_hypervisor_get_tasks_times(nw, nt, times, workers, size_ctxs, task_pools);
 
@@ -73,7 +73,7 @@ static double _compute_workers_distrib(int ns, int nw, double final_w_in_s[ns][n
 	}
 	return res;
 }
-	
+
 static void _size_ctxs(unsigned *sched_ctxs, int nsched_ctxs , int *workers, int nworkers)
 {
 	int ns = sched_ctxs == NULL ? sc_hypervisor_get_nsched_ctxs() : nsched_ctxs;
@@ -102,7 +102,7 @@ static void _size_ctxs(unsigned *sched_ctxs, int nsched_ctxs , int *workers, int
 	/* smallest possible tmax, difficult to obtain as we
 	   compute the nr of flops and not the tasks */
         /*lp computes it in s but it's converted to ms just before return */
-	double possible_tmax = sc_hypervisor_lp_get_tmax(nw, workers); 
+	double possible_tmax = sc_hypervisor_lp_get_tmax(nw, workers);
 	double smallest_tmax = possible_tmax / 3;
 	double tmax = possible_tmax * ns;
 	double tmin = 0.0;
@@ -110,7 +110,7 @@ static void _size_ctxs(unsigned *sched_ctxs, int nsched_ctxs , int *workers, int
 
 	if(nt > 0 && tmax > 0.0)
 	{
-		found_sol = sc_hypervisor_lp_execute_dichotomy(ns, nw, w_in_s, 1, (void*)&specific_data, 
+		found_sol = sc_hypervisor_lp_execute_dichotomy(ns, nw, w_in_s, 1, (void*)&specific_data,
 							       tmin, tmax, smallest_tmax, _compute_workers_distrib);
 	}
 
@@ -122,7 +122,7 @@ static void _size_ctxs(unsigned *sched_ctxs, int nsched_ctxs , int *workers, int
 		sc_hypervisor_lp_place_resources_in_ctx(ns, nw, w_in_s, sched_ctxs, workers, 1, tw);
 		free(tw);
 	}
-	
+
 	for(i = 0; i < nw; i++)
 		free(tasks[i]);
 	free(tasks);
@@ -141,7 +141,7 @@ static void size_if_required()
 		struct sc_hypervisor_wrapper* sc_w = NULL;
 		unsigned ready_to_size = 1;
 		int s;
-		starpu_pthread_mutex_lock(&act_hypervisor_mutex);
+		STARPU_PTHREAD_MUTEX_LOCK(&act_hypervisor_mutex);
 		for(s = 0; s < nsched_ctxs; s++)
 		{
 			sc_w = sc_hypervisor_get_wrapper(sched_ctxs[s]);
@@ -152,19 +152,19 @@ static void size_if_required()
 
 		if(ready_to_size)
 		{
-			_size_ctxs(sched_ctxs, nsched_ctxs, workers, nworkers);			
+			_size_ctxs(sched_ctxs, nsched_ctxs, workers, nworkers);
 			sc_hypervisor_free_size_req();
 		}
-		starpu_pthread_mutex_unlock(&act_hypervisor_mutex);
+		STARPU_PTHREAD_MUTEX_UNLOCK(&act_hypervisor_mutex);
 	}
 }
 
 static void teft_lp_handle_submitted_job(struct starpu_codelet *cl, unsigned sched_ctx, uint32_t footprint, size_t data_size)
 {
 	/* count the tasks of the same type */
-	starpu_pthread_mutex_lock(&mutex);
+	STARPU_PTHREAD_MUTEX_LOCK(&mutex);
 	sc_hypervisor_policy_add_task_to_pool(cl, sched_ctx, footprint, &task_pools, data_size);
-	starpu_pthread_mutex_unlock(&mutex);
+	STARPU_PTHREAD_MUTEX_UNLOCK(&mutex);
 
 	size_if_required();
 }
@@ -178,26 +178,26 @@ static void _try_resizing(unsigned *sched_ctxs, int nsched_ctxs , int *workers,
 	sched_ctxs = sched_ctxs == NULL ? sc_hypervisor_get_sched_ctxs() : sched_ctxs;
 
 	int nt = 0; /* Number of different kinds of tasks */
-	
-//	starpu_pthread_mutex_lock(&mutex);
-	
+
+//	STARPU_PTHREAD_MUTEX_LOCK(&mutex);
+
 	/* we don't take the mutex bc a correct value of the number of tasks is
 	   not required but we do a copy in order to be sure
-	   that the linear progr won't segfault if the list of 
+	   that the linear progr won't segfault if the list of
 	   submitted task will change during the exec */
-	
+
 	struct sc_hypervisor_policy_task_pool *tp = NULL;
 	struct sc_hypervisor_policy_task_pool *tmp_task_pools = sc_hypervisor_policy_clone_task_pool(task_pools);
-	
+
 	for (tp = task_pools; tp; tp = tp->next)
 		nt++;
-	
+
 	double w_in_s[ns][nw];
 	double **tasks_per_worker=(double**)malloc(nw*sizeof(double*));
 	int i;
 	for(i = 0; i < nw; i++)
 		tasks_per_worker[i] = (double*)malloc(nt*sizeof(double));
-	
+
 	struct teft_lp_data specific_data;
 	specific_data.nt = nt;
 	specific_data.tasks = tasks_per_worker;
@@ -220,19 +220,19 @@ static void _try_resizing(unsigned *sched_ctxs, int nsched_ctxs , int *workers,
 		struct timeval start_time;
 		struct timeval end_time;
 		gettimeofday(&start_time, NULL);
-		
-		
-		found_sol = sc_hypervisor_lp_execute_dichotomy(ns, nw, w_in_s, 1, (void*)&specific_data, 
+
+
+		found_sol = sc_hypervisor_lp_execute_dichotomy(ns, nw, w_in_s, 1, (void*)&specific_data,
 							       tmin, tmax, smallest_tmax, _compute_workers_distrib);
 		gettimeofday(&end_time, NULL);
-		
+
 		long diff_s = end_time.tv_sec  - start_time.tv_sec;
 		long diff_us = end_time.tv_usec  - start_time.tv_usec;
-		
+
 		__attribute__((unused))	float timing = (float)(diff_s*1000000 + diff_us)/1000.0;
 	}
-//	starpu_pthread_mutex_unlock(&mutex);
-	
+//	STARPU_PTHREAD_MUTEX_UNLOCK(&mutex);
+
 	/* if we did find at least one solution redistribute the resources */
 	if(found_sol)
 	{
@@ -240,7 +240,7 @@ static void _try_resizing(unsigned *sched_ctxs, int nsched_ctxs , int *workers,
 		sc_hypervisor_lp_place_resources_in_ctx(ns, nw, w_in_s, sched_ctxs, workers, 0, tw);
 		free(tw);
 	}
-	
+
 	struct sc_hypervisor_policy_task_pool *next = NULL;
 	struct sc_hypervisor_policy_task_pool *tmp_tp = tmp_task_pools;
 	while(tmp_task_pools)
@@ -265,20 +265,20 @@ static void teft_lp_handle_poped_task(unsigned sched_ctx, int worker, struct sta
 			unsigned criteria = sc_hypervisor_get_resize_criteria();
 			if(criteria != SC_NOTHING && criteria == SC_SPEED)
 			{
-				
+
 				if(sc_hypervisor_check_speed_gap_btw_ctxs(NULL, -1, NULL, -1))
 				{
 					_try_resizing(NULL, -1, NULL, -1);
 				}
 			}
-			
-			starpu_pthread_mutex_unlock(&act_hypervisor_mutex);
+
+			STARPU_PTHREAD_MUTEX_UNLOCK(&act_hypervisor_mutex);
 		}
 	}
 	/* too expensive to take this mutex and correct value of the number of tasks is not compulsory */
-	starpu_pthread_mutex_lock(&mutex);
+	STARPU_PTHREAD_MUTEX_LOCK(&mutex);
 	sc_hypervisor_policy_remove_task_from_pool(task, footprint, &task_pools);
-	starpu_pthread_mutex_unlock(&mutex);
+	STARPU_PTHREAD_MUTEX_UNLOCK(&mutex);
 
 }
 
@@ -291,7 +291,7 @@ static void teft_lp_handle_idle_cycle(unsigned sched_ctx, int worker)
 		if(ret != EBUSY)
 		{
 			_try_resizing(NULL, -1, NULL, -1);
-			starpu_pthread_mutex_unlock(&act_hypervisor_mutex);
+			STARPU_PTHREAD_MUTEX_UNLOCK(&act_hypervisor_mutex);
 		}
 	}
 	return;
@@ -312,17 +312,17 @@ static void teft_lp_resize_ctxs(unsigned *sched_ctxs, int nsched_ctxs , int *wor
 		for(s = 0; s < nsched_ctxs; s++)
 		{
 			 sc_w = sc_hypervisor_get_wrapper(sched_ctxs[s]);
-			
+
 			if((sc_w->submitted_flops + (0.1*sc_w->total_flops)) < sc_w->total_flops)
 			{
-				starpu_pthread_mutex_unlock(&act_hypervisor_mutex);
+				STARPU_PTHREAD_MUTEX_UNLOCK(&act_hypervisor_mutex);
 				return;
 			}
 		}
 
 
 		_try_resizing(sched_ctxs, nsched_ctxs, workers, nworkers);
-		starpu_pthread_mutex_unlock(&act_hypervisor_mutex);
+		STARPU_PTHREAD_MUTEX_UNLOCK(&act_hypervisor_mutex);
 	}
 }
 

+ 13 - 13
sc_hypervisor/src/hypervisor_policies/throughput_lp_policy.c

@@ -28,7 +28,7 @@ static unsigned _compute_max_speed(int ns, int nw, double w_in_s[ns][nw], unsign
 	double speed[ns][nw];
 
 	unsigned *sched_ctxs = in_sched_ctxs == NULL ? sc_hypervisor_get_sched_ctxs() : in_sched_ctxs;
-	
+
 	int w,s;
 
 	struct sc_hypervisor_wrapper* sc_w = NULL;
@@ -44,7 +44,7 @@ static unsigned _compute_max_speed(int ns, int nw, double w_in_s[ns][nw], unsign
 			speed[s][w] = sc_hypervisor_get_speed(sc_w, arch);
 		}
 	}
-	
+
 
 	struct timeval start_time;
 	struct timeval end_time;
@@ -90,7 +90,7 @@ static double _glp_resolve(int ns, int nw, double speed[ns][nw], double w_in_s[n
 		/* Variables:  x[s][w]
 		 the acknwoledgment that the worker w belongs to the context s */
 		glp_add_cols(lp, nw*ns + 1);
-		
+
 		for(s = 0; s < ns; s++)
 			for(w = 0; w < nw; w++)
 			{
@@ -159,7 +159,7 @@ static double _glp_resolve(int ns, int nw, double speed[ns][nw], double w_in_s[n
 				ar[n] = 1;
 				n++;
 			}
-			if(integer)				
+			if(integer)
 				glp_set_row_bnds(lp, curr_row_idx+w+1, GLP_FX, 1, 1);
 			else
 				glp_set_row_bnds(lp, curr_row_idx+w+1, GLP_FX, 1.0, 1.0);
@@ -229,7 +229,7 @@ static void _try_resizing(unsigned *sched_ctxs, int nsched_ctxs , int *workers,
 {
 	int ns = sched_ctxs == NULL ? sc_hypervisor_get_nsched_ctxs() : nsched_ctxs;
 	int nw = workers == NULL ? (int)starpu_worker_get_count() : nworkers; /* Number of different workers */
-	
+
 	sched_ctxs = sched_ctxs == NULL ? sc_hypervisor_get_sched_ctxs() : sched_ctxs;
 
 	double w_in_s[ns][nw];
@@ -249,7 +249,7 @@ static void _try_resizing(unsigned *sched_ctxs, int nsched_ctxs , int *workers,
 				nworkers_per_ctx_rounded[s][w] = 0;
 			}
 		}
-		
+
 		for(s = 0; s < ns; s++)
 		{
 			for(w = 0; w < nw; w++)
@@ -257,7 +257,7 @@ static void _try_resizing(unsigned *sched_ctxs, int nsched_ctxs , int *workers,
 				enum starpu_worker_archtype arch = starpu_worker_get_type(w);
 				int idx = sc_hypervisor_get_index_for_arch(STARPU_CUDA_WORKER, tw);
 				nworkers_per_ctx[s][idx] += w_in_s[s][w];
-				
+
 				if(arch == STARPU_CUDA_WORKER)
 				{
 					if(w_in_s[s][w] >= 0.3)
@@ -275,14 +275,14 @@ static void _try_resizing(unsigned *sched_ctxs, int nsched_ctxs , int *workers,
 /* 				for(s = 0; s < ns; s++) */
 /* 					printf("%d: cpus = %lf gpus = %lf cpus_round = %d gpus_round = %d\n", s, nworkers[s][1], nworkers[s][0], */
 /* 					       nworkers_rounded[s][1], nworkers_rounded[s][0]); */
-		
+
 
 		sc_hypervisor_lp_redistribute_resources_in_ctxs(ns, tw->nw, nworkers_per_ctx_rounded, nworkers_per_ctx, sched_ctxs, tw);
-		
+
 	}
 }
 
-static void throughput_lp_handle_poped_task(__attribute__((unused))unsigned sched_ctx, __attribute__((unused))int worker, 
+static void throughput_lp_handle_poped_task(__attribute__((unused))unsigned sched_ctx, __attribute__((unused))int worker,
 				       __attribute__((unused))struct starpu_task *task, __attribute__((unused))uint32_t footprint)
 {
 	int ret = starpu_pthread_mutex_trylock(&act_hypervisor_mutex);
@@ -296,7 +296,7 @@ static void throughput_lp_handle_poped_task(__attribute__((unused))unsigned sche
 				_try_resizing(NULL, -1, NULL, -1);
 			}
 		}
-                starpu_pthread_mutex_unlock(&act_hypervisor_mutex);
+                STARPU_PTHREAD_MUTEX_UNLOCK(&act_hypervisor_mutex);
 	}
 }
 
@@ -315,7 +315,7 @@ static void throughput_lp_handle_idle_cycle(unsigned sched_ctx, int worker)
 //                              sc_hypervisor_move_workers(sched_ctx, 3 - sched_ctx, &worker, 1, 1);
 			}
                 }
-                starpu_pthread_mutex_unlock(&act_hypervisor_mutex);
+                STARPU_PTHREAD_MUTEX_UNLOCK(&act_hypervisor_mutex);
         }
 }
 
@@ -325,7 +325,7 @@ static void throughput_lp_resize_ctxs(unsigned *sched_ctxs, int nsched_ctxs , in
 	if(ret != EBUSY)
 	{
 		_try_resizing(sched_ctxs, nsched_ctxs, workers, nworkers);
-		starpu_pthread_mutex_unlock(&act_hypervisor_mutex);
+		STARPU_PTHREAD_MUTEX_UNLOCK(&act_hypervisor_mutex);
 	}
 }
 

+ 16 - 16
sc_hypervisor/src/policies_utils/policy_tools.c

@@ -249,7 +249,7 @@ unsigned sc_hypervisor_policy_resize(unsigned sender_sched_ctx, unsigned receive
 {
 	int ret = 1;
 	if(force_resize)
-		starpu_pthread_mutex_lock(&act_hypervisor_mutex);
+		STARPU_PTHREAD_MUTEX_LOCK(&act_hypervisor_mutex);
 	else
 		ret = starpu_pthread_mutex_trylock(&act_hypervisor_mutex);
 	if(ret != EBUSY)
@@ -285,7 +285,7 @@ unsigned sc_hypervisor_policy_resize(unsigned sender_sched_ctx, unsigned receive
 				free(workers_to_move);
 			}
 		}
-		starpu_pthread_mutex_unlock(&act_hypervisor_mutex);
+		STARPU_PTHREAD_MUTEX_UNLOCK(&act_hypervisor_mutex);
 		return 1;
 	}
 	return 0;
@@ -307,7 +307,7 @@ double sc_hypervisor_get_slowest_ctx_exec_time(void)
 	double slowest_time = 0.0;
 
 	int s;
-	struct sc_hypervisor_wrapper* sc_w;		
+	struct sc_hypervisor_wrapper* sc_w;
 	for(s = 0; s < nsched_ctxs; s++)
 	{
 		sc_w = sc_hypervisor_get_wrapper(sched_ctxs[s]);
@@ -331,14 +331,14 @@ double sc_hypervisor_get_fastest_ctx_exec_time(void)
  	double fastest_time = curr_time;
 
 	int s;
-	struct sc_hypervisor_wrapper* sc_w;		
+	struct sc_hypervisor_wrapper* sc_w;
 	for(s = 0; s < nsched_ctxs; s++)
 	{
 		sc_w = sc_hypervisor_get_wrapper(sched_ctxs[s]);
 
 		struct sc_hypervisor_policy_config *config = sc_hypervisor_get_config(sc_w->sched_ctx);
 		double elapsed_time = (config->ispeed_ctx_sample/1000000000.0)/sc_hypervisor_get_ctx_speed(sc_w);
-		
+
 		if(elapsed_time < fastest_time)
 			fastest_time = elapsed_time;
 
@@ -385,7 +385,7 @@ enum starpu_worker_archtype sc_hypervisor_get_arch_for_index(unsigned w, struct
 
 unsigned sc_hypervisor_get_index_for_arch(enum starpu_worker_archtype arch, struct types_of_workers *tw)
 {
-	
+
 	if(arch == STARPU_CPU_WORKER)
 	{
 		if(tw->ncpus != 0)
@@ -434,7 +434,7 @@ void sc_hypervisor_get_tasks_times(int nw, int nt, double times[nw][nt], int *wo
 						double transfer_speed = starpu_transfer_bandwidth(STARPU_MAIN_RAM, starpu_worker_get_memory_node(worker));
 						if(transfer_speed > 0.0)
 							transfer_time +=  (tp->data_size / transfer_speed) / 1000. ;
-	
+
 						double latency = starpu_transfer_latency(STARPU_MAIN_RAM, starpu_worker_get_memory_node(worker));
 						transfer_time += latency/1000.;
 //						transfer_time *=4;
@@ -488,7 +488,7 @@ unsigned sc_hypervisor_check_speed_gap_btw_ctxs(unsigned *sched_ctxs_in, int ns_
 	struct sc_hypervisor_wrapper* sc_w;
 	struct sc_hypervisor_wrapper* other_sc_w;
 
-	
+
 	double optimal_v[ns];
 	unsigned has_opt_v = 1;
 	for(i = 0; i < ns; i++)
@@ -512,7 +512,7 @@ unsigned sc_hypervisor_check_speed_gap_btw_ctxs(unsigned *sched_ctxs_in, int ns_
 
 //		double vmax = sc_hypervisor_lp_get_nworkers_per_ctx(ns, nw, nworkers_per_ctx, total_nw, tw, sched_ctxs);
 
-		
+
 //		if(vmax != 0.0)
 		{
 			for(i = 0; i < ns; i++)
@@ -532,14 +532,14 @@ unsigned sc_hypervisor_check_speed_gap_btw_ctxs(unsigned *sched_ctxs_in, int ns_
 		}
 	}
 
-/* if we have an optimal speed for each type of worker compare the monitored one with the 
+/* if we have an optimal speed for each type of worker compare the monitored one with the
    theoretical one */
 	if(has_opt_v)
 	{
 		for(i = 0; i < ns; i++)
 		{
 			sc_w = sc_hypervisor_get_wrapper(sched_ctxs[i]);
-			
+
 			double ctx_v = sc_hypervisor_get_ctx_speed(sc_w);
 			if(ctx_v == -1.0)
 				return 0;
@@ -548,11 +548,11 @@ unsigned sc_hypervisor_check_speed_gap_btw_ctxs(unsigned *sched_ctxs_in, int ns_
 		for(i = 0; i < ns; i++)
 		{
 			sc_w = sc_hypervisor_get_wrapper(sched_ctxs[i]);
-			
+
 			double ctx_v = sc_hypervisor_get_ctx_speed(sc_w);
 			ctx_v = ctx_v < 0.01 ? 0.0 : ctx_v;
 			double max_vel = _get_max_speed_gap();
-			if(ctx_v != -1.0 && ((ctx_v < (1-max_vel)*optimal_v[i]) || ctx_v > (1+max_vel)*optimal_v[i])) 
+			if(ctx_v != -1.0 && ((ctx_v < (1-max_vel)*optimal_v[i]) || ctx_v > (1+max_vel)*optimal_v[i]))
 			{
 				return 1;
 			}
@@ -575,7 +575,7 @@ unsigned sc_hypervisor_check_speed_gap_btw_ctxs(unsigned *sched_ctxs_in, int ns_
 						unsigned nworkers = starpu_sched_ctx_get_nworkers(sched_ctxs[j]);
 						if(nworkers == 0)
 							return 1;
-						
+
 						other_sc_w = sc_hypervisor_get_wrapper(sched_ctxs[j]);
 						double other_ctx_v = sc_hypervisor_get_ctx_speed(other_sc_w);
 						if(other_ctx_v != -1.0)
@@ -588,7 +588,7 @@ unsigned sc_hypervisor_check_speed_gap_btw_ctxs(unsigned *sched_ctxs_in, int ns_
 					}
 				}
 			}
-			
+
 		}
 	}
 	return 0;
@@ -600,7 +600,7 @@ unsigned sc_hypervisor_check_speed_gap_btw_ctxs_on_level(int level, int *workers
 
 	if(*nsched_ctxs  > 0)
 		return sc_hypervisor_check_speed_gap_btw_ctxs(*sched_ctxs, *nsched_ctxs, workers_in, nworkers_in);
-	return 0;	
+	return 0;
 }
 
 unsigned sc_hypervisor_criteria_fulfilled(unsigned sched_ctx, int worker)

+ 2 - 2
sc_hypervisor/src/sc_config.c

@@ -248,9 +248,9 @@ void sc_hypervisor_ctl(unsigned sched_ctx, ...)
 		entry->task_tag = task_tag;
 		entry->configuration = config;
 
-		starpu_pthread_mutex_lock(&hypervisor.conf_mut[sched_ctx]);
+		STARPU_PTHREAD_MUTEX_LOCK(&hypervisor.conf_mut[sched_ctx]);
 		HASH_ADD_INT(hypervisor.configurations[sched_ctx], task_tag, entry);
-		starpu_pthread_mutex_unlock(&hypervisor.conf_mut[sched_ctx]);
+		STARPU_PTHREAD_MUTEX_UNLOCK(&hypervisor.conf_mut[sched_ctx]);
 	}
 
 	va_end(varg_list);

+ 92 - 92
sc_hypervisor/src/sc_hypervisor.c

@@ -25,7 +25,7 @@ struct starpu_sched_ctx_performance_counters* perf_counters = NULL;
 
 static void notify_idle_cycle(unsigned sched_ctx, int worker, double idle_time);
 static void notify_pushed_task(unsigned sched_ctx, int worker);
-static void notify_post_exec_task(struct starpu_task *task, size_t data_size, uint32_t footprint, 
+static void notify_post_exec_task(struct starpu_task *task, size_t data_size, uint32_t footprint,
 				  int hypervisor_tag, double flops);
 static void notify_poped_task(unsigned sched_ctx, int  worker);
 static void notify_submitted_job(struct starpu_task *task, unsigned footprint, size_t data_size);
@@ -158,7 +158,7 @@ static struct sc_hypervisor_policy *_select_hypervisor_policy(struct sc_hypervis
 
 /* initializez the performance counters that starpu will use to retrive hints for resizing */
 void* sc_hypervisor_init(struct sc_hypervisor_policy *hypervisor_policy)
-{	
+{
 /* Perhaps we have to display some help */
 	display_sched_help_message();
 
@@ -169,7 +169,7 @@ void* sc_hypervisor_init(struct sc_hypervisor_policy *hypervisor_policy)
 	char* crit =  getenv("SC_HYPERVISOR_TRIGGER_RESIZE");
 	hypervisor.resize_criteria = !crit ? SC_IDLE : strcmp(crit,"idle") == 0 ? SC_IDLE : (strcmp(crit,"speed") == 0 ? SC_SPEED : SC_NOTHING);
 
-	starpu_pthread_mutex_init(&act_hypervisor_mutex, NULL);
+	STARPU_PTHREAD_MUTEX_INIT(&act_hypervisor_mutex, NULL);
 //	hypervisor.start_executing_time = starpu_timing_now();
 
 	int i;
@@ -193,7 +193,7 @@ void* sc_hypervisor_init(struct sc_hypervisor_policy *hypervisor_policy)
 		hypervisor.sched_ctx_w[i].resize_ack.moved_workers = NULL;
 		hypervisor.sched_ctx_w[i].resize_ack.nmoved_workers = 0;
 		hypervisor.sched_ctx_w[i].resize_ack.acked_workers = NULL;
-		starpu_pthread_mutex_init(&hypervisor.sched_ctx_w[i].mutex, NULL);
+		STARPU_PTHREAD_MUTEX_INIT(&hypervisor.sched_ctx_w[i].mutex, NULL);
 		hypervisor.optimal_v[i] = 0.0;
 
 		hypervisor.sched_ctx_w[i].ref_speed[0] = -1.0;
@@ -280,7 +280,7 @@ static void _print_current_time()
 			if(hypervisor.sched_ctxs[i] != STARPU_NMAX_SCHED_CTXS)
 			{
 				struct sc_hypervisor_wrapper *sc_w = &hypervisor.sched_ctx_w[hypervisor.sched_ctxs[i]];
-				
+
 				double cpu_speed = sc_hypervisor_get_speed(sc_w, STARPU_CPU_WORKER);
 				double cuda_speed = sc_hypervisor_get_speed(sc_w, STARPU_CUDA_WORKER);
 				int ncpus = sc_hypervisor_get_nworkers_ctx(sc_w->sched_ctx, STARPU_CPU_WORKER);
@@ -301,7 +301,7 @@ void sc_hypervisor_shutdown(void)
 		{
 			sc_hypervisor_stop_resize(hypervisor.sched_ctxs[i]);
 			sc_hypervisor_unregister_ctx(hypervisor.sched_ctxs[i]);
-			starpu_pthread_mutex_destroy(&hypervisor.sched_ctx_w[i].mutex);
+			STARPU_PTHREAD_MUTEX_DESTROY(&hypervisor.sched_ctx_w[i].mutex);
 		}
 	}
 	perf_counters->notify_idle_cycle = NULL;
@@ -313,7 +313,7 @@ void sc_hypervisor_shutdown(void)
 	free(perf_counters);
 	perf_counters = NULL;
 
-	starpu_pthread_mutex_destroy(&act_hypervisor_mutex);
+	STARPU_PTHREAD_MUTEX_DESTROY(&act_hypervisor_mutex);
 
 }
 
@@ -338,11 +338,11 @@ void sc_hypervisor_register_ctx(unsigned sched_ctx, double total_flops)
 	if(hypervisor.policy.start_ctx)
 		hypervisor.policy.start_ctx(sched_ctx);
 
-	starpu_pthread_mutex_lock(&act_hypervisor_mutex);
+	STARPU_PTHREAD_MUTEX_LOCK(&act_hypervisor_mutex);
 	hypervisor.configurations[sched_ctx] = NULL;
 	hypervisor.resize_requests[sched_ctx] = NULL;
-	starpu_pthread_mutex_init(&hypervisor.conf_mut[sched_ctx], NULL);
-	starpu_pthread_mutex_init(&hypervisor.resize_mut[sched_ctx], NULL);
+	STARPU_PTHREAD_MUTEX_INIT(&hypervisor.conf_mut[sched_ctx], NULL);
+	STARPU_PTHREAD_MUTEX_INIT(&hypervisor.resize_mut[sched_ctx], NULL);
 
 	_add_config(sched_ctx);
 	hypervisor.sched_ctx_w[sched_ctx].sched_ctx = sched_ctx;
@@ -351,7 +351,7 @@ void sc_hypervisor_register_ctx(unsigned sched_ctx, double total_flops)
 	hypervisor.sched_ctx_w[sched_ctx].total_flops = total_flops;
 	hypervisor.sched_ctx_w[sched_ctx].remaining_flops = total_flops;
 	hypervisor.resize[sched_ctx] = 0;//1;
-	starpu_pthread_mutex_unlock(&act_hypervisor_mutex);
+	STARPU_PTHREAD_MUTEX_UNLOCK(&act_hypervisor_mutex);
 }
 
 static int _get_first_free_sched_ctx(unsigned *sched_ctxs, int nsched_ctxs)
@@ -395,7 +395,7 @@ void sc_hypervisor_unregister_ctx(unsigned sched_ctx)
 	if(hypervisor.policy.end_ctx)
 		hypervisor.policy.end_ctx(sched_ctx);
 
-	starpu_pthread_mutex_lock(&act_hypervisor_mutex);
+	STARPU_PTHREAD_MUTEX_LOCK(&act_hypervisor_mutex);
 	unsigned father = starpu_sched_ctx_get_inheritor(sched_ctx);
 	int *pus;
 	unsigned npus = starpu_sched_ctx_get_workers_list(sched_ctx, &pus);
@@ -422,12 +422,12 @@ void sc_hypervisor_unregister_ctx(unsigned sched_ctx)
 	hypervisor.sched_ctx_w[sched_ctx].sched_ctx = STARPU_NMAX_SCHED_CTXS;
 	_remove_config(sched_ctx);
 
-	starpu_pthread_mutex_destroy(&hypervisor.conf_mut[sched_ctx]);
-	starpu_pthread_mutex_destroy(&hypervisor.resize_mut[sched_ctx]);
+	STARPU_PTHREAD_MUTEX_DESTROY(&hypervisor.conf_mut[sched_ctx]);
+	STARPU_PTHREAD_MUTEX_DESTROY(&hypervisor.resize_mut[sched_ctx]);
 	if(hypervisor.nsched_ctxs == 1)
 		sc_hypervisor_stop_resize(hypervisor.sched_ctxs[0]);
 
-	starpu_pthread_mutex_unlock(&act_hypervisor_mutex);
+	STARPU_PTHREAD_MUTEX_UNLOCK(&act_hypervisor_mutex);
 }
 
 void sc_hypervisor_reset_react_start_time(unsigned sched_ctx, unsigned now)
@@ -498,10 +498,10 @@ double sc_hypervisor_get_elapsed_flops_per_sched_ctx(struct sc_hypervisor_wrappe
 
 	struct starpu_worker_collection *workers = starpu_sched_ctx_get_worker_collection(sc_w->sched_ctx);
 	int worker;
-	
+
 	struct starpu_sched_ctx_iterator it;
 	workers->init_iterator(workers, &it);
-		
+
 	while(workers->has_next(workers, &it))
 	{
 		worker = workers->get_next(workers, &it);
@@ -516,10 +516,10 @@ double sc_hypervisor_get_total_elapsed_flops_per_sched_ctx(struct sc_hypervisor_
 	double ret_val = 0.0;
 	struct starpu_worker_collection *workers = starpu_sched_ctx_get_worker_collection(sc_w->sched_ctx);
 	int worker;
-	
+
 	struct starpu_sched_ctx_iterator it;
 	workers->init_iterator(workers, &it);
-		
+
 	while(workers->has_next(workers, &it))
 	{
 		worker = workers->get_next(workers, &it);
@@ -560,7 +560,7 @@ void _reset_resize_sample_info(unsigned sender_sched_ctx, unsigned receiver_sche
 	{
 		/* info concerning only the gflops_rate strateg */
 		struct sc_hypervisor_wrapper *sender_sc_w = &hypervisor.sched_ctx_w[sender_sched_ctx];
-		
+
 		sender_sc_w->start_time = start_time;
 		unsigned nworkers = starpu_worker_get_count();
 		int i;
@@ -571,7 +571,7 @@ void _reset_resize_sample_info(unsigned sender_sched_ctx, unsigned receiver_sche
 			sender_sc_w->idle_start_time[i] = 0.0;
 			hypervisor.sched_ctx_w[sender_sched_ctx].exec_time[i] = 0.0;
 //			hypervisor.sched_ctx_w[sender_sched_ctx].exec_start_time[i] = (hypervisor.sched_ctx_w[sender_sched_ctx].exec_start_time[i] != 0.0) ? starpu_timing_now() : 0.0;
-			_decrement_elapsed_flops_per_worker(sender_sched_ctx, i, hypervisor.sched_ctx_w[sender_sched_ctx].elapsed_flops[i]); 
+			_decrement_elapsed_flops_per_worker(sender_sched_ctx, i, hypervisor.sched_ctx_w[sender_sched_ctx].elapsed_flops[i]);
 
 		}
 		_set_elapsed_flops_per_sched_ctx(sender_sched_ctx, 0.0);
@@ -580,7 +580,7 @@ void _reset_resize_sample_info(unsigned sender_sched_ctx, unsigned receiver_sche
 	if(receiver_sched_ctx != STARPU_NMAX_SCHED_CTXS)
 	{
 		struct sc_hypervisor_wrapper *receiver_sc_w = &hypervisor.sched_ctx_w[receiver_sched_ctx];
-		
+
 		receiver_sc_w->start_time = start_time;
 
 		unsigned nworkers = starpu_worker_get_count();
@@ -592,7 +592,7 @@ void _reset_resize_sample_info(unsigned sender_sched_ctx, unsigned receiver_sche
 			receiver_sc_w->idle_start_time[i] = (receiver_sc_w->exec_start_time[i] != 0.0) ? 0.0 : starpu_timing_now();
 //			hypervisor.sched_ctx_w[receiver_sched_ctx].exec_start_time[i] = (receiver_sc_w->exec_start_time[i] != 0.0) ? starpu_timing_now() : 0.0;
 			hypervisor.sched_ctx_w[receiver_sched_ctx].exec_time[i] = 0.0;
-			_decrement_elapsed_flops_per_worker(receiver_sched_ctx, i, hypervisor.sched_ctx_w[receiver_sched_ctx].elapsed_flops[i]); 
+			_decrement_elapsed_flops_per_worker(receiver_sched_ctx, i, hypervisor.sched_ctx_w[receiver_sched_ctx].elapsed_flops[i]);
 		}
 		_set_elapsed_flops_per_sched_ctx(receiver_sched_ctx, 0.0);
 	}
@@ -651,7 +651,7 @@ void sc_hypervisor_move_workers(unsigned sender_sched_ctx, unsigned receiver_sch
 
 				hypervisor.resize[sender_sched_ctx] = 0;
 				if(imposed_resize)  imposed_resize = 0;
-				starpu_pthread_mutex_unlock(&hypervisor.sched_ctx_w[sender_sched_ctx].mutex);
+				STARPU_PTHREAD_MUTEX_UNLOCK(&hypervisor.sched_ctx_w[sender_sched_ctx].mutex);
 			}
 		}
 		struct sc_hypervisor_policy_config *new_config = sc_hypervisor_get_config(receiver_sched_ctx);
@@ -744,7 +744,7 @@ void sc_hypervisor_remove_workers_from_sched_ctx(int* workers_to_remove, unsigne
 
 				hypervisor.resize[sched_ctx] = 0;
 				if(imposed_resize)  imposed_resize = 0;
-				starpu_pthread_mutex_unlock(&hypervisor.sched_ctx_w[sched_ctx].mutex);
+				STARPU_PTHREAD_MUTEX_UNLOCK(&hypervisor.sched_ctx_w[sched_ctx].mutex);
 			}
 		}
  	}
@@ -755,7 +755,7 @@ static unsigned _ack_resize_completed(unsigned sched_ctx, int worker)
 {
 	if(worker != -1 && !starpu_sched_ctx_contains_worker(worker, sched_ctx))
 		return 0;
-	
+
 	struct sc_hypervisor_resize_ack *resize_ack = NULL;
 	unsigned sender_sched_ctx = STARPU_NMAX_SCHED_CTXS;
 
@@ -765,7 +765,7 @@ static unsigned _ack_resize_completed(unsigned sched_ctx, int worker)
 		if(hypervisor.sched_ctxs[i] != STARPU_NMAX_SCHED_CTXS)
 		{
 			struct sc_hypervisor_wrapper *sc_w = &hypervisor.sched_ctx_w[hypervisor.sched_ctxs[i]];
-			starpu_pthread_mutex_lock(&sc_w->mutex);
+			STARPU_PTHREAD_MUTEX_LOCK(&sc_w->mutex);
 			unsigned only_remove = 0;
 			if(sc_w->resize_ack.receiver_sched_ctx == -1 && hypervisor.sched_ctxs[i] != sched_ctx &&
 			   sc_w->resize_ack.nmoved_workers > 0 && starpu_sched_ctx_contains_worker(worker, hypervisor.sched_ctxs[i]))
@@ -776,7 +776,7 @@ static unsigned _ack_resize_completed(unsigned sched_ctx, int worker)
 					{
 						only_remove = 1;
 						_reset_resize_sample_info(sched_ctx, STARPU_NMAX_SCHED_CTXS);
-						starpu_pthread_mutex_unlock(&sc_w->mutex);
+						STARPU_PTHREAD_MUTEX_UNLOCK(&sc_w->mutex);
 						break;
 					}
 			}
@@ -785,10 +785,10 @@ static unsigned _ack_resize_completed(unsigned sched_ctx, int worker)
 			{
 				resize_ack = &sc_w->resize_ack;
 				sender_sched_ctx = hypervisor.sched_ctxs[i];
-				starpu_pthread_mutex_unlock(&sc_w->mutex);
+				STARPU_PTHREAD_MUTEX_UNLOCK(&sc_w->mutex);
 				break;
 			}
-			starpu_pthread_mutex_unlock(&sc_w->mutex);
+			STARPU_PTHREAD_MUTEX_UNLOCK(&sc_w->mutex);
 		}
 	}
 
@@ -852,10 +852,10 @@ static unsigned _ack_resize_completed(unsigned sched_ctx, int worker)
 				free(resize_ack->acked_workers);
 
 			}
-			starpu_pthread_mutex_unlock(&hypervisor.sched_ctx_w[sender_sched_ctx].mutex);
+			STARPU_PTHREAD_MUTEX_UNLOCK(&hypervisor.sched_ctx_w[sender_sched_ctx].mutex);
 			return resize_completed;
 		}
-		starpu_pthread_mutex_unlock(&hypervisor.sched_ctx_w[sender_sched_ctx].mutex);
+		STARPU_PTHREAD_MUTEX_UNLOCK(&hypervisor.sched_ctx_w[sender_sched_ctx].mutex);
 	}
 	return 0;
 }
@@ -872,9 +872,9 @@ void sc_hypervisor_post_resize_request(unsigned sched_ctx, int task_tag)
 	entry->sched_ctx = sched_ctx;
 	entry->task_tag = task_tag;
 
-	starpu_pthread_mutex_lock(&hypervisor.resize_mut[sched_ctx]);
+	STARPU_PTHREAD_MUTEX_LOCK(&hypervisor.resize_mut[sched_ctx]);
 	HASH_ADD_INT(hypervisor.resize_requests[sched_ctx], task_tag, entry);
-	starpu_pthread_mutex_unlock(&hypervisor.resize_mut[sched_ctx]);
+	STARPU_PTHREAD_MUTEX_UNLOCK(&hypervisor.resize_mut[sched_ctx]);
 }
 
 void sc_hypervisor_resize_ctxs(unsigned *sched_ctxs, int nsched_ctxs , int *workers, int nworkers)
@@ -919,7 +919,7 @@ int _update_max_hierarchically(unsigned *sched_ctxs, int nsched_ctxs)
 			int nsched_ctxs_child = 0;
 			sc_hypervisor_get_ctxs_on_level(&sched_ctxs_child, &nsched_ctxs_child, level+1, sched_ctxs[s]);
 			if(nsched_ctxs_child > 0)
-			{			
+			{
 				config->max_nworkers += _update_max_hierarchically(sched_ctxs_child, nsched_ctxs_child);
 				free(sched_ctxs_child);
 				int max_possible_workers = starpu_worker_get_count();
@@ -927,7 +927,7 @@ int _update_max_hierarchically(unsigned *sched_ctxs, int nsched_ctxs)
 					config->max_nworkers = 0;
 				if(config->max_nworkers > max_possible_workers)
 					config->max_nworkers = max_possible_workers;
-			
+
 			}
 #ifdef STARPU_SC_HYPERVISOR_DEBUG
 			printf("ctx %d has max %d \n", sched_ctxs[s], config->max_nworkers);
@@ -1004,10 +1004,10 @@ void sc_hypervisor_update_resize_interval(unsigned *sched_ctxs, int nsched_ctxs,
 		struct sc_hypervisor_policy_config *config = sc_hypervisor_get_config(sched_ctx);
 		struct starpu_worker_collection *workers = starpu_sched_ctx_get_worker_collection(sched_ctx);
 		int worker;
-		
+
 		struct starpu_sched_ctx_iterator it;
 		workers->init_iterator(workers, &it);
-		
+
 		double elapsed_time_worker[STARPU_NMAXWORKERS];
 		double norm_idle_time = 0.0;
 		double end_time  = starpu_timing_now();
@@ -1028,9 +1028,9 @@ void sc_hypervisor_update_resize_interval(unsigned *sched_ctxs, int nsched_ctxs,
 				}
 				else
 				{
-					double idle = (end_time - hypervisor.sched_ctx_w[sched_ctx].idle_start_time[worker]) / 1000000.0; /* in seconds */ 
+					double idle = (end_time - hypervisor.sched_ctx_w[sched_ctx].idle_start_time[worker]) / 1000000.0; /* in seconds */
 					idle_time = hypervisor.sched_ctx_w[sched_ctx].idle_time[worker] + idle;
-				}		
+				}
 				norm_idle_time += (elapsed_time_worker[worker] == 0.0 ? 0.0 : (idle_time / elapsed_time_worker[worker]));
 /* 				printf("%d/%d: start time %lf elapsed time %lf idle time %lf norm_idle_time %lf \n",  */
 /* 				       worker, sched_ctx, hypervisor.sched_ctx_w[sched_ctx].start_time_w[worker], elapsed_time_worker[worker], idle_time, norm_idle_time); */
@@ -1054,14 +1054,14 @@ void sc_hypervisor_update_resize_interval(unsigned *sched_ctxs, int nsched_ctxs,
 			{
 				double current_exec_time = 0.0;
 				if(hypervisor.sched_ctx_w[sched_ctx].exec_start_time[worker] < hypervisor.sched_ctx_w[sched_ctx].start_time)
-					current_exec_time = (end_time - hypervisor.sched_ctx_w[sched_ctx].start_time) / 1000000.0; /* in seconds */ 
+					current_exec_time = (end_time - hypervisor.sched_ctx_w[sched_ctx].start_time) / 1000000.0; /* in seconds */
 				else
-					current_exec_time = (end_time - hypervisor.sched_ctx_w[sched_ctx].exec_start_time[worker]) / 1000000.0; /* in seconds */ 
+					current_exec_time = (end_time - hypervisor.sched_ctx_w[sched_ctx].exec_start_time[worker]) / 1000000.0; /* in seconds */
 
 				exec_time = hypervisor.sched_ctx_w[sched_ctx].exec_time[worker] + current_exec_time;
-			}		
+			}
 			norm_exec_time += elapsed_time_worker[worker] == 0.0 ? 0.0 : exec_time / elapsed_time_worker[worker];
-		}			
+		}
 
 		double curr_time = starpu_timing_now();
 		double elapsed_time = (curr_time - hypervisor.sched_ctx_w[sched_ctx].start_time) / 1000000.0; /* in seconds */
@@ -1079,20 +1079,20 @@ void sc_hypervisor_update_resize_interval(unsigned *sched_ctxs, int nsched_ctxs,
 /* 		} */
 		config->max_nworkers = lrint(norm_exec_time);
 //		config->max_nworkers = hypervisor.sched_ctx_w[sched_ctx].nready_tasks - 1;
-		
+
 		/* if(config->max_nworkers < 0) */
 /* 			config->max_nworkers = 0; */
 /* 		if(config->max_nworkers > max_workers) */
 /* 			config->max_nworkers = max_workers; */
-		
+
 #ifdef STARPU_SC_HYPERVISOR_DEBUG
-		printf("%d: ready tasks  %d norm_idle_time %lf elapsed_time %lf norm_exec_time %lf nworker %d max %d \n", 
+		printf("%d: ready tasks  %d norm_idle_time %lf elapsed_time %lf norm_exec_time %lf nworker %d max %d \n",
 		       sched_ctx, nready_tasks, norm_idle_time, elapsed_time, norm_exec_time, workers->nworkers, config->max_nworkers);
 #endif
 
 		total_max_nworkers += config->max_nworkers;
 		configured = 1;
-		
+
 	}
 
 	unsigned nhierarchy_levels = sc_hypervisor_get_nhierarchy_levels();
@@ -1101,7 +1101,7 @@ void sc_hypervisor_update_resize_interval(unsigned *sched_ctxs, int nsched_ctxs,
 		unsigned *sched_ctxs2;
 		int nsched_ctxs2;
 		sc_hypervisor_get_ctxs_on_level(&sched_ctxs2, &nsched_ctxs2, 0, STARPU_NMAX_SCHED_CTXS);
-		
+
 		if(nsched_ctxs2  > 0)
 		{
 			_update_max_hierarchically(sched_ctxs2, nsched_ctxs2);
@@ -1121,7 +1121,7 @@ void sc_hypervisor_update_resize_interval(unsigned *sched_ctxs, int nsched_ctxs,
 			}
 
 			int max_possible_workers = starpu_worker_get_count();
-			/*if the sum of the max cpus is smaller than the total cpus available 
+			/*if the sum of the max cpus is smaller than the total cpus available
 			  increase the max for the ones having more ready tasks to exec */
 			if(current_total_max_nworkers < max_possible_workers)
 			{
@@ -1136,9 +1136,9 @@ void sc_hypervisor_update_resize_interval(unsigned *sched_ctxs, int nsched_ctxs,
 		}
 	}
 
-	
 
-	/*if the sum of the max cpus is smaller than the total cpus available 
+
+	/*if the sum of the max cpus is smaller than the total cpus available
 	  increase the max for the ones having more ready tasks to exec */
 	/* if(configured && total_max_nworkers < max_workers) */
 /* 	{ */
@@ -1158,7 +1158,7 @@ void sc_hypervisor_update_resize_interval(unsigned *sched_ctxs, int nsched_ctxs,
 /* 		config->max_nworkers += diff; */
 /* 		printf("%d: redib max_nworkers incr %d \n",  max_nready_sched_ctx, config->max_nworkers); */
 /* 	} */
-       
+
 }
 
 /* notifies the hypervisor that a new task was pushed on the queue of the worker */
@@ -1211,24 +1211,24 @@ static void notify_idle_cycle(unsigned sched_ctx, int worker, double idle_time)
 	if(hypervisor.start_executing_time == 0.0) return;
 	struct sc_hypervisor_wrapper *sc_w = &hypervisor.sched_ctx_w[sched_ctx];
 	sc_w->current_idle_time[worker] += idle_time;
-	
+
 	if(sc_w->idle_start_time[worker] == 0.0 && sc_w->hyp_react_start_time != 0.0)
 		sc_w->idle_start_time[worker] = starpu_timing_now();
-	
+
 
 	if(sc_w->idle_start_time[worker] > 0.0)
 	{
 		double end_time  = starpu_timing_now();
 		sc_w->idle_time[worker] += (end_time - sc_w->idle_start_time[worker]) / 1000000.0; /* in seconds */
 	}
-	
+
 	hypervisor.sched_ctx_w[sched_ctx].idle_start_time[worker] = starpu_timing_now();
 
 	if(hypervisor.resize[sched_ctx] && hypervisor.policy.handle_idle_cycle)
 	{
 		if(sc_w->hyp_react_start_time == 0.0)
 			sc_hypervisor_reset_react_start_time(sched_ctx, 1);
-		
+
 		double curr_time = starpu_timing_now();
 		double elapsed_time = (curr_time - sc_w->hyp_react_start_time) / 1000000.0; /* in seconds */
 		if(sc_w->sched_ctx != STARPU_NMAX_SCHED_CTXS && elapsed_time > sc_w->config->time_sample)
@@ -1242,7 +1242,7 @@ static void notify_idle_cycle(unsigned sched_ctx, int worker, double idle_time)
 				if(sc_hypervisor_check_idle(sched_ctx, worker))
 				{
 					idle_everywhere = 1;
-				
+
 					nsched_ctxs = starpu_worker_get_sched_ctx_list(worker, &sched_ctxs);
 					int s;
 					for(s = 0; s < nsched_ctxs; s++)
@@ -1255,9 +1255,9 @@ static void notify_idle_cycle(unsigned sched_ctx, int worker, double idle_time)
 					}
 					free(sched_ctxs);
 				}
-				starpu_pthread_mutex_unlock(&act_hypervisor_mutex);
+				STARPU_PTHREAD_MUTEX_UNLOCK(&act_hypervisor_mutex);
 			}
-			
+
 			if(idle_everywhere)
 			{
 				double hyp_overhead_start = starpu_timing_now();
@@ -1302,7 +1302,7 @@ static void notify_poped_task(unsigned sched_ctx, int worker)
 	}
 
 	hypervisor.sched_ctx_w[sched_ctx].exec_start_time[worker] = starpu_timing_now();
-		
+
 	if(hypervisor.sched_ctx_w[sched_ctx].idle_start_time[worker] > 0.0)
 	{
 		int ns = hypervisor.nsched_ctxs;
@@ -1317,7 +1317,7 @@ static void notify_poped_task(unsigned sched_ctx, int worker)
 		}
 		double end_time  = starpu_timing_now();
 		double idle = (end_time - hypervisor.sched_ctx_w[sched_ctx].idle_start_time[worker]) / 1000000.0; /* in seconds */
-			
+
 		if(hypervisor.sched_ctx_w[sched_ctx].compute_partial_idle[worker])
 			hypervisor.sched_ctx_w[sched_ctx].idle_time[worker] += idle / 2.0;
 		else
@@ -1329,12 +1329,12 @@ static void notify_poped_task(unsigned sched_ctx, int worker)
 
 	if(hypervisor.resize[sched_ctx])
 		hypervisor.sched_ctx_w[sched_ctx].current_idle_time[worker] = 0.0;
-				
+
 	if(hypervisor.policy.handle_idle_end)
 		hypervisor.policy.handle_idle_end(sched_ctx, worker);
 }
 
- 
+
 static void _update_counters_hierarchically(int worker, unsigned sched_ctx, double flops, size_t data_size)
 {
 	hypervisor.sched_ctx_w[sched_ctx].poped_tasks[worker]++;
@@ -1343,10 +1343,10 @@ static void _update_counters_hierarchically(int worker, unsigned sched_ctx, doub
 	hypervisor.sched_ctx_w[sched_ctx].elapsed_tasks[worker]++ ;
 	hypervisor.sched_ctx_w[sched_ctx].total_elapsed_flops[worker] += flops;
 
-	starpu_pthread_mutex_lock(&hypervisor.sched_ctx_w[sched_ctx].mutex);
+	STARPU_PTHREAD_MUTEX_LOCK(&hypervisor.sched_ctx_w[sched_ctx].mutex);
 	hypervisor.sched_ctx_w[sched_ctx].remaining_flops -= flops;
-	starpu_pthread_mutex_unlock(&hypervisor.sched_ctx_w[sched_ctx].mutex);
-		
+	STARPU_PTHREAD_MUTEX_UNLOCK(&hypervisor.sched_ctx_w[sched_ctx].mutex);
+
 	if(starpu_sched_ctx_get_hierarchy_level(sched_ctx) > 0)
 		_update_counters_hierarchically(worker, starpu_sched_ctx_get_inheritor(sched_ctx), flops, data_size);
 
@@ -1362,8 +1362,8 @@ static void notify_post_exec_task(struct starpu_task *task, size_t data_size, ui
 	if(hypervisor.sched_ctx_w[sched_ctx].exec_start_time[worker] != 0.0)
 	{
 		double current_time = starpu_timing_now();
-		double exec_time = (current_time - 
-				    hypervisor.sched_ctx_w[sched_ctx].exec_start_time[worker]) / 1000000.0; /* in seconds */ 
+		double exec_time = (current_time -
+				    hypervisor.sched_ctx_w[sched_ctx].exec_start_time[worker]) / 1000000.0; /* in seconds */
 		hypervisor.sched_ctx_w[sched_ctx].exec_time[worker] += exec_time;
 		hypervisor.sched_ctx_w[sched_ctx].exec_start_time[worker] = 0.0;
 	}
@@ -1374,9 +1374,9 @@ static void notify_post_exec_task(struct starpu_task *task, size_t data_size, ui
 	hypervisor.sched_ctx_w[sched_ctx].elapsed_tasks[worker]++ ;
 	hypervisor.sched_ctx_w[sched_ctx].total_elapsed_flops[worker] += flops;
 
-	starpu_pthread_mutex_lock(&hypervisor.sched_ctx_w[sched_ctx].mutex);
+	STARPU_PTHREAD_MUTEX_LOCK(&hypervisor.sched_ctx_w[sched_ctx].mutex);
 	hypervisor.sched_ctx_w[sched_ctx].remaining_flops -= flops;
-	starpu_pthread_mutex_unlock(&hypervisor.sched_ctx_w[sched_ctx].mutex);
+	STARPU_PTHREAD_MUTEX_UNLOCK(&hypervisor.sched_ctx_w[sched_ctx].mutex);
 
 	if(_sc_hypervisor_use_lazy_resize())
 		_ack_resize_completed(sched_ctx, worker);
@@ -1385,11 +1385,11 @@ static void notify_post_exec_task(struct starpu_task *task, size_t data_size, ui
 	{
 		_update_counters_hierarchically(worker, starpu_sched_ctx_get_inheritor(sched_ctx), flops, data_size);
 	}
-	
+
 	if(hypervisor.resize[sched_ctx])
-	{	
+	{
 		if(hypervisor.policy.handle_poped_task)
-		{	
+		{
 			if(hypervisor.sched_ctx_w[sched_ctx].hyp_react_start_time == 0.0)
 				sc_hypervisor_reset_react_start_time(sched_ctx, 1);
 
@@ -1412,15 +1412,15 @@ static void notify_post_exec_task(struct starpu_task *task, size_t data_size, ui
 				hypervisor.policy.handle_poped_task(sched_ctx, -2, task, footprint);
 		}
 	}
-/* 	starpu_pthread_mutex_lock(&act_hypervisor_mutex); */
+/* 	STARPU_PTHREAD_MUTEX_LOCK(&act_hypervisor_mutex); */
 /* 	_ack_resize_completed(sched_ctx, worker); */
-/* 	starpu_pthread_mutex_unlock(&act_hypervisor_mutex); */
+/* 	STARPU_PTHREAD_MUTEX_UNLOCK(&act_hypervisor_mutex); */
 	if(hypervisor.sched_ctx_w[sched_ctx].poped_tasks[worker] % 200 == 0)
 		_print_current_time();
 
 	if(task_tag <= 0)
-		return; 
-	
+		return;
+
 	unsigned conf_sched_ctx;
 	unsigned i;
 	unsigned ns = hypervisor.nsched_ctxs;
@@ -1430,7 +1430,7 @@ static void notify_post_exec_task(struct starpu_task *task, size_t data_size, ui
 		struct configuration_entry *entry;
 
 		conf_sched_ctx = hypervisor.sched_ctxs[i];
-		starpu_pthread_mutex_lock(&hypervisor.conf_mut[conf_sched_ctx]);
+		STARPU_PTHREAD_MUTEX_LOCK(&hypervisor.conf_mut[conf_sched_ctx]);
 
 		HASH_FIND_INT(hypervisor.configurations[conf_sched_ctx], &task_tag, entry);
 
@@ -1442,12 +1442,12 @@ static void notify_post_exec_task(struct starpu_task *task, size_t data_size, ui
 			HASH_DEL(hypervisor.configurations[conf_sched_ctx], entry);
 			free(config);
 		}
-		starpu_pthread_mutex_unlock(&hypervisor.conf_mut[conf_sched_ctx]);
+		STARPU_PTHREAD_MUTEX_UNLOCK(&hypervisor.conf_mut[conf_sched_ctx]);
 	}
 
 	if(hypervisor.resize[sched_ctx])
 	{
-		starpu_pthread_mutex_lock(&hypervisor.resize_mut[sched_ctx]);
+		STARPU_PTHREAD_MUTEX_LOCK(&hypervisor.resize_mut[sched_ctx]);
 
 		if(hypervisor.policy.handle_post_exec_hook)
 		{
@@ -1462,7 +1462,7 @@ static void notify_post_exec_task(struct starpu_task *task, size_t data_size, ui
 			}
 
 		}
-		starpu_pthread_mutex_unlock(&hypervisor.resize_mut[sched_ctx]);
+		STARPU_PTHREAD_MUTEX_UNLOCK(&hypervisor.resize_mut[sched_ctx]);
 	}
 	return;
 }
@@ -1470,9 +1470,9 @@ static void notify_post_exec_task(struct starpu_task *task, size_t data_size, ui
 static void notify_submitted_job(struct starpu_task *task, uint32_t footprint, size_t data_size)
 {
 	unsigned sched_ctx = task->sched_ctx;
-	starpu_pthread_mutex_lock(&hypervisor.sched_ctx_w[sched_ctx].mutex);
+	STARPU_PTHREAD_MUTEX_LOCK(&hypervisor.sched_ctx_w[sched_ctx].mutex);
 	hypervisor.sched_ctx_w[sched_ctx].submitted_flops += task->flops;
-	starpu_pthread_mutex_unlock(&hypervisor.sched_ctx_w[sched_ctx].mutex);
+	STARPU_PTHREAD_MUTEX_UNLOCK(&hypervisor.sched_ctx_w[sched_ctx].mutex);
 
 	/* signaled by the user - no need to wait for them */
 	/* if(hypervisor.policy.handle_submitted_job && !type_of_tasks_known) */
@@ -1499,10 +1499,10 @@ static void notify_delete_context(unsigned sched_ctx)
 
 void sc_hypervisor_size_ctxs(unsigned *sched_ctxs, int nsched_ctxs, int *workers, int nworkers)
 {
-//	starpu_pthread_mutex_lock(&act_hypervisor_mutex);
+//	STARPU_PTHREAD_MUTEX_LOCK(&act_hypervisor_mutex);
 	unsigned curr_nsched_ctxs = sched_ctxs == NULL ? hypervisor.nsched_ctxs : (unsigned)nsched_ctxs;
 	unsigned *curr_sched_ctxs = sched_ctxs == NULL ? hypervisor.sched_ctxs : sched_ctxs;
-//	starpu_pthread_mutex_unlock(&act_hypervisor_mutex);
+//	STARPU_PTHREAD_MUTEX_UNLOCK(&act_hypervisor_mutex);
 	unsigned s;
 	for(s = 0; s < curr_nsched_ctxs; s++)
 		hypervisor.resize[curr_sched_ctxs[s]] = 1;
@@ -1605,10 +1605,10 @@ struct types_of_workers* sc_hypervisor_get_types_of_workers(int *workers, unsign
 void sc_hypervisor_update_diff_total_flops(unsigned sched_ctx, double diff_total_flops)
 {
 //	double hyp_overhead_start = starpu_timing_now();
-	starpu_pthread_mutex_lock(&hypervisor.sched_ctx_w[sched_ctx].mutex);
+	STARPU_PTHREAD_MUTEX_LOCK(&hypervisor.sched_ctx_w[sched_ctx].mutex);
 	hypervisor.sched_ctx_w[sched_ctx].total_flops += diff_total_flops;
-	hypervisor.sched_ctx_w[sched_ctx].remaining_flops += diff_total_flops;	
-	starpu_pthread_mutex_unlock(&hypervisor.sched_ctx_w[sched_ctx].mutex);
+	hypervisor.sched_ctx_w[sched_ctx].remaining_flops += diff_total_flops;
+	STARPU_PTHREAD_MUTEX_UNLOCK(&hypervisor.sched_ctx_w[sched_ctx].mutex);
 /* 	double hyp_overhead_end = starpu_timing_now(); */
 /* 	hyp_overhead += (hyp_overhead_end - hyp_overhead_start); */
 	if(starpu_sched_ctx_get_hierarchy_level(sched_ctx) > 0)
@@ -1623,10 +1623,10 @@ void sc_hypervisor_update_diff_elapsed_flops(unsigned sched_ctx, double diff_ela
 	int workerid = starpu_worker_get_id();
 	if(workerid != -1)
 	{
-//		starpu_pthread_mutex_lock(&hypervisor.sched_ctx_w[sched_ctx].mutex);
+//		STARPU_PTHREAD_MUTEX_LOCK(&hypervisor.sched_ctx_w[sched_ctx].mutex);
 		hypervisor.sched_ctx_w[sched_ctx].elapsed_flops[workerid] += diff_elapsed_flops;
 		hypervisor.sched_ctx_w[sched_ctx].total_elapsed_flops[workerid] += diff_elapsed_flops;
-//		starpu_pthread_mutex_unlock(&hypervisor.sched_ctx_w[sched_ctx].mutex);
+//		STARPU_PTHREAD_MUTEX_UNLOCK(&hypervisor.sched_ctx_w[sched_ctx].mutex);
 	}
 /* 	double hyp_overhead_end = starpu_timing_now(); */
 /* 	hyp_overhead += (hyp_overhead_end - hyp_overhead_start); */
@@ -1643,7 +1643,7 @@ void sc_hypervisor_get_ctxs_on_level(unsigned **sched_ctxs, int *nsched_ctxs, un
 	for(s = 0; s < hypervisor.nsched_ctxs; s++)
 	{
 		/* if father == STARPU_NMAX_SCHED_CTXS we take all the ctxs in this level */
-		if(starpu_sched_ctx_get_hierarchy_level(hypervisor.sched_ctxs[s]) == hierarchy_level && 
+		if(starpu_sched_ctx_get_hierarchy_level(hypervisor.sched_ctxs[s]) == hierarchy_level &&
 		   (starpu_sched_ctx_get_inheritor(hypervisor.sched_ctxs[s]) == father_sched_ctx_id || father_sched_ctx_id == STARPU_NMAX_SCHED_CTXS))
 		        (*sched_ctxs)[(*nsched_ctxs)++] = hypervisor.sched_ctxs[s];
 	}

+ 2 - 2
sc_hypervisor/src/sc_hypervisor_intern.h

@@ -45,7 +45,7 @@ struct resize_request_entry
 	UT_hash_handle hh;
 };
 
-/* structure to indicate when the moving of workers was actually done 
+/* structure to indicate when the moving of workers was actually done
    (moved workers can be seen in the new ctx ) */
 struct resize_ack
 {
@@ -96,7 +96,7 @@ struct sc_hypervisor
 
 	/* max speed diff btw ctx before triggering resizing */
 	double max_speed_gap;
-	
+
 	/* criteria to trigger resizing */
 	unsigned resize_criteria;
 

+ 4 - 2
src/core/disk_ops/unistd/disk_unistd_global.c

@@ -257,14 +257,16 @@ int starpu_unistd_global_full_read(void *base STARPU_ATTRIBUTE_UNUSED, void *obj
 {
         struct starpu_unistd_global_obj *tmp = (struct starpu_unistd_global_obj *) obj;
 	int fd = tmp->descriptor;
+	int ret;
+	struct stat st;
 
 	if (fd < 0)
 		fd = _starpu_unistd_reopen(obj);
 #ifdef STARPU_HAVE_WINDOWS
 	*size = _filelength(fd);
 #else
-	struct stat st;
-	fstat(fd, &st);
+	ret = fstat(fd, &st);
+	STARPU_ASSERT(ret==0);
 
 	*size = st.st_size;
 #endif

+ 22 - 19
src/core/sched_ctx.c

@@ -123,7 +123,8 @@ static void _starpu_update_workers_without_ctx(int *workerids, int nworkers, int
 void starpu_sched_ctx_stop_task_submission()
 {
 	_starpu_exclude_task_from_dag(&stop_submission_task);
-	_starpu_task_submit_internally(&stop_submission_task);
+	int ret = _starpu_task_submit_internally(&stop_submission_task);
+	STARPU_ASSERT(!ret);
 }
 
 void starpu_sched_ctx_worker_shares_tasks_lists(int workerid, int sched_ctx_id)
@@ -259,20 +260,20 @@ static void _starpu_add_workers_to_sched_ctx(struct _starpu_sched_ctx *sched_ctx
 					if(sched_ctx->perf_arch.devices[dev2].type == devices[dev1].type && sched_ctx->perf_arch.devices[dev2].devid == devices[dev1].devid)
 						found = 1;
 				}
-				
+
 				if(!found)
 				{
 					nfinal_devices++;
 				}
 				else
 					found = 0;
-				
+
 			}
 
 
 			int nsize =  (sched_ctx->perf_arch.ndevices+nfinal_devices);
 			sched_ctx->perf_arch.devices  = (struct starpu_perfmodel_device*)realloc(sched_ctx->perf_arch.devices, nsize*sizeof(struct starpu_perfmodel_device));
-			
+
 		}
 
 		int dev1, dev2;
@@ -285,7 +286,7 @@ static void _starpu_add_workers_to_sched_ctx(struct _starpu_sched_ctx *sched_ctx
 				{
 					if(sched_ctx->perf_arch.devices[dev2].type == STARPU_CPU_WORKER)
 						sched_ctx->perf_arch.devices[dev2].ncores += devices[dev1].ncores;
-				     
+
 					found = 1;
 				}
 			}
@@ -391,11 +392,11 @@ static void _starpu_remove_workers_from_sched_ctx(struct _starpu_sched_ctx *sche
 				devices[ndevices].ncores = str_worker->perf_arch.devices[dev].ncores;
 				ndevices++;
 			}
-			else 
+			else
 				found = 0;
 		}
 		found = 0;
-		
+
 	}
 	sched_ctx->perf_arch.ndevices = ndevices;
 	for(dev = 0; dev < ndevices; dev++)
@@ -421,16 +422,16 @@ static void _starpu_sched_ctx_free_scheduling_data(struct _starpu_sched_ctx *sch
 	if(sched_ctx->sched_policy && sched_ctx->sched_policy->remove_workers)
 	{
 		int *workerids = NULL;
-		
+
 		unsigned nworkers_ctx = starpu_sched_ctx_get_workers_list(sched_ctx->id, &workerids);
-		
+
 		if(nworkers_ctx > 0)
 		{
 			_STARPU_TRACE_WORKER_SCHEDULING_PUSH;
 			sched_ctx->sched_policy->remove_workers(sched_ctx->id, workerids, nworkers_ctx);
 			_STARPU_TRACE_WORKER_SCHEDULING_POP;
 		}
-		
+
 		free(workerids);
 	}
 	return;
@@ -466,8 +467,8 @@ struct _starpu_sched_ctx* _starpu_create_sched_ctx(struct starpu_sched_policy *p
 						   int nworkers_ctx, unsigned is_initial_sched,
 						   const char *sched_ctx_name,
 						   int min_prio_set, int min_prio,
-						   int max_prio_set, int max_prio, 
-						   unsigned awake_workers,  
+						   int max_prio_set, int max_prio,
+						   unsigned awake_workers,
 						   void (*sched_policy_init)(void))
 {
 	struct _starpu_machine_config *config = (struct _starpu_machine_config *)_starpu_get_machine_config();
@@ -889,8 +890,7 @@ void starpu_sched_ctx_delete(unsigned sched_ctx_id)
 {
 	struct _starpu_sched_ctx *sched_ctx = _starpu_get_sched_ctx_struct(sched_ctx_id);
 #ifdef STARPU_USE_SC_HYPERVISOR
-	if(sched_ctx != NULL && sched_ctx_id != 0 && sched_ctx_id != STARPU_NMAX_SCHED_CTXS
-	   && sched_ctx->perf_counters != NULL)
+	if (sched_ctx_id != 0 && sched_ctx_id != STARPU_NMAX_SCHED_CTXS && sched_ctx->perf_counters != NULL)
 	{
 		_STARPU_TRACE_HYPERVISOR_BEGIN();
 		sched_ctx->perf_counters->notify_delete_context(sched_ctx_id);
@@ -1020,15 +1020,15 @@ unsigned _starpu_can_push_task(struct _starpu_sched_ctx *sched_ctx, struct starp
 	if(sched_ctx->sched_policy && sched_ctx->sched_policy->simulate_push_task)
 	{
 		if (window_size == 0.0) return 1;
-		
+
 		STARPU_PTHREAD_RWLOCK_RDLOCK(&changing_ctx_mutex[sched_ctx->id]);
 		double expected_end = sched_ctx->sched_policy->simulate_push_task(task);
 		STARPU_PTHREAD_RWLOCK_UNLOCK(&changing_ctx_mutex[sched_ctx->id]);
-		
-		double expected_len = 0.0; 
+
+		double expected_len = 0.0;
 		if(hyp_actual_start_sample[sched_ctx->id] != 0.0)
 			expected_len = expected_end - hyp_actual_start_sample[sched_ctx->id] ;
-		else 
+		else
 		{
 			printf("%d: sc start is 0.0\n", sched_ctx->id);
 			expected_len = expected_end - starpu_timing_now();
@@ -1449,7 +1449,9 @@ void starpu_sched_ctx_update_start_resizing_sample(unsigned sched_ctx_id, double
 
 unsigned _starpu_sched_ctx_allow_hypervisor(unsigned sched_ctx_id)
 {
+	(void) sched_ctx_id;
 	return 1;
+#if 0
 	double now = starpu_timing_now();
 	if(hyp_start_allow_sample[sched_ctx_id] > 0.0)
 	{
@@ -1471,6 +1473,7 @@ unsigned _starpu_sched_ctx_allow_hypervisor(unsigned sched_ctx_id)
 		return 1;
 	}
 	return 0;
+#endif
 }
 
 void starpu_sched_ctx_set_policy_data(unsigned sched_ctx_id, void* policy_data)
@@ -1652,7 +1655,7 @@ unsigned starpu_sched_ctx_contains_worker(int workerid, unsigned sched_ctx_id)
 		int worker;
 
 		struct starpu_sched_ctx_iterator it;
-		
+
 		workers->init_iterator(workers, &it);
 		while(workers->has_next(workers, &it))
 		{

+ 1 - 1
src/core/sched_ctx_list.c

@@ -56,7 +56,7 @@ void _starpu_sched_ctx_elt_ensure_consistency(struct _starpu_sched_ctx_list *lis
 					      unsigned sched_ctx)
 {
 	struct _starpu_sched_ctx_elt *elt = _starpu_sched_ctx_elt_find(list, sched_ctx);
-	if (elt->task_number>0)
+	if (elt && elt->task_number>0)
 		elt->task_number = 0;
 }
 

+ 3 - 2
tools/starpu_machine_display.c

@@ -23,14 +23,15 @@
 
 static void display_worker_names(enum starpu_worker_archtype type)
 {
-	unsigned nworkers = starpu_worker_get_count_by_type(type);
+	int nworkers = starpu_worker_get_count_by_type(type);
 	if (!nworkers)
 		return;
+	STARPU_ASSERT(nworkers>0);
 
 	int ids[nworkers];
 	starpu_worker_get_ids_by_type(type, ids, nworkers);
 
-	unsigned i;
+	int i;
 	for (i = 0; i < nworkers; i++)
 	{
 		char name[256];

+ 4 - 2
tools/starpu_perfmodel_display.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2011, 2013-2014  Université de Bordeaux
- * Copyright (C) 2011, 2012, 2013, 2014  CNRS
+ * Copyright (C) 2011, 2012, 2013, 2014, 2016  CNRS
  * Copyright (C) 2011  Télécom-SudParis
  *
  * StarPU is free software; you can redistribute it and/or modify
@@ -66,6 +66,7 @@ static void usage()
 static void parse_args(int argc, char **argv)
 {
 	int c;
+	int res;
 
 	static struct option long_options[] =
 	{
@@ -109,7 +110,8 @@ static void parse_args(int argc, char **argv)
 		case 'f':
 			/* footprint */
 			pdisplay_specific_footprint = 1;
-			sscanf(optarg, "%08x", &pspecific_footprint);
+			res = sscanf(optarg, "%08x", &pspecific_footprint);
+			STARPU_ASSERT(res==1);
 			break;
 
 		case 'd':

+ 12 - 4
tools/starpu_perfmodel_plot.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2011-2014  Université de Bordeaux
- * Copyright (C) 2011, 2012, 2013, 2014, 2015  CNRS
+ * Copyright (C) 2011, 2012, 2013, 2014, 2015, 2016  CNRS
  * Copyright (C) 2011  Télécom-SudParis
  *
  * StarPU is free software; you can redistribute it and/or modify
@@ -230,8 +230,10 @@ static void display_perf_model(FILE *gnuplot_file, struct starpu_perfmodel_arch*
 		}
 		else
 		{
+			char *arch_name2 = replace_char(arch_name, '_', '-');
 			print_comma(gnuplot_file, first);
-			fprintf(gnuplot_file, "\"< grep '^%s' %s\" using 3:4 title \"Profiling %s\"", arch_name, options->data_file_name, replace_char(arch_name, '_', '-'));
+			fprintf(gnuplot_file, "\"< grep '^%s' %s\" using 3:4 title \"Profiling %s\"", arch_name, options->data_file_name, arch_name2);
+			free(arch_name2);
 		}
 	}
 #endif
@@ -291,9 +293,11 @@ static void display_history_based_perf_models(FILE *gnuplot_file, struct starpu_
 
 				if (arch_model->list)
 				{
+					char *arch_name2 = replace_char(arch_name, '_', '-');
 					print_comma(gnuplot_file, first);
-					fprintf(gnuplot_file, "\"%s\" using 1:%d:%d with errorlines title \"Average %s\"", options->avg_file_name, col, col+1, replace_char(arch_name, '_', '-'));
+					fprintf(gnuplot_file, "\"%s\" using 1:%d:%d with errorlines title \"Average %s\"", options->avg_file_name, col, col+1, arch_name2);
 					col += 2;
+					free(arch_name2);
 				}
 			}
 		}
@@ -414,11 +418,13 @@ static void dump_data_file(FILE *data_file, struct _perfmodel_plot_options *opti
 
 static void display_selected_models(FILE *gnuplot_file, struct starpu_perfmodel *model, struct _perfmodel_plot_options *options)
 {
+	char *symbol = replace_char(options->symbol, '_', '-');
+
 	fprintf(gnuplot_file, "#!/usr/bin/gnuplot -persist\n");
 	fprintf(gnuplot_file, "\n");
 	fprintf(gnuplot_file, "set term postscript eps enhanced color\n");
 	fprintf(gnuplot_file, "set output \"starpu_%s.eps\"\n", options->symbol);
-	fprintf(gnuplot_file, "set title \"Model for codelet %s\"\n", replace_char(options->symbol, '_', '-'));
+	fprintf(gnuplot_file, "set title \"Model for codelet %s\"\n", symbol);
 	fprintf(gnuplot_file, "set xlabel \"Total data size\"\n");
 	if (options->gflops)
 		fprintf(gnuplot_file, "set ylabel \"GFlops\"\n");
@@ -441,6 +447,8 @@ static void display_selected_models(FILE *gnuplot_file, struct starpu_perfmodel
 	/* display all or selected combinations */
 	display_all_perf_models(gnuplot_file, model, &first, options);
 	display_history_based_perf_models(gnuplot_file, model, &first, options);
+
+	free(symbol);
 }
 
 int main(int argc, char **argv)