Explorar o código

- add a conditional variant of continuation tasks associated with a spinlock

Olivier Aumage %!s(int64=11) %!d(string=hai) anos
pai
achega
e5f5aba186
Modificáronse 4 ficheiros con 34 adicións e 3 borrados
  1. 23 3
      src/core/jobs.c
  2. 4 0
      src/core/jobs.h
  3. 5 0
      src/core/task.c
  4. 2 0
      src/core/task.h

+ 23 - 3
src/core/jobs.c

@@ -155,6 +155,15 @@ void _starpu_job_prepare_for_continuation(struct _starpu_job *j)
 	STARPU_ASSERT(j->task_size == 1);
 	j->continuation = 1;
 }
+
+void _starpu_job_prepare_for_conditional_continuation(struct _starpu_job *j, struct _starpu_spinlock *lock_ptr)
+{
+	STARPU_ASSERT(!j->continuation);
+	/* continuation are not supported for parallel tasks for now */
+	STARPU_ASSERT(j->task_size == 1);
+	j->continuation_lock_ptr = lock_ptr;
+	j->continuation = 1;
+}
 #endif
 
 void _starpu_handle_job_termination(struct _starpu_job *j)
@@ -365,9 +374,20 @@ void _starpu_handle_job_termination(struct _starpu_job *j)
 		}
 #endif
 
-		/* We reuse the same job structure */
-		int ret = _starpu_submit_job(j);
-		STARPU_ASSERT(!ret);
+#ifdef STARPU_OPENMP
+		if (continuation && j->continuation_lock_ptr != NULL)
+		{
+			struct _starpu_spinlock *lock_ptr = j->continuation_lock_ptr;
+			j->continuation_lock_ptr = NULL;
+			_starpu_spin_unlock(lock_ptr);
+		}
+		else
+#endif
+		{
+			/* We reuse the same job structure */
+			int ret = _starpu_submit_job(j);
+			STARPU_ASSERT(!ret);
+		}
 	}
 
 	_starpu_decrement_nsubmitted_tasks_of_sched_ctx(sched_ctx);

+ 4 - 0
src/core/jobs.h

@@ -112,6 +112,8 @@ LIST_TYPE(_starpu_job,
 	/* Job is a continuation or a regular task. */
 	unsigned continuation;
 
+	struct _starpu_spinlock *continuation_lock_ptr;
+
 	/* Job has been stopped at least once. */
 	unsigned discontinuous;
 #endif
@@ -169,6 +171,8 @@ int _starpu_test_job_termination(struct _starpu_job *j);
 
 /* Prepare the job for accepting new dependencies before becoming a continuation. */
 void _starpu_job_prepare_for_continuation(struct _starpu_job *j);
+
+void _starpu_job_prepare_for_conditional_continuation(struct _starpu_job *j, struct _starpu_spinlock *lock_ptr);
 #endif
 
 /* Specify that the task should not appear in the DAG generated by debug tools. */

+ 5 - 0
src/core/task.c

@@ -956,6 +956,11 @@ void _starpu_task_prepare_for_continuation(void)
 {
 	_starpu_job_prepare_for_continuation(_starpu_get_job_associated_to_task(starpu_task_get_current()));
 }
+
+void _starpu_task_prepare_for_conditional_continuation(struct _starpu_spinlock *lock_ptr)
+{
+	_starpu_job_prepare_for_conditional_continuation(_starpu_get_job_associated_to_task(starpu_task_get_current()), lock_ptr);
+}
 #endif
 
 /*

+ 2 - 0
src/core/task.h

@@ -62,6 +62,8 @@ _starpu_handle_needs_conversion_task_for_arch(starpu_data_handle_t handle,
 #ifdef STARPU_OPENMP
 /* Prepare the current task for accepting new dependencies before becoming a continuation. */
 void _starpu_task_prepare_for_continuation(void);
+
+void _starpu_task_prepare_for_conditional_continuation(struct _starpu_spinlock *lock_ptr);
 #endif
 
 int _starpu_task_uses_multiformat_handles(struct starpu_task *task);