Prechádzať zdrojové kódy

Watch for multiple assignation of a tag to tasks

Samuel Thibault 12 rokov pred
rodič
commit
436c4109f3
2 zmenil súbory, kde vykonal 10 pridanie a 3 odobranie
  1. 9 3
      src/core/dependencies/tags.c
  2. 1 0
      src/core/jobs.c

+ 9 - 3
src/core/dependencies/tags.c

@@ -268,13 +268,19 @@ void _starpu_tag_declare(starpu_tag_t id, struct _starpu_job *job)
 	job->task->use_tag = 1;
 
 	struct _starpu_tag *tag= gettag_struct(id);
+
+	_starpu_spin_lock(&tag->lock);
+
+	/* Note: a tag can be shared by several tasks, when it is used to
+	 * detect when either of them are finished. We however don't allow
+	 * several tasks to share a tag when it is used to wake them by
+	 * dependency */
 	tag->job = job;
-	tag->is_assigned = 1;
+	tag->is_assigned++;
 
 	job->tag = tag;
-
 	/* the tag is now associated to a job */
-	_starpu_spin_lock(&tag->lock);
+
 	/* 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

+ 1 - 0
src/core/jobs.c

@@ -282,6 +282,7 @@ static unsigned _starpu_not_all_tag_deps_are_fulfilled(struct _starpu_job *j)
 	struct _starpu_cg_list *tag_successors = &tag->tag_successors;
 
 	_starpu_spin_lock(&tag->lock);
+	STARPU_ASSERT_MSG(tag->is_assigned == 1 || !tag_successors->ndeps, "a tag can be assigned only one task to wake");
 
 	if (tag_successors->ndeps != tag_successors->ndeps_completed)
 	{