Browse Source

fix bug in ispeed (reset counter in get_first_workers in the wrong place) + probably fix hydra bug (can't make it crash but not sure it is fixed)

Andra Hugo 12 years ago
parent
commit
ef6e41e8e6

+ 5 - 4
sched_ctx_hypervisor/src/hypervisor_policies/lp_tools.c

@@ -369,6 +369,7 @@ void _lp_redistribute_resources_in_ctxs(int ns, int nw, int res_rounded[ns][nw],
 				int nw_add = 0;
 
 				int w;
+				int j = 0, k = 0;
 				for(w = 0; w < nw; w++)
 				{
 					enum starpu_archtype arch = STARPU_ANY_WORKER;
@@ -381,7 +382,7 @@ void _lp_redistribute_resources_in_ctxs(int ns, int nw, int res_rounded[ns][nw],
 					if( nw_needed > 0 && tmp_nw_move[w] > 0)
 					{
 						nw_move += nw_needed >= tmp_nw_move[w] ? tmp_nw_move[w] : nw_needed;
-						int i = 0, j = 0;
+						int i = 0;
 						for(i = 0; i < STARPU_NMAXWORKERS; i++)
 						{
 							if(tmp_workers_move[w][i] != -1)
@@ -401,14 +402,14 @@ void _lp_redistribute_resources_in_ctxs(int ns, int nw, int res_rounded[ns][nw],
 					if(diff > 0.3 && tmp_nw_add[w] != 0)
 					{
 						nw_add = tmp_nw_add[w];
-						int i = 0, j = 0;
+						int i = 0;
 						for(i = 0; i < STARPU_NMAXWORKERS; i++)
 						{
 							if(tmp_workers_add[w][i] != -1)
 							{
-								workers_add[j++] = tmp_workers_add[w][i];
+								workers_add[k++] = tmp_workers_add[w][i];
 								tmp_workers_add[w][i] = -1;
-								if(j == nw_add)
+								if(k == nw_add)
 									break;
 							}
 						}

+ 0 - 1
sched_ctx_hypervisor/src/hypervisor_policies/policy_tools.c

@@ -169,7 +169,6 @@ int* _get_first_workers(unsigned sched_ctx, int *nworkers, enum starpu_archtype
 		}
 	}
 
-
 	return curr_workers;
 }
 

+ 1 - 1
sched_ctx_hypervisor/src/sched_ctx_hypervisor.c

@@ -419,7 +419,7 @@ void sched_ctx_hypervisor_move_workers(unsigned sender_sched_ctx, unsigned recei
 	{
 		_print_current_time();
 		int j;
-		printf("resize ctx %d with", sender_sched_ctx);
+		printf("resize ctx %d with %d workers", sender_sched_ctx, nworkers_to_move);
 		for(j = 0; j < nworkers_to_move; j++)
 			printf(" %d", workers_to_move[j]);
 		printf("\n");

+ 11 - 9
src/core/sched_ctx.c

@@ -726,17 +726,19 @@ void _starpu_decrement_nsubmitted_tasks_of_sched_ctx(unsigned sched_ctx_id)
 			_STARPU_PTHREAD_MUTEX_UNLOCK(&finished_submit_mutex);
 
 			/* take care the context is not deleted or changed at the same time */
-			_STARPU_PTHREAD_MUTEX_LOCK(&changing_ctx_mutex[sched_ctx->id]);
-			int *workerids = NULL;
-			unsigned nworkers = _get_workers_list(sched_ctx, &workerids);
-
-			if(nworkers > 0)
+			_STARPU_PTHREAD_MUTEX_LOCK(&changing_ctx_mutex[sched_ctx_id]);
+			if(sched_ctx->id != STARPU_NMAX_SCHED_CTXS)
 			{
-				starpu_sched_ctx_add_workers(workerids, nworkers, sched_ctx->inheritor);
-				free(workerids);
+				int *workerids = NULL;
+				unsigned nworkers = _get_workers_list(sched_ctx, &workerids);
+				
+				if(nworkers > 0)
+				{
+					starpu_sched_ctx_add_workers(workerids, nworkers, sched_ctx->inheritor);
+					free(workerids);
+				}
 			}
-
-			_STARPU_PTHREAD_MUTEX_UNLOCK(&changing_ctx_mutex[sched_ctx->id]);
+			_STARPU_PTHREAD_MUTEX_UNLOCK(&changing_ctx_mutex[sched_ctx_id]);
 
 			return;
 		}