Quellcode durchsuchen

We must support nested callbacks in case we have empty tasks.

Cédric Augonnet vor 15 Jahren
Ursprung
Commit
02f3ad935d
2 geänderte Dateien mit 6 neuen und 4 gelöschten Zeilen
  1. 6 1
      src/core/jobs.c
  2. 0 3
      src/core/task.c

+ 6 - 1
src/core/jobs.c

@@ -120,13 +120,18 @@ void _starpu_handle_job_termination(starpu_job_t j, unsigned job_is_already_lock
 		 * within the callback */
 		_starpu_set_local_worker_status(STATUS_CALLBACK);
 		
+		/* Perhaps we have nested callbacks (eg. with chains of empty
+		 * tasks). So we store the current task and we will restore it
+		 * later. */
+		struct starpu_task *current_task = starpu_get_current_task();
+
 		_starpu_set_current_task(task);
 
 		STARPU_TRACE_START_CALLBACK(j);
 		task->callback_func(task->callback_arg);
 		STARPU_TRACE_END_CALLBACK(j);
 		
-		_starpu_set_current_task(NULL);
+		_starpu_set_current_task(current_task);
 
 		_starpu_set_local_worker_status(STATUS_UNKNOWN);
 	}

+ 0 - 3
src/core/task.c

@@ -288,8 +288,5 @@ struct starpu_task *starpu_get_current_task(void)
 
 void _starpu_set_current_task(struct starpu_task *task)
 {
-	if (task)
-		STARPU_ASSERT(pthread_getspecific(current_task_key) == NULL);
-
 	pthread_setspecific(current_task_key, task);
 }