Преглед изворни кода

starpu_task_submit: on initialisation, the scheduling context of the
task is no longer set, on submission, it is set to the initial context
for internal tasks, and to the current context for the other tasks

Nathalie Furmento пре 12 година
родитељ
комит
48073d0642
1 измењених фајлова са 9 додато и 7 уклоњено
  1. 9 7
      src/core/task.c

+ 9 - 7
src/core/task.c

@@ -74,7 +74,7 @@ void starpu_task_init(struct starpu_task *task)
 	task->predicted_transfer = NAN;
 
 	task->magic = 42;
-	task->sched_ctx = _starpu_get_initial_sched_ctx()->id;
+	task->sched_ctx = STARPU_NMAX_SCHED_CTXS;
 
 	task->flops = 0.0;
 
@@ -411,19 +411,21 @@ int starpu_task_submit(struct starpu_task *task)
 	int ret;
 	unsigned is_sync = task->synchronous;
 	starpu_task_bundle_t bundle = task->bundle;
-	unsigned nsched_ctxs = _starpu_get_nsched_ctxs();
-	unsigned set_sched_ctx = STARPU_NMAX_SCHED_CTXS;
 
 	/* internally, StarPU manipulates a struct _starpu_job * which is a wrapper around a
 	* task structure, it is possible that this job structure was already
 	* allocated. */
 	struct _starpu_job *j = _starpu_get_job_associated_to_task(task);
 
-	if (task->sched_ctx == _starpu_get_initial_sched_ctx()->id  && nsched_ctxs != 1 && !j->internal)
+	if (j->internal)
+	{
+		// Internal tasks are submitted to initial context
+		task->sched_ctx = _starpu_get_initial_sched_ctx()->id;
+	}
+	else if (task->sched_ctx == STARPU_NMAX_SCHED_CTXS)
 	{
-		set_sched_ctx = starpu_sched_ctx_get_context();
-		if (set_sched_ctx != STARPU_NMAX_SCHED_CTXS)
-			task->sched_ctx = set_sched_ctx;
+		// If the task has not specified a context, we set the current context
+		task->sched_ctx = _starpu_sched_ctx_get_current_context();
 	}
 
 	if (is_sync)