Andra Hugo 13 lat temu
rodzic
commit
0fd804f264

+ 51 - 21
sched_ctx_hypervisor/src/hypervisor_policies/lp3_policy.c

@@ -17,7 +17,8 @@
 #include "policy_utils.h"
 #include <math.h>
 
-static struct bound_task_pool *task_pools, *last;
+//static struct bound_task_pool *task_pools, *last;
+static struct bound_task_pool *task_pools;
 
 static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
 
@@ -26,12 +27,12 @@ static void lp3_handle_submitted_job(struct starpu_task *task, unsigned footprin
 	pthread_mutex_lock(&mutex);
 	struct bound_task_pool *tp;
 	
-	if (last && last->cl == task->cl && last->footprint == footprint && last->sched_ctx_id == task->sched_ctx)
-		tp = last;
-	else
-		for (tp = task_pools; tp; tp = tp->next)
-			if (tp->cl == task->cl && tp->footprint == footprint && tp->sched_ctx_id == task->sched_ctx)
-					break;
+/* 	if (last && last->cl == task->cl && last->footprint == footprint && last->sched_ctx_id == task->sched_ctx) */
+/* 		tp = last; */
+/* 	else */
+	for (tp = task_pools; tp; tp = tp->next)
+		if (tp->cl == task->cl && tp->footprint == footprint && tp->sched_ctx_id == task->sched_ctx)
+			break;
 	
 	if (!tp)
 	{
@@ -42,8 +43,12 @@ static void lp3_handle_submitted_job(struct starpu_task *task, unsigned footprin
 		tp->n = 0;
 		tp->next = task_pools;
 		task_pools = tp;
+//		printf("add t_foot%d_%s\n", (int)tp->footprint, tp->cl->model->symbol);
 	}
-	
+/* 	else */
+/* 	{ */
+/* 		printf("increment t_foot%d_%s\n", (int)tp->footprint, tp->cl->model->symbol); */
+/* 	} */
 	/* One more task of this kind */
 	tp->n++;
 	pthread_mutex_unlock(&mutex);
@@ -65,7 +70,7 @@ static void _starpu_get_tasks_times(int nw, int nt, double times[nw][nt])
                        else
                                 times[w][t] = length / 1000.;
 			
-//			printf("t%d on worker %d ctx %d: %lf \n", t, w, tp->sched_ctx_id, times[w][t]);
+//			printf("t%d_%s on worker %d ctx %d: %lf \n", t, tp->cl->model->symbol, w, tp->sched_ctx_id, times[w][t]);
                 }
 //		printf("\n");
         }
@@ -123,7 +128,7 @@ static double _glp_resolve(int ns, int nw, int nt, double tasks[nw][nt], double
 				char name[32];
 				snprintf(name, sizeof(name), "w%ds%dn", w, s);
 				glp_set_col_name(lp, nw*nt+s*nw+w+1, name);	
-				glp_set_col_bnds(lp, nw*nt+s*nw+w+1, GLP_LO, 0., 0.);
+				glp_set_col_bnds(lp, nw*nt+s*nw+w+1, GLP_DB, 0.0, 1.0);
 			}
 
 		int *sched_ctxs = sched_ctx_hypervisor_get_sched_ctxs();
@@ -170,7 +175,7 @@ static double _glp_resolve(int ns, int nw, int nt, double tasks[nw][nt], double
 				ja[n] = nw*nt+s*nw+w+1;
 				ar[n] = (-1) * tmax;
 				n++;
-				glp_set_row_bnds(lp, curr_row_idx+s*nw+w+1, GLP_UP, 0, 0);
+				glp_set_row_bnds(lp, curr_row_idx+s*nw+w+1, GLP_UP, 0.0, 0.0);
 			}
 		}
 
@@ -212,7 +217,7 @@ static double _glp_resolve(int ns, int nw, int nt, double tasks[nw][nt], double
 				n++;
 			}
 
-			glp_set_row_bnds(lp, curr_row_idx+w+1, GLP_FX, 1, 1);
+			glp_set_row_bnds(lp, curr_row_idx+w+1, GLP_FX, 1.0, 1.0);
 		}
 
 //		printf("n = %d nw*ns  = %d ne = %d\n", n, nw*ns, ne);
