Parcourir la source

cleaning ispeed_lp code + free hwloc_worker_set when deleting the context

Andra Hugo il y a 11 ans
Parent
commit
abebb0c602

+ 4 - 0
sc_hypervisor/include/sc_hypervisor_lp.h

@@ -72,6 +72,10 @@ double sc_hypervisor_lp_simulate_distrib_tasks(int ns, int nw, int nt, double w_
 					       double times[nw][nt], unsigned is_integer, double tmax, unsigned *in_sched_ctxs,
 					       struct sc_hypervisor_policy_task_pool *tmp_task_pools);
 
+/* linear program that simulates a distribution of flops over the workers on particular sample of the execution
+   of the application such that the entire sample would finish in a minimum amount of time */
+double sc_hypervisor_lp_simulate_distrib_flops_on_sample(int ns, int nw, double final_w_in_s[ns][nw], unsigned is_integer, double tmax, 
+							 double **speed, double flops[ns], double **final_flops_on_w);
 #endif // STARPU_HAVE_GLPK_H
 
 #ifdef __cplusplus

+ 2 - 6
sc_hypervisor/src/hypervisor_policies/feft_lp_policy.c

@@ -46,7 +46,7 @@ static void _try_resizing(unsigned *sched_ctxs, int nsched_ctxs, int *workers, i
 	long diff_s = end_time.tv_sec  - start_time.tv_sec;
 	long diff_us = end_time.tv_usec  - start_time.tv_usec;
 	
-	float timing = (float)(diff_s*1000000 + diff_us)/1000;
+	__attribute__((unused))	float timing = (float)(diff_s*1000000 + diff_us)/1000;
 	
 	if(vmax != 0.0)
 	{
@@ -142,12 +142,8 @@ static void feft_lp_handle_idle_cycle(unsigned sched_ctx, int worker)
 		unsigned criteria = sc_hypervisor_get_resize_criteria();
 		if(criteria != SC_NOTHING && criteria == SC_IDLE)
 		{
-			
 			if(sc_hypervisor_check_idle(sched_ctx, worker))
-			{
 				_try_resizing(NULL, -1, NULL, -1);
-//				sc_hypervisor_move_workers(sched_ctx, 3 - sched_ctx, &worker, 1, 1);
-			}
 		}
 		starpu_pthread_mutex_unlock(&act_hypervisor_mutex);
 	}
@@ -182,7 +178,7 @@ struct sc_hypervisor_policy feft_lp_policy = {
 	.resize_ctxs = feft_lp_resize_ctxs,
 	.handle_poped_task = feft_lp_handle_poped_task,
 	.handle_pushed_task = NULL,
-	.handle_idle_cycle = feft_lp_handle_idle_cycle, //NULL,
+	.handle_idle_cycle = feft_lp_handle_idle_cycle,
 	.handle_idle_end = NULL,
 	.handle_post_exec_hook = NULL,
 	.handle_submitted_job = NULL,

+ 4 - 218
sc_hypervisor/src/hypervisor_policies/ispeed_lp_policy.c

@@ -28,13 +28,9 @@ struct ispeed_lp_data
 	int *workers;
 };
 
-/*
- * GNU Linear Programming Kit backend
- */
 #ifdef STARPU_HAVE_GLPK_H
-#include <glpk.h>
-static double _glp_resolve (int ns, int nw, double final_w_in_s[ns][nw],
-			    unsigned is_integer, double tmax, void *specific_data)
+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 ispeed_lp_data *sd = (struct ispeed_lp_data *)specific_data;
 
@@ -43,220 +39,11 @@ static double _glp_resolve (int ns, int nw, double final_w_in_s[ns][nw],
 	
 	double **final_flops_on_w = sd->flops_on_w;
 	
-	double w_in_s[ns][nw];
-	double flops_on_w[ns][nw];
-
-	int w, s;
-	glp_prob *lp;
-
-//	printf("try with tmax %lf\n", tmax);
-	lp = glp_create_prob();
-	glp_set_prob_name(lp, "StarPU theoretical bound");
-	glp_set_obj_dir(lp, GLP_MAX);
-	glp_set_obj_name(lp, "total execution time");
-
-	{
-		int ne = 5 * ns * nw /* worker execution time */
-			+ 1; /* glp dumbness */
-		int n = 1;
-		int ia[ne], ja[ne];
-		double ar[ne];
-
-
-		/* Variables: number of flops assigned to worker w in context s, and 
-		 the acknwoledgment that the worker w belongs to the context s */
-		glp_add_cols(lp, 2*nw*ns);
-#define colnum(w, s) ((s)*nw+(w)+1)
-		for(s = 0; s < ns; s++)
-			for(w = 0; w < nw; w++)
-				glp_set_obj_coef(lp, nw*ns+colnum(w,s), 1.);
-		
-		for(s = 0; s < ns; s++)
-			for(w = 0; w < nw; w++)
-			{
-				char name[32];
-				snprintf(name, sizeof(name), "flopsw%ds%dn", w, s);
-				glp_set_col_name(lp, colnum(w,s), name);
-				glp_set_col_bnds(lp, colnum(w,s), GLP_LO, 0., 0.);
-
-				snprintf(name, sizeof(name), "w%ds%dn", w, s);
-				glp_set_col_name(lp, nw*ns+colnum(w,s), name);
-				if (is_integer)
-				{
-                                        glp_set_col_kind(lp, nw*ns+colnum(w, s), GLP_IV);
-					glp_set_col_bnds(lp, nw*ns+colnum(w,s), GLP_DB, 0, 1);
-				}
-				else
-					glp_set_col_bnds(lp, nw*ns+colnum(w,s), GLP_DB, 0.0, 1.0);
-
-			}
-
-
-		int curr_row_idx = 0;
-		/* Total worker execution time */
-		glp_add_rows(lp, nw*ns);
-
-		/*nflops[s][w]/v[s][w] < x[s][w]*tmax */
-		for(s = 0; s < ns; s++)
-		{
-			for (w = 0; w < nw; w++)
-			{
-				char name[32], title[64];
-				starpu_worker_get_name(w, name, sizeof(name));
-				snprintf(title, sizeof(title), "worker %s", name);
-				glp_set_row_name(lp, curr_row_idx+s*nw+w+1, title);
-
-				/* nflosp[s][w] */
-				ia[n] = curr_row_idx+s*nw+w+1;
-				ja[n] = colnum(w, s);
-				ar[n] = 1 / speed[s][w];
-
-				n++;
-				
-				/* x[s][w] = 1 | 0 */
-				ia[n] = curr_row_idx+s*nw+w+1;
-				ja[n] = nw*ns+colnum(w,s);
-				ar[n] = (-1) * tmax;
-				n++;
-				glp_set_row_bnds(lp, curr_row_idx+s*nw+w+1, GLP_UP, 0.0, 0.0);
-			}
-		}
-
-		curr_row_idx += nw*ns;
-
-		/* sum(flops[s][w]) = flops[s] */
-		glp_add_rows(lp, ns);
-		for (s = 0; s < ns; s++)
-		{
-			char name[32], title[64];
-			starpu_worker_get_name(w, name, sizeof(name));
-			snprintf(title, sizeof(title), "flops %lf ctx%d", flops[s], s);
-			glp_set_row_name(lp, curr_row_idx+s+1, title);
-			for (w = 0; w < nw; w++)
-			{
-				ia[n] = curr_row_idx+s+1;
-				ja[n] = colnum(w, s);
-				ar[n] = 1;
-				n++;
-			}
-			glp_set_row_bnds(lp, curr_row_idx+s+1, GLP_FX, flops[s], flops[s]);
-		}
-
-		curr_row_idx += ns;
-
-		/* sum(x[s][w]) = 1 */
-		glp_add_rows(lp, nw);
-		for (w = 0; w < nw; w++)
-		{
-			char name[32], title[64];
-			starpu_worker_get_name(w, name, sizeof(name));
-			snprintf(title, sizeof(title), "w%x", w);
-			glp_set_row_name(lp, curr_row_idx+w+1, title);
-			for(s = 0; s < ns; s++)
-			{
-				ia[n] = curr_row_idx+w+1;
-				ja[n] = nw*ns+colnum(w,s);
-				ar[n] = 1;
-				n++;
-			}
-			if(is_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);
-		}
-
-		curr_row_idx += nw;
-
-		/* sum(nflops[s][w]) > 0*/
-		glp_add_rows(lp, nw);
-		for (w = 0; w < nw; w++)
-		{
-			char name[32], title[64];
-			starpu_worker_get_name(w, name, sizeof(name));
-			snprintf(title, sizeof(title), "flopsw%x", w);
-			glp_set_row_name(lp, curr_row_idx+w+1, title);
-			for(s = 0; s < ns; s++)
-			{
-				ia[n] = curr_row_idx+w+1;
-				ja[n] = colnum(w,s);
-				ar[n] = 1;
-				n++;
-			}
-
-			glp_set_row_bnds(lp, curr_row_idx+w+1, GLP_LO, 0.1, 0.);
-		}
-
-		if(n != ne)
-			printf("ns= %d nw = %d n = %d ne = %d\n", ns, nw, n, ne);
-		STARPU_ASSERT(n == ne);
-
-		glp_load_matrix(lp, ne-1, ia, ja, ar);
-	}
-
-	glp_smcp parm;
-	glp_init_smcp(&parm);
-	parm.msg_lev = GLP_MSG_OFF;
-	int ret = glp_simplex(lp, &parm);
-	if (ret)
-	{
-		glp_delete_prob(lp);
-		lp = NULL;
-		return 0.0;
-	}
-
-        if (is_integer)
-        {
-                glp_iocp iocp;
-                glp_init_iocp(&iocp);
-                iocp.msg_lev = GLP_MSG_OFF;
-                glp_intopt(lp, &iocp);
-		int stat = glp_mip_status(lp);
-		/* if we don't have a solution return */
-		if(stat == GLP_NOFEAS)
-		{
-			glp_delete_prob(lp);
-			lp = NULL;
-			return 0.0;
-		}
-        }
-
-	int stat = glp_get_prim_stat(lp);
-	/* if we don't have a solution return */
-	if(stat == GLP_NOFEAS)
-	{
-		glp_delete_prob(lp);
-		lp = NULL;
-		return 0.0;
-	}
-
-	double res = glp_get_obj_val(lp);
-
-	for(s = 0; s < ns; s++)
-		for(w = 0; w < nw; w++)
-		{
-			flops_on_w[s][w] = glp_get_col_prim(lp, colnum(w, s));
-			if (is_integer)
-				w_in_s[s][w] = (double)glp_mip_col_val(lp, nw*ns+colnum(w, s));
-			else
-				w_in_s[s][w] = glp_get_col_prim(lp, nw*ns+colnum(w,s));
-//			printf("w_in_s[s%d][w%d] = %lf flops[s%d][w%d] = %lf \n", s, w, w_in_s[s][w], s, w, flops_on_w[s][w]);
-		}
-
-	glp_delete_prob(lp);
-	for(s = 0; s < ns; s++)
-		for(w = 0; w < nw; w++)
-		{
-			final_w_in_s[s][w] = w_in_s[s][w];
-			final_flops_on_w[s][w] = flops_on_w[s][w];
-		}
-
-	return res;
+	return sc_hypervisor_lp_simulate_distrib_flops_on_sample(ns, nw, final_w_in_s, is_integer, tmax, speed, flops, final_flops_on_w);
 }
 
 static unsigned _compute_flops_distribution_over_ctxs(int ns, int nw, double w_in_s[ns][nw], double **flops_on_w, unsigned *sched_ctxs, int *workers)
 {
-//	double flops[ns];
-//	double speed[ns][nw];
 	double *flops = (double*)malloc(ns*sizeof(double));
 	double **speed = (double **)malloc(ns*sizeof(double*));
 	int i;
@@ -312,7 +99,7 @@ static unsigned _compute_flops_distribution_over_ctxs(int ns, int nw, double w_i
         specific_data.workers = workers;
 
         unsigned found_sol = sc_hypervisor_lp_execute_dichotomy(ns, nw, w_in_s, 1, (void*)&specific_data, 
-								tmin, tmax, smallest_tmax, _glp_resolve);
+								tmin, tmax, smallest_tmax, _compute_workers_distrib);
 
 	for(i = 0; i < ns; i++)
 		free(speed[i]);
@@ -416,7 +203,6 @@ static void ispeed_lp_handle_idle_cycle(unsigned sched_ctx, int worker)
 			if(sc_hypervisor_check_idle(sched_ctx, worker))
                         {
                                 _try_resizing(NULL, -1, NULL, -1);
-//                              sc_hypervisor_move_workers(sched_ctx, 3 - sched_ctx, &worker, 1, 1);                                                                                                                
                         }
                 }
                 starpu_pthread_mutex_unlock(&act_hypervisor_mutex);

+ 3 - 7
sc_hypervisor/src/hypervisor_policies/teft_lp_policy.c

@@ -85,7 +85,6 @@ static void _size_ctxs(unsigned *sched_ctxs, int nsched_ctxs , int *workers, int
 		nt++;
 
 	double w_in_s[ns][nw];
-//	double tasks[nw][nt];
 	double **tasks=(double**)malloc(nw*sizeof(double*));
 	int i;
 	for(i = 0; i < nw; i++)
@@ -175,7 +174,7 @@ static void _try_resizing(unsigned *sched_ctxs, int nsched_ctxs , int *workers,
 
 	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
@@ -190,7 +189,6 @@ static void _try_resizing(unsigned *sched_ctxs, int nsched_ctxs , int *workers,
 	
 	
 	double w_in_s[ns][nw];
-//			double tasks_per_worker[nw][nt];
 	double **tasks_per_worker=(double**)malloc(nw*sizeof(double*));
 	int i;
 	for(i = 0; i < nw; i++)
@@ -208,13 +206,13 @@ static void _try_resizing(unsigned *sched_ctxs, int nsched_ctxs , int *workers,
 	   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, NULL);
-	double smallest_tmax = 0.0;//possible_tmax / 3;
+	double smallest_tmax = 0.0;
 	double tmax = possible_tmax * ns;
 	double tmin = smallest_tmax;
 
 	unsigned found_sol = sc_hypervisor_lp_execute_dichotomy(ns, nw, w_in_s, 1, (void*)&specific_data, 
 								tmin, tmax, smallest_tmax, _compute_workers_distrib);
-//			starpu_pthread_mutex_unlock(&mutex);
+//	starpu_pthread_mutex_unlock(&mutex);
 	
 	/* if we did find at least one solution redistribute the resources */
 	if(found_sol)
@@ -282,7 +280,6 @@ static void teft_lp_handle_idle_cycle(unsigned sched_ctx, int worker)
 			return;
 		}
 
-
 		unsigned criteria = sc_hypervisor_get_resize_criteria();
 		if(criteria != SC_NOTHING && criteria == SC_IDLE)
 		{
@@ -290,7 +287,6 @@ static void teft_lp_handle_idle_cycle(unsigned sched_ctx, int worker)
 			if(sc_hypervisor_check_idle(sched_ctx, worker))
 			{
 				_try_resizing(NULL, -1, NULL, -1);
-//				sc_hypervisor_move_workers(sched_ctx, 3 - sched_ctx, &worker, 1, 1);
 			}
 		}
 		starpu_pthread_mutex_unlock(&act_hypervisor_mutex);

+ 2 - 1
sc_hypervisor/src/policies_utils/dichotomy.c

@@ -19,6 +19,8 @@
 #include <math.h>
 #include <sys/time.h>
 
+/* executes the function lp_estimated_distrib_func over the interval [tmin, tmax] until it finds the lowest value that
+   still has solutions */
 unsigned sc_hypervisor_lp_execute_dichotomy(int ns, int nw, double w_in_s[ns][nw], unsigned solve_lp_integer, void *specific_data,
 					    double tmin, double tmax, double smallest_tmax,
 					    double (*lp_estimated_distrib_func)(int ns, int nw, double draft_w_in_s[ns][nw], 
@@ -82,7 +84,6 @@ unsigned sc_hypervisor_lp_execute_dichotomy(int ns, int nw, double w_in_s[ns][nw
 
 	float timing = (float)(diff_s*1000000 + diff_us)/1000;
 
-//        fprintf(stdout, "nd = %d total time: %f ms \n", nd, timing);
 	return found_sol;
 }
 

+ 213 - 0
sc_hypervisor/src/policies_utils/lp_programs.c

@@ -447,4 +447,217 @@ double sc_hypervisor_lp_simulate_distrib_flops(int ns, int nw, double v[ns][nw],
 	return vmax;
 }
 
+double sc_hypervisor_lp_simulate_distrib_flops_on_sample(int ns, int nw, double final_w_in_s[ns][nw], unsigned is_integer, double tmax, 
+							 double **speed, double flops[ns], double **final_flops_on_w)
+{
+	double w_in_s[ns][nw];
+	double flops_on_w[ns][nw];
+
+	int w, s;
+	glp_prob *lp;
+
+//	printf("try with tmax %lf\n", tmax);
+	lp = glp_create_prob();
+	glp_set_prob_name(lp, "StarPU theoretical bound");
+	glp_set_obj_dir(lp, GLP_MAX);
+	glp_set_obj_name(lp, "total execution time");
+
+	{
+		int ne = 5 * ns * nw /* worker execution time */
+			+ 1; /* glp dumbness */
+		int n = 1;
+		int ia[ne], ja[ne];
+		double ar[ne];
+
+
+		/* Variables: number of flops assigned to worker w in context s, and 
+		 the acknwoledgment that the worker w belongs to the context s */
+		glp_add_cols(lp, 2*nw*ns);
+#define colnum_sample(w, s) ((s)*nw+(w)+1)
+		for(s = 0; s < ns; s++)
+			for(w = 0; w < nw; w++)
+				glp_set_obj_coef(lp, nw*ns+colnum_sample(w,s), 1.);
+		
+		for(s = 0; s < ns; s++)
+			for(w = 0; w < nw; w++)
+			{
+				char name[32];
+				snprintf(name, sizeof(name), "flopsw%ds%dn", w, s);
+				glp_set_col_name(lp, colnum_sample(w,s), name);
+				glp_set_col_bnds(lp, colnum_sample(w,s), GLP_LO, 0., 0.);
+
+				snprintf(name, sizeof(name), "w%ds%dn", w, s);
+				glp_set_col_name(lp, nw*ns+colnum_sample(w,s), name);
+				if (is_integer)
+				{
+                                        glp_set_col_kind(lp, nw*ns+colnum_sample(w, s), GLP_IV);
+					glp_set_col_bnds(lp, nw*ns+colnum_sample(w,s), GLP_DB, 0, 1);
+				}
+				else
+					glp_set_col_bnds(lp, nw*ns+colnum_sample(w,s), GLP_DB, 0.0, 1.0);
+
+			}
+
+
+		int curr_row_idx = 0;
+		/* Total worker execution time */
+		glp_add_rows(lp, nw*ns);
+
+		/*nflops[s][w]/v[s][w] < x[s][w]*tmax */
+		for(s = 0; s < ns; s++)
+		{
+			for (w = 0; w < nw; w++)
+			{
+				char name[32], title[64];
+				starpu_worker_get_name(w, name, sizeof(name));
+				snprintf(title, sizeof(title), "worker %s", name);
+				glp_set_row_name(lp, curr_row_idx+s*nw+w+1, title);
+
+				/* nflosp[s][w] */
+				ia[n] = curr_row_idx+s*nw+w+1;
+				ja[n] = colnum_sample(w, s);
+				ar[n] = 1 / speed[s][w];
+
+				n++;
+				
+				/* x[s][w] = 1 | 0 */
+				ia[n] = curr_row_idx+s*nw+w+1;
+				ja[n] = nw*ns+colnum_sample(w,s);
+				ar[n] = (-1) * tmax;
+				n++;
+				glp_set_row_bnds(lp, curr_row_idx+s*nw+w+1, GLP_UP, 0.0, 0.0);
+			}
+		}
+
+		curr_row_idx += nw*ns;
+
+		/* sum(flops[s][w]) = flops[s] */
+		glp_add_rows(lp, ns);
+		for (s = 0; s < ns; s++)
+		{
+			char name[32], title[64];
+			starpu_worker_get_name(w, name, sizeof(name));
+			snprintf(title, sizeof(title), "flops %lf ctx%d", flops[s], s);
+			glp_set_row_name(lp, curr_row_idx+s+1, title);
+			for (w = 0; w < nw; w++)
+			{
+				ia[n] = curr_row_idx+s+1;
+				ja[n] = colnum_sample(w, s);
+				ar[n] = 1;
+				n++;
+			}
+			glp_set_row_bnds(lp, curr_row_idx+s+1, GLP_FX, flops[s], flops[s]);
+		}
+
+		curr_row_idx += ns;
+
+		/* sum(x[s][w]) = 1 */
+		glp_add_rows(lp, nw);
+		for (w = 0; w < nw; w++)
+		{
+			char name[32], title[64];
+			starpu_worker_get_name(w, name, sizeof(name));
+			snprintf(title, sizeof(title), "w%x", w);
+			glp_set_row_name(lp, curr_row_idx+w+1, title);
+			for(s = 0; s < ns; s++)
+			{
+				ia[n] = curr_row_idx+w+1;
+				ja[n] = nw*ns+colnum_sample(w,s);
+				ar[n] = 1;
+				n++;
+			}
+			if(is_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);
+		}
+
+		curr_row_idx += nw;
+
+		/* sum(nflops[s][w]) > 0*/
+		glp_add_rows(lp, nw);
+		for (w = 0; w < nw; w++)
+		{
+			char name[32], title[64];
+			starpu_worker_get_name(w, name, sizeof(name));
+			snprintf(title, sizeof(title), "flopsw%x", w);
+			glp_set_row_name(lp, curr_row_idx+w+1, title);
+			for(s = 0; s < ns; s++)
+			{
+				ia[n] = curr_row_idx+w+1;
+				ja[n] = colnum_sample(w,s);
+				ar[n] = 1;
+				n++;
+			}
+
+			glp_set_row_bnds(lp, curr_row_idx+w+1, GLP_LO, 0.1, 0.);
+		}
+
+		if(n != ne)
+			printf("ns= %d nw = %d n = %d ne = %d\n", ns, nw, n, ne);
+		STARPU_ASSERT(n == ne);
+
+		glp_load_matrix(lp, ne-1, ia, ja, ar);
+	}
+
+	glp_smcp parm;
+	glp_init_smcp(&parm);
+	parm.msg_lev = GLP_MSG_OFF;
+	int ret = glp_simplex(lp, &parm);
+	if (ret)
+	{
+		glp_delete_prob(lp);
+		lp = NULL;
+		return 0.0;
+	}
+
+        if (is_integer)
+        {
+                glp_iocp iocp;
+                glp_init_iocp(&iocp);
+                iocp.msg_lev = GLP_MSG_OFF;
+                glp_intopt(lp, &iocp);
+		int stat = glp_mip_status(lp);
+		/* if we don't have a solution return */
+		if(stat == GLP_NOFEAS)
+		{
+			glp_delete_prob(lp);
+			lp = NULL;
+			return 0.0;
+		}
+        }
+
+	int stat = glp_get_prim_stat(lp);
+	/* if we don't have a solution return */
+	if(stat == GLP_NOFEAS)
+	{
+		glp_delete_prob(lp);
+		lp = NULL;
+		return 0.0;
+	}
+
+	double res = glp_get_obj_val(lp);
+
+	for(s = 0; s < ns; s++)
+		for(w = 0; w < nw; w++)
+		{
+			flops_on_w[s][w] = glp_get_col_prim(lp, colnum_sample(w, s));
+			if (is_integer)
+				w_in_s[s][w] = (double)glp_mip_col_val(lp, nw*ns+colnum_sample(w, s));
+			else
+				w_in_s[s][w] = glp_get_col_prim(lp, nw*ns+colnum_sample(w,s));
+//			printf("w_in_s[s%d][w%d] = %lf flops[s%d][w%d] = %lf \n", s, w, w_in_s[s][w], s, w, flops_on_w[s][w]);
+		}
+
+	glp_delete_prob(lp);
+	for(s = 0; s < ns; s++)
+		for(w = 0; w < nw; w++)
+		{
+			final_w_in_s[s][w] = w_in_s[s][w];
+			final_flops_on_w[s][w] = flops_on_w[s][w];
+		}
+
+	return res;
+
+}
 #endif // STARPU_HAVE_GLPK_H

+ 1 - 13
sc_hypervisor/src/policies_utils/lp_tools.c

@@ -39,23 +39,11 @@ double sc_hypervisor_lp_get_nworkers_per_ctx(int nsched_ctxs, int ntypes_of_work
 	for(i = 0; i < nsched_ctxs; i++)
 	{
 		sc_w = sc_hypervisor_get_wrapper(sched_ctxs[i]);
-/* #ifdef STARPU_USE_CUDA */
-/* 		int ncuda = starpu_worker_get_count_by_type(STARPU_CUDA_WORKER); */
-/* 		if(ncuda != 0) */
-/* 		{ */
-/* 			v[i][0] = sc_hypervisor_get_speed(sc_w, STARPU_CUDA_WORKER); */
-/* 			v[i][1] = sc_hypervisor_get_speed(sc_w, STARPU_CPU_WORKER); */
-/* 		} */
-/* 		else */
-/* 			v[i][0] = sc_hypervisor_get_speed(sc_w, STARPU_CPU_WORKER); */
-/* #else */
-/* 		v[i][0] = sc_hypervisor_get_speed(sc_w, STARPU_CPU_WORKER); */
-/* #endif // STARPU_USE_CUDA */
 		int w;
 		for(w = 0; w < nw; w++)
 			v[i][w] = sc_hypervisor_get_speed(sc_w, sc_hypervisor_get_arch_for_index(w, tw)); 
 		
-		flops[i] = sc_w->remaining_flops < 0.0 ? 0.0 : sc_w->remaining_flops/1000000000; //sc_w->total_flops/1000000000; /* in gflops*/
+		flops[i] = sc_w->remaining_flops < 0.0 ? 0.0 : sc_w->remaining_flops/1000000000; /* in gflops*/
 //		printf("%d: flops %lf\n", sched_ctxs[i], flops[i]);
 	}
 

+ 5 - 2
sc_hypervisor/src/policies_utils/speed.c

@@ -165,17 +165,20 @@ double sc_hypervisor_get_ref_speed_per_worker_type(struct sc_hypervisor_wrapper*
 	return -1.0;
 }
 
+/* returns the speed necessary for the linear programs (either the monitored one either a default value) */
 double sc_hypervisor_get_speed(struct sc_hypervisor_wrapper *sc_w, enum starpu_worker_archtype arch)
 {
-
+	/* monitored speed in the last frame */
 	double speed = sc_hypervisor_get_speed_per_worker_type(sc_w, arch);
 	if(speed == -1.0)
 	{
+		/* avg value of the monitored speed over the entier current execution */
 		speed = sc_hypervisor_get_ref_speed_per_worker_type(sc_w, arch);
 	}
 	if(speed == -1.0)
 	{
-		speed = arch == STARPU_CPU_WORKER ? 5.0 : 100.0;
+		/* a default value */
+		speed = arch == STARPU_CPU_WORKER ? SC_HYPERVISOR_DEFAULT_CPU_SPEED : SC_HYPERVISOR_DEFAULT_CUDA_SPEED;
 	}
        
 	return speed;

+ 1 - 4
sc_hypervisor/src/sc_hypervisor.c

@@ -247,7 +247,6 @@ static void _print_current_time()
 
 void sc_hypervisor_shutdown(void)
 {
-//	printf("shutdown\n");
 	int i;
 	for(i = 0; i < STARPU_NMAX_SCHED_CTXS; i++)
 	{
@@ -344,8 +343,6 @@ void sc_hypervisor_unregister_ctx(unsigned sched_ctx)
 	hypervisor.sched_ctx_w[sched_ctx].sched_ctx = STARPU_NMAX_SCHED_CTXS;
 	_remove_config(sched_ctx);
 
-/* 	free(hypervisor.configurations[sched_ctx]); */
-/* 	free(hypervisor.resize_requests[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)
@@ -796,7 +793,7 @@ static void notify_poped_task(unsigned sched_ctx, int worker, struct starpu_task
 	hypervisor.sched_ctx_w[sched_ctx].elapsed_data[worker] += data_size ;
 	hypervisor.sched_ctx_w[sched_ctx].elapsed_tasks[worker]++ ;
 	hypervisor.sched_ctx_w[sched_ctx].total_elapsed_flops[worker] += task->flops;
-	hypervisor.sched_ctx_w[sched_ctx].remaining_flops -= task->flops; //sc_hypervisor_get_elapsed_flops_per_sched_ctx(&hypervisor.sched_ctx_w[sched_ctx]);
+	hypervisor.sched_ctx_w[sched_ctx].remaining_flops -= task->flops;
 
 	if(hypervisor.resize[sched_ctx])
 	{	

+ 2 - 0
sc_hypervisor/src/sc_hypervisor_intern.h

@@ -18,6 +18,8 @@
 #include <common/uthash.h>
 
 #define SC_SPEED_MAX_GAP_DEFAULT 50
+#define SC_HYPERVISOR_DEFAULT_CPU_SPEED 5.0
+#define SC_HYPERVISOR_DEFAULT_CUDA_SPEED 100.0
 
 struct size_request
 {

+ 3 - 0
src/core/sched_ctx.c

@@ -527,6 +527,9 @@ static void _starpu_delete_sched_ctx(struct _starpu_sched_ctx *sched_ctx)
 	STARPU_PTHREAD_MUTEX_DESTROY(&sched_ctx->empty_ctx_mutex);
 	sem_destroy(&sched_ctx->parallel_code_sem);
 	sched_ctx->id = STARPU_NMAX_SCHED_CTXS;
+#ifdef STARPU_HAVE_HWLOC
+	hwloc_bitmap_free(sched_ctx->hwloc_workers_set);
+#endif //STARPU_HAVE_HWLOC
 
 	struct _starpu_machine_config *config = _starpu_get_machine_config();
 	STARPU_PTHREAD_MUTEX_LOCK(&sched_ctx_manag);