Browse Source

Fix restarted tags by separating the "same tag used by several instances of the same task" and the "same tag signaled by several tasks" thanks to setting submitted to 2 in the former case.

Samuel Thibault 13 years ago
parent
commit
06aab4fa3e
4 changed files with 17 additions and 4 deletions
  1. 6 1
      src/core/dependencies/tags.c
  2. 4 1
      src/core/jobs.c
  3. 3 1
      src/core/jobs.h
  4. 4 1
      src/core/task.c

+ 6 - 1
src/core/dependencies/tags.c

@@ -233,7 +233,12 @@ void _starpu_tag_declare(starpu_tag_t id, struct _starpu_job *job)
 
 	/* the tag is now associated to a job */
 	_starpu_spin_lock(&tag->lock);
-	if (tag->state != STARPU_DONE)
+	/* When the same tag may be signaled several times by different tasks,
+	 * and it's already done, we should not reset the "done" state.
+	 * When the tag is simply used by the same task several times, we have
+	 * to do so. */
+	if (job->task->regenerate || job->submitted == 2 ||
+			tag->state != STARPU_DONE)
 		tag->state = STARPU_ASSOCIATED;
 	_starpu_spin_unlock(&tag->lock);
 }

+ 4 - 1
src/core/jobs.c

@@ -277,7 +277,10 @@ static unsigned _starpu_not_all_tag_deps_are_fulfilled(struct _starpu_job *j)
 	else
 	{
 		/* existing deps (if any) are fulfilled */
-		if (tag->state != STARPU_DONE)
+		/* If the same tag is being signaled by several tasks, do not
+		 * clear a DONE state. If it's the same job submitted several
+		 * times with the same tag, we have to do it */
+		if (j->submitted == 2 || tag->state != STARPU_DONE)
 			tag->state = STARPU_READY;
 		/* already prepare for next run */
 		tag_successors->ndeps_completed = 0;

+ 3 - 1
src/core/jobs.h

@@ -91,7 +91,9 @@ LIST_TYPE(_starpu_job,
 	uint32_t footprint;
 
 	/* Indicates whether the task associated to that job has already been
-	 * submitted to StarPU or not (using starpu_task_submit). */
+	 * submitted to StarPU (1) or not (0) (using starpu_task_submit).
+	 * Becomes and stays 2 when the task is submitted several times.
+	 */
 	unsigned submitted;
 
 	/* Indicates whether the task associated to this job is terminated or

+ 4 - 1
src/core/task.c

@@ -215,7 +215,10 @@ int _starpu_submit_job(struct _starpu_job *j)
 	/* Need to atomically set submitted to 1 and check dependencies, since
 	 * this is concucrent with _starpu_notify_cg */
 	j->terminated = 0;
-	j->submitted = 1;
+	if (!j->submitted)
+		j->submitted = 1;
+	else
+		j->submitted = 2;
 
 	int ret = _starpu_enforce_deps_and_schedule(j);