浏览代码

fix bug node_worker predictions

Simon Archipoff 12 年之前
父节点
当前提交
4303e0a2a0
共有 3 个文件被更改,包括 16 次插入5 次删除
  1. 2 1
      src/sched_policies/node_heft.c
  2. 13 3
      src/sched_policies/node_worker.c
  3. 1 1
      tests/parallel_tasks/parallel_kernels_spmd.c

+ 2 - 1
src/sched_policies/node_heft.c

@@ -117,13 +117,14 @@ static int push_task(struct _starpu_sched_node * node, struct starpu_task * task
 					 preds + i,
 					 best_exp_end,
 					 max_exp_end);
+//		fprintf(stderr,"fitness for worker %d is %f\n",i,tmp == DBL_MAX ? -1 : tmp);
 		if(tmp < best_fitness)
 		{
 			best_fitness = tmp;
 			index_best_fitness = i;
 		}
 	}
-
+//	fprintf(stderr,"push on worker %d\n",index_best_fitness);
 	STARPU_ASSERT(best_fitness != DBL_MAX);
 
 	struct _starpu_sched_node * c = node->childs[index_best_fitness];

+ 13 - 3
src/sched_policies/node_worker.c

@@ -97,7 +97,6 @@ static void _starpu_worker_task_list_destroy(struct _starpu_worker_task_list * l
 {
 	if(l)
 	{
-
 		STARPU_PTHREAD_MUTEX_DESTROY(&l->mutex);
 		free(l);
 	}
@@ -106,6 +105,7 @@ static void _starpu_worker_task_list_destroy(struct _starpu_worker_task_list * l
 /* the task, ntasks, pntasks, left and right field members are set by the caller */
 static inline void _starpu_worker_task_list_push(struct _starpu_worker_task_list * l, struct _starpu_task_grid * t)
 {
+	STARPU_ASSERT(t->task);
 	if(l->first == NULL)
 		l->first = l->last = t;
 	t->down = l->last;
@@ -113,6 +113,12 @@ static inline void _starpu_worker_task_list_push(struct _starpu_worker_task_list
 	t->up = NULL;
 	l->last = t;
 	l->ntasks++;
+	l->exp_start = starpu_timing_now();
+	if(!isnan(t->task->predicted))
+	{
+		l->exp_len += t->task->predicted;
+		l->exp_end = l->exp_start + l->exp_end;
+	}
 }
 
 //recursively set left and right pointers to NULL
@@ -172,6 +178,11 @@ static inline struct starpu_task * _starpu_worker_task_list_pop(struct _starpu_w
 			if(*p == 0)
 				_starpu_task_grid_unset_left_right_member(t);
 			l->ntasks--;
+			if(!isnan(task->predicted))
+			{
+				l->exp_len -= task->predicted;
+				l->exp_end = l->exp_start + l->exp_len;
+			}
 			return task;
 		}
 		t = t->up;
@@ -348,7 +359,6 @@ static double worker_estimated_finish_time(struct _starpu_worker * worker)
 	    task = starpu_task_list_next(task))
 		if(!isnan(task->predicted))
 		   sum += task->predicted;
-
 	if(worker->current_task) 
 	{
 		struct starpu_task * t = worker->current_task;
@@ -405,7 +415,7 @@ static struct _starpu_task_execute_preds estimated_execute_preds(struct _starpu_
 	int nimpl;
 	for(nimpl = 0; nimpl < STARPU_MAXIMPLEMENTATIONS; nimpl++)
 	{
-		if(/*starpu_worker_can_execute_task(workerid,task,nimpl) ||*/ starpu_combined_worker_can_execute_task(workerid, task, nimpl))
+		if(starpu_worker_can_execute_task(workerid,task,nimpl) || starpu_combined_worker_can_execute_task(workerid, task, nimpl))
 		{
 			double d;
 			if(bundle)

+ 1 - 1
tests/parallel_tasks/parallel_kernels_spmd.c

@@ -32,7 +32,7 @@ static void codelet_null(void *descr[], STARPU_ATTRIBUTE_UNUSED void *_args)
 	STARPU_ASSERT(worker_size > 0);
 
 	usleep(1000/worker_size);
-#if 1
+#if 0
 	int id = starpu_worker_get_id();
 	int combined_id = starpu_combined_worker_get_id();
 	int rank = starpu_combined_worker_get_rank();