瀏覽代碼

We must have set the j->terminated flag early, so that it is possible to
express task dependencies within the callback function.

Cédric Augonnet 15 年之前
父節點
當前提交
5898e6d9aa
共有 1 個文件被更改,包括 7 次插入4 次删除
  1. 7 4
      src/core/jobs.c

+ 7 - 4
src/core/jobs.c

@@ -93,13 +93,17 @@ void _starpu_handle_job_termination(starpu_job_t j)
 {
 	struct starpu_task *task = j->task;
 
-	if (STARPU_UNLIKELY(j->terminated))
-		fprintf(stderr, "OOPS ... job %p was already terminated !!\n", j);
-
 	/* in case there are dependencies, wake up the proper tasks */
 	j->submitted = 0;
 	_starpu_notify_dependencies(j);
 
+	/* We must have set the j->terminated flag early, so that it is
+	 * possible to express task dependencies within the callback
+	 * function. */
+	pthread_mutex_lock(&j->sync_mutex);
+	j->terminated = 1;
+	pthread_mutex_unlock(&j->sync_mutex);
+
 	/* the callback is executed after the dependencies so that we may remove the tag 
  	 * of the task itself */
 	if (task->callback_func)
@@ -131,7 +135,6 @@ void _starpu_handle_job_termination(starpu_job_t j)
 		/* we do not desallocate the job structure if some is going to
 		 * wait after the task */
 		pthread_mutex_lock(&j->sync_mutex);
-		j->terminated = 1;
 		pthread_cond_broadcast(&j->sync_cond);
 		pthread_mutex_unlock(&j->sync_mutex);
 	}