[NFC][OpenMP][Offloading] Replaced explicit parallel level computation with function `__kmpc_parallel_level`
There are two places in current deviceRTLs where it computes parallel level explicitly, which is basically the functionality of `__kmpc_parallel_level`. Starting from D105787, we plan to introduce a series of function call folding based on information that can be deducted during compilation time. Computation of parallel level is the next target. This patch makes steps for the optimization. Reviewed By: jdoerfert Differential Revision: https://reviews.llvm.org/D105955
This commit is contained in:
parent
851a335b1e
commit
97c8f60bba
|
@ -129,7 +129,7 @@ EXTERN int omp_get_max_active_levels(void) {
|
|||
}
|
||||
|
||||
EXTERN int omp_get_level(void) {
|
||||
int level = parallelLevel[GetWarpId()] & (OMP_ACTIVE_PARALLEL_LEVEL - 1);
|
||||
int level = __kmpc_parallel_level();
|
||||
PRINT(LD_IO, "call omp_get_level() returns %d\n", level);
|
||||
return level;
|
||||
}
|
||||
|
|
|
@ -238,9 +238,7 @@ EXTERN void __kmpc_end_serialized_parallel(kmp_Ident *loc,
|
|||
currTaskDescr->RestoreLoopData();
|
||||
}
|
||||
|
||||
EXTERN uint16_t __kmpc_parallel_level(kmp_Ident *loc, uint32_t global_tid) {
|
||||
PRINT0(LD_IO, "call to __kmpc_parallel_level\n");
|
||||
|
||||
EXTERN uint16_t __kmpc_parallel_level() {
|
||||
return parallelLevel[GetWarpId()] & (OMP_ACTIVE_PARALLEL_LEVEL - 1);
|
||||
}
|
||||
|
||||
|
@ -292,7 +290,7 @@ EXTERN void __kmpc_parallel_51(kmp_Ident *ident, kmp_int32 global_tid,
|
|||
// SPMD mode we already incremented the parallel level counter, account for
|
||||
// that.
|
||||
bool InParallelRegion =
|
||||
(__kmpc_parallel_level(ident, global_tid) > __kmpc_is_spmd_exec_mode());
|
||||
(__kmpc_parallel_level() > __kmpc_is_spmd_exec_mode());
|
||||
if (!if_expr || InParallelRegion) {
|
||||
__kmpc_serialized_parallel(ident, global_tid);
|
||||
__kmp_invoke_microtask(global_tid, 0, fn, args, nargs);
|
||||
|
|
|
@ -89,7 +89,7 @@ int GetOmpThreadId() {
|
|||
return 0;
|
||||
// omp_thread_num
|
||||
int rc;
|
||||
if ((parallelLevel[GetWarpId()] & (OMP_ACTIVE_PARALLEL_LEVEL - 1)) > 1) {
|
||||
if (__kmpc_parallel_level() > 1) {
|
||||
rc = 0;
|
||||
} else if (__kmpc_is_spmd_exec_mode()) {
|
||||
rc = tid;
|
||||
|
|
|
@ -222,7 +222,7 @@ EXTERN void __kmpc_push_num_threads(kmp_Ident *loc, int32_t global_tid,
|
|||
int32_t num_threads);
|
||||
EXTERN void __kmpc_serialized_parallel(kmp_Ident *loc, uint32_t global_tid);
|
||||
EXTERN void __kmpc_end_serialized_parallel(kmp_Ident *loc, uint32_t global_tid);
|
||||
EXTERN uint16_t __kmpc_parallel_level(kmp_Ident *loc, uint32_t global_tid);
|
||||
EXTERN uint16_t __kmpc_parallel_level();
|
||||
|
||||
// proc bind
|
||||
EXTERN void __kmpc_push_proc_bind(kmp_Ident *loc, uint32_t global_tid,
|
||||
|
|
Loading…
Reference in New Issue