Forráskód Böngészése

allow the user introduce the types of tasks he will have in the appl (hope to have perf model for them)

Andra Hugo 12 éve
szülő
commit
dc1f675127

+ 2 - 1
sched_ctx_hypervisor/include/sched_ctx_hypervisor.h

@@ -171,7 +171,7 @@ struct sched_ctx_hypervisor_policy
 
 	void (*handle_post_exec_hook)(unsigned sched_ctx, int task_tag);
 
-	void (*handle_submitted_job)(struct starpu_task *task, unsigned footprint);
+	void (*handle_submitted_job)(struct starpu_codelet *cl, unsigned sched_ctx, uint32_t footprint);
 	
 	void (*end_ctx)(unsigned sched_ctx);
 };
@@ -231,6 +231,7 @@ double sched_ctx_hypervisor_get_velocity_per_worker_type(struct sched_ctx_hyperv
 
 double sched_ctx_hypervisor_get_velocity(struct sched_ctx_hypervisor_wrapper *sc_w, enum starpu_archtype arch);
 
+void sched_ctx_hypervisor_set_type_of_task(struct starpu_codelet *cl, unsigned sched_ctx, uint32_t footprint);
 #ifdef __cplusplus
 }
 #endif

+ 4 - 4
sched_ctx_hypervisor/src/hypervisor_policies/lp2_policy.c

@@ -165,7 +165,7 @@ static void size_if_required()
 	}
 }
 
-static void lp2_handle_submitted_job(struct starpu_task *task, uint32_t footprint)
+static void lp2_handle_submitted_job(struct starpu_codelet *cl, unsigned sched_ctx, uint32_t footprint)
 {
 	/* count the tasks of the same type */
 	starpu_pthread_mutex_lock(&mutex);
@@ -173,16 +173,16 @@ static void lp2_handle_submitted_job(struct starpu_task *task, uint32_t footprin
 
 	for (tp = task_pools; tp; tp = tp->next)
 	{
-		if (tp && tp->cl == task->cl && tp->footprint == footprint && tp->sched_ctx_id == task->sched_ctx)
+		if (tp && tp->cl == cl && tp->footprint == footprint && tp->sched_ctx_id == sched_ctx)
 			break;
 	}
 
 	if (!tp)
 	{
 		tp = (struct bound_task_pool *) malloc(sizeof(struct bound_task_pool));
-		tp->cl = task->cl;
+		tp->cl = cl;
 		tp->footprint = footprint;
-		tp->sched_ctx_id = task->sched_ctx;
+		tp->sched_ctx_id = sched_ctx;
 		tp->n = 0;
 		tp->next = task_pools;
 		task_pools = tp;

+ 11 - 8
sched_ctx_hypervisor/src/sched_ctx_hypervisor.c

@@ -19,6 +19,7 @@
 #include <starpu_config.h>
 
 unsigned imposed_resize = 0;
+unsigned type_of_tasks_known = 0;
 struct starpu_sched_ctx_performance_counters* perf_counters = NULL;
 
 static void notify_idle_cycle(unsigned sched_ctx, int worker, double idle_time);
@@ -497,11 +498,9 @@ void _reset_resize_sample_info(unsigned sender_sched_ctx, unsigned receiver_sche
 	
 	double start_time =  starpu_timing_now();
 	sender_sc_w->start_time = start_time;
-//	sender_sc_w->remaining_flops = sender_sc_w->remaining_flops - sched_ctx_hypervisor_get_elapsed_flops_per_sched_ctx(sender_sc_w);
 	_set_elapsed_flops_per_sched_ctx(sender_sched_ctx, 0.0);
 
 	receiver_sc_w->start_time = start_time;
-//	receiver_sc_w->remaining_flops = receiver_sc_w->remaining_flops - sched_ctx_hypervisor_get_elapsed_flops_per_sched_ctx(receiver_sc_w);
 	_set_elapsed_flops_per_sched_ctx(receiver_sched_ctx, 0.0);
 }
 
@@ -509,7 +508,7 @@ void _reset_resize_sample_info(unsigned sender_sched_ctx, unsigned receiver_sche
 /* forbids another resize request before this one is take into account */
 void sched_ctx_hypervisor_move_workers(unsigned sender_sched_ctx, unsigned receiver_sched_ctx, int* workers_to_move, unsigned nworkers_to_move, unsigned now)
 {
-	if(nworkers_to_move > 0 && hypervisor.resize[sender_sched_ctx])// && hypervisor.resize[receiver_sched_ctx])
+	if(nworkers_to_move > 0 && hypervisor.resize[sender_sched_ctx])
 	{
 		_print_current_time();
 		unsigned j;
@@ -553,7 +552,6 @@ void sched_ctx_hypervisor_move_workers(unsigned sender_sched_ctx, unsigned recei
 				}
 
 				hypervisor.resize[sender_sched_ctx] = 0;
-//				hypervisor.resize[receiver_sched_ctx] = 0;
 
 				starpu_pthread_mutex_unlock(&hypervisor.sched_ctx_w[sender_sched_ctx].mutex);
 			}
@@ -736,7 +734,6 @@ static unsigned _ack_resize_completed(unsigned sched_ctx, int worker)
 
 				hypervisor.resize[sender_sched_ctx] = 1;
 				hypervisor.allow_remove[receiver_sched_ctx] = 1;
-				//	hypervisor.resize[receiver_sched_ctx] = 1;
 				/* if the user allowed resizing leave the decisions to the application */
 				if(imposed_resize)  imposed_resize = 0;
 
@@ -882,8 +879,7 @@ static void notify_post_exec_hook(unsigned sched_ctx, int task_tag)
 			HASH_FIND_INT(hypervisor.resize_requests[sched_ctx], &task_tag, entry);
 			if (entry != NULL)
 			{
-				hypervisor.policy.handle_post_exec_hook(sched_ctx,
-									task_tag);
+				hypervisor.policy.handle_post_exec_hook(sched_ctx, task_tag);
 				HASH_DEL(hypervisor.resize_requests[sched_ctx], entry);
 				free(entry);
 			}
@@ -900,8 +896,15 @@ static void notify_submitted_job(struct starpu_task *task, uint32_t footprint)
 	hypervisor.sched_ctx_w[task->sched_ctx].submitted_flops += task->flops;
 	starpu_pthread_mutex_unlock(&act_hypervisor_mutex);
 
+	if(hypervisor.policy.handle_submitted_job && !type_of_tasks_known)
+		hypervisor.policy.handle_submitted_job(task->cl, task->sched_ctx, footprint);
+}
+
+void sched_ctx_hypervisor_set_type_of_task(struct starpu_codelet *cl, unsigned sched_ctx, uint32_t footprint)
+{
+	type_of_tasks_known = 1;
 	if(hypervisor.policy.handle_submitted_job)
-		hypervisor.policy.handle_submitted_job(task, footprint);
+		hypervisor.policy.handle_submitted_job(cl, sched_ctx, footprint);
 }
 
 static void notify_delete_context(unsigned sched_ctx)