[Openmp-commits] [openmp] 97c8f60 - [NFC][OpenMP][Offloading] Replaced explicit parallel level computation with function `__kmpc_parallel_level`
Shilei Tian via Openmp-commits
openmp-commits at lists.llvm.org
Thu Jul 15 19:21:12 PDT 2021
Author: Shilei Tian
Date: 2021-07-15T22:21:06-04:00
New Revision: 97c8f60bbaf0986320fdfd03b11328b91c730a96
URL: https://github.com/llvm/llvm-project/commit/97c8f60bbaf0986320fdfd03b11328b91c730a96
DIFF: https://github.com/llvm/llvm-project/commit/97c8f60bbaf0986320fdfd03b11328b91c730a96.diff
LOG: [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
Added:
Modified:
openmp/libomptarget/deviceRTLs/common/src/libcall.cu
openmp/libomptarget/deviceRTLs/common/src/parallel.cu
openmp/libomptarget/deviceRTLs/common/src/support.cu
openmp/libomptarget/deviceRTLs/interface.h
Removed:
################################################################################
diff --git a/openmp/libomptarget/deviceRTLs/common/src/libcall.cu b/openmp/libomptarget/deviceRTLs/common/src/libcall.cu
index 65816aeb863d8..49d6d9f835780 100644
--- a/openmp/libomptarget/deviceRTLs/common/src/libcall.cu
+++ b/openmp/libomptarget/deviceRTLs/common/src/libcall.cu
@@ -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;
}
diff --git a/openmp/libomptarget/deviceRTLs/common/src/parallel.cu b/openmp/libomptarget/deviceRTLs/common/src/parallel.cu
index 2fd7b0585ad6c..5e318a237af4b 100644
--- a/openmp/libomptarget/deviceRTLs/common/src/parallel.cu
+++ b/openmp/libomptarget/deviceRTLs/common/src/parallel.cu
@@ -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);
diff --git a/openmp/libomptarget/deviceRTLs/common/src/support.cu b/openmp/libomptarget/deviceRTLs/common/src/support.cu
index f9014dfc42849..d78f94c0b1b5e 100644
--- a/openmp/libomptarget/deviceRTLs/common/src/support.cu
+++ b/openmp/libomptarget/deviceRTLs/common/src/support.cu
@@ -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;
diff --git a/openmp/libomptarget/deviceRTLs/interface.h b/openmp/libomptarget/deviceRTLs/interface.h
index 5130757799726..17e3bdf18be15 100644
--- a/openmp/libomptarget/deviceRTLs/interface.h
+++ b/openmp/libomptarget/deviceRTLs/interface.h
@@ -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,
More information about the Openmp-commits
mailing list