[Openmp-commits] [openmp] 4c88341 - [OpenMP][FIX] Do check the level before return team size

Johannes Doerfert via Openmp-commits openmp-commits at lists.llvm.org
Wed Oct 27 16:18:53 PDT 2021


Author: Johannes Doerfert
Date: 2021-10-27T18:18:42-05:00
New Revision: 4c88341d17f8b81e4d21a63e0e4c16dca9063670

URL: https://github.com/llvm/llvm-project/commit/4c88341d17f8b81e4d21a63e0e4c16dca9063670
DIFF: https://github.com/llvm/llvm-project/commit/4c88341d17f8b81e4d21a63e0e4c16dca9063670.diff

LOG: [OpenMP][FIX] Do check the level before return team size

The team size could/should be an ICV but since we know it is either 1 or
a value we can leave it in the team state for now. However, we still
need to determine if the current level is nested before we use it.

Reviewed By: jhuber6

Differential Revision: https://reviews.llvm.org/D111949

Added: 
    

Modified: 
    openmp/libomptarget/DeviceRTL/src/State.cpp

Removed: 
    


################################################################################
diff  --git a/openmp/libomptarget/DeviceRTL/src/State.cpp b/openmp/libomptarget/DeviceRTL/src/State.cpp
index 538dc95ddcee..ae6a93e7927b 100644
--- a/openmp/libomptarget/DeviceRTL/src/State.cpp
+++ b/openmp/libomptarget/DeviceRTL/src/State.cpp
@@ -445,7 +445,9 @@ int omp_get_team_size(int Level) {
   return returnValIfLevelIsActive(Level, state::ParallelTeamSize, 1);
 }
 
-int omp_get_num_threads(void) { return state::ParallelTeamSize; }
+int omp_get_num_threads(void) {
+  return omp_get_level() > 1 ? 1 : state::ParallelTeamSize;
+}
 
 int omp_get_thread_limit(void) { return mapping::getKernelSize(); }
 


        


More information about the Openmp-commits mailing list