Browse Source

Fix concurrency between a task releasing its successor, and a successor enqueuing itself on the list: the parent task should tell successors to just proceed only after it has emptied its list

Samuel Thibault 13 years ago
parent
commit
c0024de1d4
1 changed files with 4 additions and 1 deletions
  1. 4 1
      src/core/dependencies/cg.c

+ 4 - 1
src/core/dependencies/cg.c

@@ -152,6 +152,8 @@ void _starpu_notify_cg(struct _starpu_cg *cg)
 				unsigned ndeps_completed =
 					STARPU_ATOMIC_ADD(&job_successors->ndeps_completed, 1);
 
+				STARPU_ASSERT(job_successors->ndeps >= ndeps_completed);
+
 				/* Need to atomically test submitted and check
 				 * dependencies, since this is concurrent with
 				 * _starpu_submit_job */
@@ -183,7 +185,7 @@ void _starpu_notify_cg_list(struct _starpu_cg_list *successors)
 	unsigned succ;
 
 	_starpu_spin_lock(&successors->lock);
-	successors->terminated = 1;
+	STARPU_ASSERT(!successors->terminated);
 	/* Note: some thread might be concurrently adding other items */
 	for (succ = 0; succ < successors->nsuccs; succ++)
 	{
@@ -216,5 +218,6 @@ void _starpu_notify_cg_list(struct _starpu_cg_list *successors)
 
 		_starpu_spin_lock(&successors->lock);
 	}
+	successors->terminated = 1;
 	_starpu_spin_unlock(&successors->lock);
 }