瀏覽代碼

pheft: use post_exec_hook to fix the expected start

Samuel Thibault 5 年之前
父節點
當前提交
fd39d1a37c
共有 1 個文件被更改,包括 14 次插入2 次删除
  1. 14 2
      src/sched_policies/parallel_heft.c

+ 14 - 2
src/sched_policies/parallel_heft.c

@@ -98,6 +98,19 @@ static void parallel_heft_pre_exec_hook(struct starpu_task *task, unsigned sched
 	starpu_worker_unlock_self();
 }
 
+static void parallel_heft_post_exec_hook(struct starpu_task *task, unsigned sched_ctx_id STARPU_ATTRIBUTE_UNUSED)
+{
+	unsigned workerid = starpu_worker_get_id_check();
+	const double now = starpu_timing_now();
+
+	/* Once we have executed the task, we can update the predicted amount
+	 * of work. */
+	starpu_worker_lock_self();
+	worker_exp_start[workerid] = now;
+	worker_exp_end[workerid] = worker_exp_start[workerid] + worker_exp_len[workerid];
+	starpu_worker_unlock_self();
+}
+
 static int push_task_on_best_worker(struct starpu_task *task, int best_workerid, double exp_start_predicted, double exp_end_predicted, int prio, unsigned sched_ctx_id)
 {
 	/* make sure someone coule execute that task ! */
@@ -574,7 +587,6 @@ static void parallel_heft_deinit(unsigned sched_ctx_id)
 	free(hd);
 }
 
-/* TODO: use post_exec_hook to fix the expected start */
 struct starpu_sched_policy _starpu_sched_parallel_heft_policy =
 {
 	.init_sched = initialize_parallel_heft_policy,
@@ -584,7 +596,7 @@ struct starpu_sched_policy _starpu_sched_parallel_heft_policy =
 	.push_task = parallel_heft_push_task,
 	.pop_task = NULL,
 	.pre_exec_hook = parallel_heft_pre_exec_hook,
-	.post_exec_hook = NULL,
+	.post_exec_hook = parallel_heft_post_exec_hook,
 	.pop_every_task = NULL,
 	.policy_name = "pheft",
 	.policy_description = "parallel HEFT",