Browse Source

fix other bugs in predictions

Simon Archipoff 12 years ago
parent
commit
935cf66ade
2 changed files with 37 additions and 12 deletions
  1. 26 5
      src/sched_policies/node_heft.c
  2. 11 7
      src/sched_policies/node_worker.c

+ 26 - 5
src/sched_policies/node_heft.c

@@ -54,12 +54,35 @@ static int push_task(struct starpu_sched_node * node, struct starpu_task * task)
 											 estimated_lengths[i],
 											 estimated_transfer_length[i]);
 			if(estimated_ends_with_task[i] < best_exp_end_with_task)	
-			best_exp_end_with_task = estimated_ends_with_task[i];
+				best_exp_end_with_task = estimated_ends_with_task[i];
 			if(estimated_ends_with_task[i] > max_exp_end_with_task)
 				max_exp_end_with_task = estimated_ends_with_task[i];
 			suitable_nodes[nsuitable_nodes++] = i;
 		}
 	}
+
+#if 0
+	fprintf(stderr,"estimated end           ");
+	for(i = 0; i < node->nchilds; i++)
+	{
+		fprintf(stderr,"%f ",estimated_ends[i]);
+	}
+	fprintf(stderr,"\n");
+	fprintf(stderr,"estimated end with task ");
+		for(i = 0; i < node->nchilds; i++)
+	{
+		fprintf(stderr,"%f ",estimated_ends_with_task[i]);
+	}
+	fprintf(stderr,"\n");
+	fprintf(stderr,"estimated length        ");
+		for(i = 0; i < node->nchilds; i++)
+	{
+		fprintf(stderr,"%f ",estimated_lengths[i]);
+	}
+	fprintf(stderr,"\n\n");
+#endif
+
+
 	double best_fitness = DBL_MAX;
 	int best_inode = -1;
 	for(i = 0; i < nsuitable_nodes; i++)
@@ -71,14 +94,12 @@ static int push_task(struct starpu_sched_node * node, struct starpu_task * task)
 					     max_exp_end_with_task,
 					     estimated_transfer_length[inode],
 					     0.0);
-//		fprintf(stderr,"%f %d\n", tmp, inode);
 		if(tmp < best_fitness)
 		{
 			best_fitness = tmp;
 			best_inode = inode;
 		}
 	}
-//	fprintf(stderr,"push %d\n",best_inode);
 	STARPU_ASSERT(best_inode != -1);
 	best_node = node->childs[best_inode];
 	return best_node->push_task(best_node, task);
@@ -254,8 +275,8 @@ struct starpu_sched_policy _starpu_sched_tree_heft_policy =
 	.remove_workers = starpu_sched_tree_remove_workers,
 	.push_task = starpu_sched_tree_push_task,
 	.pop_task = starpu_sched_tree_pop_task,
-	.pre_exec_hook = NULL,
-	.post_exec_hook = NULL,
+	.pre_exec_hook = starpu_sched_node_worker_pre_exec_hook,
+	.post_exec_hook = starpu_sched_node_worker_post_exec_hook,
 	.pop_every_task = NULL,
 	.policy_name = "tree-heft",
 	.policy_description = "heft tree policy"

+ 11 - 7
src/sched_policies/node_worker.c

@@ -131,8 +131,8 @@ static inline void _starpu_worker_task_list_push(struct _starpu_worker_task_list
 	double predicted = t->task->predicted;
 	double predicted_transfer = t->task->predicted_transfer;
 
-	/* Sometimes workers didn't take the tasks as early as we expected */
-	l->exp_start = STARPU_MAX(l->exp_start, starpu_timing_now());
+	/* Sometimes workers didn't take the tasks as early as we expected 
+	   l->exp_start = STARPU_MAX(l->exp_start, starpu_timing_now());*/
 	l->exp_end = l->exp_start + l->exp_len;
 
 	if ((starpu_timing_now() + predicted_transfer) < l->exp_end)
@@ -220,7 +220,7 @@ static inline struct starpu_task * _starpu_worker_task_list_pop(struct _starpu_w
 			(void) STARPU_ATOMIC_ADD(p, -1);
 			if(*p == 0)
 				_starpu_task_grid_unset_left_right_member(t);
-			l->ntasks--;
+//			l->ntasks--;
 			if(!isnan(task->predicted))
 			{
 				l->exp_len -= task->predicted_transfer;
@@ -719,16 +719,18 @@ void starpu_sched_node_worker_pre_exec_hook(struct starpu_task * task)
 	{
 		struct _starpu_worker_task_list * list = _worker_get_list();
 		STARPU_PTHREAD_MUTEX_LOCK(&list->mutex);
-		STARPU_ASSERT(list->ntasks != 0);
-		list->ntasks--;
 		if(!task->execute_on_a_specific_worker)
-			list->exp_len = STARPU_MAX(list->exp_len - task->predicted, 0.0);
+		{
+			STARPU_ASSERT(list->ntasks != 0);
+			list->ntasks--;
+		}
 
 		list->exp_start = starpu_timing_now() + task->predicted;
+
 		if(list->ntasks == 0)
 		{
 			list->exp_end = list->exp_start;
-			list->exp_end = 0.0;
+			list->exp_len = 0.0;
 		}
 		else
 			list->exp_end = list->exp_start + list->exp_len;
@@ -749,6 +751,7 @@ void starpu_sched_node_worker_post_exec_hook(struct starpu_task * task)
 static void starpu_sched_node_worker_push_task_notify(struct starpu_task *task, int workerid, unsigned sched_ctx_id STARPU_ATTRIBUTE_UNUSED)
 {
 
+#if 0
 	struct starpu_sched_node * worker_node = starpu_sched_node_worker_get(workerid);
 	/* dont work with parallel tasks */
 	if(starpu_sched_node_is_combined_worker(worker_node))
@@ -802,4 +805,5 @@ static void starpu_sched_node_worker_push_task_notify(struct starpu_task *task,
 	list->ntasks++;
 
 	STARPU_PTHREAD_MUTEX_UNLOCK(&list->mutex);
+#endif
 }