Browse Source

openmp: fix a crash with _starpu_omp_get_task() for non-CPU workers

For the KStar heterogeneous study, we added a new 'where' clause on task
constructs. This clause can be used to tell the runtime where to execute
the tasks, the flag accepts the following values cpu, gpu and all.

To know if the current thread comes from a CPU or a GPU worker, we
hacked up omp_is_initial_device() which should return 0 for GPU workers,
and 1 for CPU workers.

That workaround is only for experimental uses and it's not going to be
part of the official specification.
Samuel Pitoiset 8 years ago
parent
commit
ed203ce01a
1 changed files with 4 additions and 1 deletions
  1. 4 1
      src/util/openmp_runtime_support_omp_api.c

+ 4 - 1
src/util/openmp_runtime_support_omp_api.c

@@ -267,7 +267,10 @@ int starpu_omp_get_team_num(void)
 
 int starpu_omp_is_initial_device(void)
 {
-	const struct starpu_omp_device * const device = _starpu_omp_get_task()->owner_region->owner_device;
+	struct starpu_omp_task *task = _starpu_omp_get_task();
+	if (!task)
+		return 0;
+	const struct starpu_omp_device * const device = task->owner_region->owner_device;
 	return device == _starpu_omp_global_state->initial_device;
 }