@@ -223,7 +228,7 @@ static double _glp_resolve(int ns, int nw, int nt, double tasks[nw][nt], double
 
 	glp_smcp parm;
 	glp_init_smcp(&parm);
-	parm.msg_lev = GLP_MSG_OFF;
+//	parm.msg_lev = GLP_MSG_OFF;
 	int ret = glp_simplex(lp, &parm);
 	if (ret)
 	{
@@ -232,6 +237,15 @@ static double _glp_resolve(int ns, int nw, int nt, double tasks[nw][nt], double
 		return 0.0;
 	}
 
+	int stat = glp_get_prim_stat(lp);
+
+	if(stat == GLP_NOFEAS)
+	{
+		printf("NO FEASIBLE SOLUTION \n");
+		glp_delete_prob(lp);
+		lp = NULL;
+		return 0.0;
+	}
 	double res = glp_get_obj_val(lp);
 
 	printf("Z: %f (must be eq to nw %d)\n", res, nw);
@@ -292,6 +306,7 @@ static void _redistribute_resources_in_ctxs(int ns, int nw, int nt, double w_in_
 }
 
 static int done = 0;
+static int first = 0;
 static void lp3_handle_poped_task(unsigned sched_ctx, int worker)
 {
 	struct sched_ctx_wrapper* sc_w = sched_ctx_hypervisor_get_wrapper(sched_ctx);
@@ -299,6 +314,12 @@ static void lp3_handle_poped_task(unsigned sched_ctx, int worker)
 	int ret = pthread_mutex_trylock(&act_hypervisor_mutex);
 	if(ret != EBUSY)
 	{
+		if(!first)
+		{
+			task_pools = NULL;
+			first = 1;
+		}
+
 		if(sc_w->submitted_flops < sc_w->total_flops)
 		{
 			pthread_mutex_unlock(&act_hypervisor_mutex);
@@ -336,12 +357,14 @@ static void lp3_handle_poped_task(unsigned sched_ctx, int worker)
 				}
 
 			double tmax = 30000;
+			
 			double res = 1.0;
+			unsigned found_sol = 0;
 			while(tmax >= 1.0)
 			{
 				printf("resolve for tmax = %lf\n", tmax);
 				res = _glp_resolve(ns, nw, nt, draft_tasks, tmax, draft_w_in_s);
-				if(res == (double)nw)
+				if(res != 0.0)
 				{
 					for(w = 0; w < nw; w++)
 						for(t = 0; t < nt; t++)
@@ -349,25 +372,32 @@ static void lp3_handle_poped_task(unsigned sched_ctx, int worker)
 					for(s = 0; s < ns; s++)
 						for(w = 0; w < nw; w++)
 							w_in_s[s][w] = draft_w_in_s[s][w];
-
+					tmax /= 2;
+					found_sol = 1;
 				}
 				else
-				{
-					
-					printf("break\n");
 					break;
-				}
-				tmax /= 2;
+					
 			}
 
 /* 			for(w = 0; w < nw; w++) */
+/* 				for(t = 0; t < nt; t++) */
+/* 					tasks[w][t] = draft_tasks[w][t]; */
+/* 			for(s = 0; s < ns; s++) */
+/* 				for(w = 0; w < nw; w++) */
+/* 					w_in_s[s][w] = draft_w_in_s[s][w]; */
+
+/* 			for(w = 0; w < nw; w++) */
 /* 				for (t = 0, tp = task_pools; tp; t++, tp = tp->next) */
 /* 				{ */
 /* 					if(tasks[w][t] > 0.0) */
 /* 						printf("ctx %d/worker %d/task type %d: res = %lf \n", tp->sched_ctx_id, w, t, tasks[w][t]); */
 /* 				} */
 
-			_redistribute_resources_in_ctxs(ns, nw, nt, w_in_s);
+			if(found_sol)
+			{
+				_redistribute_resources_in_ctxs(ns, nw, nt, w_in_s);
+			}
 		}
 		pthread_mutex_unlock(&act_hypervisor_mutex);
 	}		

+ 13 - 13
sched_ctx_hypervisor/src/hypervisor_policies/lp_policy.c

@@ -160,7 +160,7 @@ static void _glp_resolve(int ns, int nw, double v[ns][nw], double flops[ns], dou
 //	glp_simplex(lp, NULL);
 	
 	double vmax1 = glp_get_obj_val(lp);
-	printf("vmax1 = %lf \n", vmax1);
+//	printf("vmax1 = %lf \n", vmax1);
 
 	n = 1;
 	for(s = 0; s < ns; s++)
@@ -360,25 +360,25 @@ static void lp_handle_poped_task(unsigned sched_ctx, int worker)
 			v[i][0] = 200.0;//_get_velocity_per_worker_type(sc_w, STARPU_CUDA_WORKER);
 			v[i][1] = 20.0;//_get_velocity_per_worker_type(sc_w, STARPU_CPU_WORKER);
 			flops[i] = sc_w->remaining_flops/1000000000; //sc_w->total_flops/1000000000; /* in gflops*/
-			printf("%d: flops %lf\n", sched_ctxs[i], flops[i]);
+//			printf("%d: flops %lf\n", sched_ctxs[i], flops[i]);
 		}
                 
 		int ret = pthread_mutex_trylock(&act_hypervisor_mutex);
 		if(ret != EBUSY)
 		{
 			_glp_resolve(nsched_ctxs, 2, v, flops, res);
-			for( i = 0; i < nsched_ctxs; i++)
-			{
-				printf("ctx %d/worker type %d: n = %lf \n", i, 0, res[i][0]);
-				printf("ctx %d/worker type %d: n = %lf \n", i, 1, res[i][1]);
-			}
+/* 			for( i = 0; i < nsched_ctxs; i++) */
+/* 			{ */
+/* 				printf("ctx %d/worker type %d: n = %lf \n", i, 0, res[i][0]); */
+/* 				printf("ctx %d/worker type %d: n = %lf \n", i, 1, res[i][1]); */
+/* 			} */
 			int res_rounded[nsched_ctxs][2];
-			_round_double_to_int(nsched_ctxs, 2, res, res_rounded);
-			for( i = 0; i < nsched_ctxs; i++)
-			{
-				printf("ctx %d/worker type %d: n = %d \n", i, 0, res_rounded[i][0]);
-				printf("ctx %d/worker type %d: n = %d \n", i, 1, res_rounded[i][1]);
-			}
+ 			_round_double_to_int(nsched_ctxs, 2, res, res_rounded);
+	/* 		for( i = 0; i < nsched_ctxs; i++) */
+/* 			{ */
+/* 				printf("ctx %d/worker type %d: n = %d \n", i, 0, res_rounded[i][0]); */
+/* 				printf("ctx %d/worker type %d: n = %d \n", i, 1, res_rounded[i][1]); */
+/* 			} */
 			
 			_redistribute_resources_in_ctxs(nsched_ctxs, 2, res_rounded, res);
 			

+ 1 - 1
sched_ctx_hypervisor/src/hypervisor_policies/policy_utils.c

@@ -345,7 +345,7 @@ int _velocity_gap_btw_ctxs()
 					{
 						double gap = ctx_v < other_ctx_v ? other_ctx_v / ctx_v : ctx_v / other_ctx_v ;
 //						printf("gap = %lf\n", gap);
-						if(gap > 5)
+						if(gap > 8)
 							return 1;
 					}
 				}

+ 3 - 0
src/core/perfmodel/perfmodel_history.c

@@ -1014,7 +1014,10 @@ double _starpu_history_based_job_expected_perf(struct starpu_perfmodel *model, e
 		/* TODO: report differently if we've scheduled really enough
 		 * of that task and the scheduler should perhaps put it aside */
 		/* Not calibrated enough */
+	{
+		printf("nan pt ca stupid algo nsamples %d\n", entry->nsample);
 		exp = NAN;
+	}
 
 	if (isnan(exp) && !model->benchmarking)
 	{

+ 2 - 1
src/drivers/driver_common/driver_common.c

@@ -127,8 +127,9 @@ void _starpu_driver_update_job_feedback(struct _starpu_job *j, struct _starpu_wo
 		}
 
 		if (calibrate_model)
-
+		{
 			_starpu_update_perfmodel_history(j, j->task->cl->model,  perf_arch, worker_args->devid, measured,j->nimpl);
+		}
 
 
 	}