Browse Source

small fix to resize ctxs when only cpus are available

Andra Hugo 12 years ago
parent
commit
b0b9e3f308

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

@@ -25,7 +25,7 @@ static void _try_resizing(int *sched_ctxs, int nsched_ctxs)
 	/* for vite */
 	starpu_trace_user_event(2);
 	int ns = sched_ctxs == NULL ? sc_hypervisor_get_nsched_ctxs() : nsched_ctxs;
-	sched_ctxs = sched_ctxs == NULL ? sc_hypervisor_get_sched_ctxs() : sched_ctxs;
+	int curr_sched_ctxs = sched_ctxs == NULL ? sc_hypervisor_get_sched_ctxs() : sched_ctxs;
 
 	double nworkers_per_ctx[ns][2];
 	int nw = 1;
@@ -40,7 +40,7 @@ static void _try_resizing(int *sched_ctxs, int nsched_ctxs)
 	struct timeval start_time;
 	struct timeval end_time;
 	gettimeofday(&start_time, NULL);
-	
+	printf("###########################################try resize\n");
 	double vmax = sc_hypervisor_lp_get_nworkers_per_ctx(ns, nw, nworkers_per_ctx, total_nw);
 	gettimeofday(&end_time, NULL);
 	
@@ -53,7 +53,7 @@ static void _try_resizing(int *sched_ctxs, int nsched_ctxs)
 	{
 		int nworkers_per_ctx_rounded[nsched_ctxs][nw];
 		sc_hypervisor_lp_round_double_to_int(ns, nw, nworkers_per_ctx, nworkers_per_ctx_rounded);
-		sc_hypervisor_lp_redistribute_resources_in_ctxs(ns, nw, nworkers_per_ctx_rounded, nworkers_per_ctx, sched_ctxs);
+		sc_hypervisor_lp_redistribute_resources_in_ctxs(ns, nw, nworkers_per_ctx_rounded, nworkers_per_ctx, curr_sched_ctxs);
 	}
 }
 

+ 12 - 7
sc_hypervisor/src/policies_utils/lp_tools.c

@@ -153,13 +153,12 @@ void _lp_find_workers_to_give_away(int nw, int ns, unsigned sched_ctx, int sched
 	for(w = 0; w < nw; w++)
 	{
 		enum starpu_worker_archtype arch = STARPU_ANY_WORKER;
-		if(w == 0) arch = STARPU_CUDA_WORKER;
-		if(w == 1) arch = STARPU_CPU_WORKER;
 		
-		
-		if(w == 1)
+		if(w == 1 || nw == 1) 
 		{
+			arch = STARPU_CPU_WORKER;
 			int nworkers_ctx = sc_hypervisor_get_nworkers_ctx(sched_ctx, arch);
+			printf("%d: cpus in ctx %d\n", sched_ctx, nworkers_ctx);
 			if(nworkers_ctx > res_rounded[sched_ctx_idx][w])
 			{
 				int nworkers_to_move = nworkers_ctx - res_rounded[sched_ctx_idx][w];
@@ -172,6 +171,7 @@ void _lp_find_workers_to_give_away(int nw, int ns, unsigned sched_ctx, int sched
 		}
 		else
 		{
+			arch = STARPU_CUDA_WORKER;
 			double nworkers_ctx = sc_hypervisor_get_nworkers_ctx(sched_ctx, arch) * 1.0;
 			if(nworkers_ctx > res[sched_ctx_idx][w])
 			{
@@ -227,9 +227,14 @@ void _lp_find_workers_to_accept(int nw, int ns, unsigned sched_ctx, int sched_ct
 	for(w = 0; w < nw; w++)
 	{
 		enum starpu_worker_archtype arch = STARPU_ANY_WORKER;
-		if(w == 0) arch = STARPU_CUDA_WORKER;
-		if(w == 1) arch = STARPU_CPU_WORKER;
-		
+		if(nw == 1)
+			arch = STARPU_CPU_WORKER;
+		else
+		{
+			if(w == 0) arch = STARPU_CUDA_WORKER;
+			if(w == 1) arch = STARPU_CPU_WORKER;
+		}
+
 		int nw_ctx2 = sc_hypervisor_get_nworkers_ctx(sched_ctx, arch);
 		int nw_needed = res_rounded[sched_ctx_idx][w] - nw_ctx2;
 		

+ 1 - 0
sc_hypervisor/src/sc_hypervisor.c

@@ -133,6 +133,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 */
 struct starpu_sched_ctx_performance_counters* sc_hypervisor_init(struct sc_hypervisor_policy *hypervisor_policy)
 {
+	printf("****************$$$$$$$$$$$$$$$$$$$hereeeeeeeeeeeeeeeeeeeeeeeeeeeee\n");
 	hypervisor.min_tasks = 0;
 	hypervisor.nsched_ctxs = 0;
 	char* vel_gap = getenv("SC_HYPERVISOR_MAX_SPEED_GAP");