[AbstractAttributor] Fold __kmpc_parallel_level if possible
Similar to D105787, this patch tries to fold `__kmpc_parallel_level` if possible.
Note that `__kmpc_parallel_level` doesn't take activeness into consideration,
based on current `deviceRTLs`, its return value can be such as 0, 1, 2, instead
of 0, 129, 130, etc. that also indicate activeness.
Reviewed By: jdoerfert
Differential Revision: https://reviews.llvm.org/D106154
GitOrigin-RevId: e97e0a4fad091474131ad84d6f46009bf84c5b60
diff --git a/libomptarget/deviceRTLs/common/src/parallel.cu b/libomptarget/deviceRTLs/common/src/parallel.cu
index 2656f3e..b12d5cc 100644
--- a/libomptarget/deviceRTLs/common/src/parallel.cu
+++ b/libomptarget/deviceRTLs/common/src/parallel.cu
@@ -239,7 +239,7 @@
currTaskDescr->RestoreLoopData();
}
-EXTERN uint8_t __kmpc_parallel_level() {
+NOINLINE EXTERN uint8_t __kmpc_parallel_level() {
return parallelLevel[GetWarpId()] & (OMP_ACTIVE_PARALLEL_LEVEL - 1);
}
@@ -282,11 +282,11 @@
// parallel interface
////////////////////////////////////////////////////////////////////////////////
-EXTERN void __kmpc_parallel_51(kmp_Ident *ident, kmp_int32 global_tid,
- kmp_int32 if_expr, kmp_int32 num_threads,
- int proc_bind, void *fn, void *wrapper_fn,
- void **args, size_t nargs) {
-
+NOINLINE EXTERN void __kmpc_parallel_51(kmp_Ident *ident, kmp_int32 global_tid,
+ kmp_int32 if_expr,
+ kmp_int32 num_threads, int proc_bind,
+ void *fn, void *wrapper_fn, void **args,
+ size_t nargs) {
// Handle the serialized case first, same for SPMD/non-SPMD except that in
// SPMD mode we already incremented the parallel level counter, account for
// that.
diff --git a/libomptarget/deviceRTLs/interface.h b/libomptarget/deviceRTLs/interface.h
index ade1bfe..2e80dc3 100644
--- a/libomptarget/deviceRTLs/interface.h
+++ b/libomptarget/deviceRTLs/interface.h
@@ -222,7 +222,7 @@
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 uint8_t __kmpc_parallel_level();
+NOINLINE EXTERN uint8_t __kmpc_parallel_level();
// proc bind
EXTERN void __kmpc_push_proc_bind(kmp_Ident *loc, uint32_t global_tid,
@@ -441,10 +441,11 @@
/// \param wrapper_fn The worker wrapper function of fn.
/// \param args The pointer array of arguments to fn.
/// \param nargs The number of arguments to fn.
-EXTERN void __kmpc_parallel_51(ident_t *ident, kmp_int32 global_tid,
- kmp_int32 if_expr, kmp_int32 num_threads,
- int proc_bind, void *fn, void *wrapper_fn,
- void **args, size_t nargs);
+NOINLINE EXTERN void __kmpc_parallel_51(ident_t *ident, kmp_int32 global_tid,
+ kmp_int32 if_expr,
+ kmp_int32 num_threads, int proc_bind,
+ void *fn, void *wrapper_fn, void **args,
+ size_t nargs);
// SPMD execution mode interrogation function.
EXTERN int8_t __kmpc_is_spmd_exec_mode();