Переглянути джерело

Start to reorganize the handling of tasks dependencies during task submission.

Cédric Augonnet 16 роки тому
батько
коміт
5cecf770ab
2 змінених файлів з 38 додано та 27 видалено
  1. 0 7
      src/core/dependencies/tags.c
  2. 38 20
      src/core/jobs.c

+ 0 - 7
src/core/dependencies/tags.c

@@ -369,10 +369,3 @@ void starpu_tag_wait(starpu_tag_t id)
 	starpu_tag_wait_array(1, &id);
 }
 
-/* This function is called when a new task is submitted to StarPU 
- * it returns 1 if the task deps are not fulfilled, 0 otherwise */
-unsigned submit_job_enforce_task_deps(job_t j)
-{
-	struct tag_s *tag = j->tag;
-	return (tag->state == BLOCKED);
-}

+ 38 - 20
src/core/jobs.c

@@ -148,30 +148,34 @@ static void block_sync_task(job_t j)
 	job_delete(j);
 }
 
-/* application should submit new tasks to StarPU through this function */
-int starpu_submit_task(struct starpu_task *task)
-{
-	int ret;
-	unsigned is_sync = task->synchronous;
 
-	STARPU_ASSERT(task);
-
-	if (!worker_exists(task->cl->where))
-		return -ENODEV;
+/* This function is called when a new task is submitted to StarPU 
+ * it returns 1 if the task deps are not fulfilled, 0 otherwise */
+static unsigned enforce_task_deps(job_t j)
+{
+	if (j->task->use_tag)
+	{
+		unsigned deps_are_not_fulfilled;
+		struct tag_s *tag = j->tag;
+		deps_are_not_fulfilled = (tag->state == BLOCKED);
 
-	/* internally, StarPU manipulates a job_t which is a wrapper around a
- 	* task structure */
-	job_t j = job_create(task);
+		return deps_are_not_fulfilled;
+	}
+	else
+	{
+		/* this task does not use tags, so we can go on */
+		return 0;
+	}
+}
 
+static enforce_deps_and_schedule(job_t j)
+{
 	/* enfore task dependencies */
 	if (task->use_tag)
 	{
-		if (submit_job_enforce_task_deps(j))
+		if (enforce_task_deps(j))
 		{
 			j->tag->is_submitted = 1;
-
-			if (is_sync)
-				block_sync_task(j);
 			return 0;
 		}
 		
@@ -182,14 +186,28 @@ int starpu_submit_task(struct starpu_task *task)
 #ifdef NO_DATA_RW_LOCK
 	/* enforce data dependencies */
 	if (submit_job_enforce_data_deps(j))
-	{
-		if (is_sync)
-			block_sync_task(j);
 		return 0;
-	}
 #endif
 
 	ret = push_task(j);
+}
+
+/* application should submit new tasks to StarPU through this function */
+int starpu_submit_task(struct starpu_task *task)
+{
+	int ret;
+	unsigned is_sync = task->synchronous;
+
+	STARPU_ASSERT(task);
+
+	if (!worker_exists(task->cl->where))
+		return -ENODEV;
+
+	/* internally, StarPU manipulates a job_t which is a wrapper around a
+ 	* task structure */
+	job_t j = job_create(task);
+
+	enforce_deps_and_schedule(j);
 
 	if (is_sync)
 		block_sync_task(j);