Forráskód Böngészése

fix example sched_ctx/sched_ctx_without_sched_policy and ensure callback pop is executed only by CPUs

Terry Cojean 10 éve
szülő
commit
e9fe676d22

+ 1 - 4
examples/sched_ctx/sched_ctx_without_sched_policy.c

@@ -42,6 +42,7 @@ int parallel_code(int sched_ctx)
 // 			printf("cpu = %d ctx%d nth = %d\n", sched_getcpu(), sched_ctx, omp_get_num_threads());
 #pragma omp for
 		for(i = 0; i < NTASKS; i++)
+#pragma omp critical
 			t++;
 	}
 
@@ -59,10 +60,6 @@ static void sched_ctx_func(void *descr[] STARPU_ATTRIBUTE_UNUSED, void *arg)
 static struct starpu_codelet sched_ctx_codelet =
 {
 	.cpu_funcs = {sched_ctx_func},
-#ifdef STARPU_DEVEL
-#warning FIXME: cuda_funcs should not need to be defined
-#endif
-	.cuda_funcs = {sched_ctx_func},
 	.model = NULL,
 	.nbuffers = 0,
 	.name = "sched_ctx"

+ 4 - 1
src/core/sched_policy.c

@@ -922,7 +922,10 @@ profiling:
 		}
 	}
 
-	if(task->prologue_callback_pop_func)
+	/* This function is useful only for CPUs as its unique purpose is to initialize
+	 * another runtime (e.g. OpenMP) when using parallel tasks (sched contexts without
+	 * policy). We therefore ensure GPUs don't try to execute it. */
+	if(task->prologue_callback_pop_func && worker->arch == STARPU_CPU_WORKER)
 		task->prologue_callback_pop_func(task->prologue_callback_pop_arg);
 
 	return task;