Skip to content

Commit 137f333

Browse files
DominikAdamskironlieb
authored andcommitted
Unify init/deinit interface for Flang OpenMP
Flang will use only __kmpc_target_init_v1 and __kmpc_target_deinit_v1 functions to init/deinit OpenMP runtime. Signed-off-by: Dominik Adamski <[email protected]> Change-Id: I3169008303713fe300607a0fbf12c7705fe226a4
1 parent 65b6ba6 commit 137f333

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

openmp/libomptarget/deviceRTLs/common/src/omptarget.cu

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,27 @@ EXTERN
459459
int32_t __kmpc_target_init_v1(ident_t *Ident, int8_t Mode,
460460
int8_t UseGenericStateMachine,
461461
int8_t RequiresFullRuntime) {
462+
463+
if (Mode & OMP_TGT_EXEC_MODE_SPMD) {
464+
setExecutionParameters(OMP_TGT_EXEC_MODE_SPMD,
465+
466+
OMP_TGT_RUNTIME_UNINITIALIZED);
467+
int threadId = __kmpc_get_hardware_thread_id_in_block();
468+
if (threadId == 0) {
469+
parallelLevel[0] = 1 + (__kmpc_get_hardware_num_threads_in_block() > 1
470+
? OMP_ACTIVE_PARALLEL_LEVEL
471+
: 0);
472+
} else if (GetLaneId() == 0) {
473+
parallelLevel[GetWarpId()] =
474+
1 + (__kmpc_get_hardware_num_threads_in_block() > 1
475+
? OMP_ACTIVE_PARALLEL_LEVEL
476+
: 0);
477+
}
478+
// Runtime is not required - exit.
479+
__kmpc_impl_syncthreads();
480+
return -1;
481+
}
482+
462483
return __kmpc_target_init(Ident, Mode, UseGenericStateMachine,
463484
RequiresFullRuntime);
464485
}

0 commit comments

Comments
 (0)