[Openmp-commits] [openmp] 18798cf - [OpenMP] Add missing weak definitions of missing variables (#77767)

via Openmp-commits openmp-commits at lists.llvm.org
Thu Jan 11 06:28:50 PST 2024


Author: Dominik Adamski
Date: 2024-01-11T15:28:45+01:00
New Revision: 18798cf972cd0669d3b4b84da18d467542588802

URL: https://github.com/llvm/llvm-project/commit/18798cf972cd0669d3b4b84da18d467542588802
DIFF: https://github.com/llvm/llvm-project/commit/18798cf972cd0669d3b4b84da18d467542588802.diff

LOG: [OpenMP] Add missing weak definitions of missing variables (#77767)

Variables `__omp_rtl_assume_teams_oversubscription` and
`__omp_rtl_assume_threads_oversubscription `are used by functions:
`__kmpc_distribute_static_loop`, `__kmpc_distribute_for_static_loop `and
`__kmpc_for_static_loop`.

Added: 
    

Modified: 
    openmp/libomptarget/DeviceRTL/include/Configuration.h
    openmp/libomptarget/DeviceRTL/src/Configuration.cpp
    openmp/libomptarget/DeviceRTL/src/Workshare.cpp

Removed: 
    


################################################################################
diff  --git a/openmp/libomptarget/DeviceRTL/include/Configuration.h b/openmp/libomptarget/DeviceRTL/include/Configuration.h
index c9f8f2500e031d..8e6f5c89cbf24a 100644
--- a/openmp/libomptarget/DeviceRTL/include/Configuration.h
+++ b/openmp/libomptarget/DeviceRTL/include/Configuration.h
@@ -30,6 +30,12 @@ uint32_t getDeviceNum();
 /// Return the user choosen debug level.
 uint32_t getDebugKind();
 
+/// Return if teams oversubscription is assumed
+uint32_t getAssumeTeamsOversubscription();
+
+/// Return if threads oversubscription is assumed
+uint32_t getAssumeThreadsOversubscription();
+
 /// Return the amount of dynamic shared memory that was allocated at launch.
 uint64_t getDynamicMemorySize();
 

diff  --git a/openmp/libomptarget/DeviceRTL/src/Configuration.cpp b/openmp/libomptarget/DeviceRTL/src/Configuration.cpp
index ab1608b1cfb0ae..ef0c3663536f5e 100644
--- a/openmp/libomptarget/DeviceRTL/src/Configuration.cpp
+++ b/openmp/libomptarget/DeviceRTL/src/Configuration.cpp
@@ -23,6 +23,9 @@ using namespace ompx;
 [[gnu::weak]] extern const uint32_t __omp_rtl_debug_kind = 0;
 [[gnu::weak]] extern const uint32_t __omp_rtl_assume_no_thread_state = 0;
 [[gnu::weak]] extern const uint32_t __omp_rtl_assume_no_nested_parallelism = 0;
+[[gnu::weak]] extern const uint32_t __omp_rtl_assume_threads_oversubscription =
+    0;
+[[gnu::weak]] extern const uint32_t __omp_rtl_assume_teams_oversubscription = 0;
 
 // This variable should be visibile to the plugin so we override the default
 // hidden visibility.
@@ -30,6 +33,14 @@ using namespace ompx;
   gnu::visibility("protected")]] DeviceEnvironmentTy
     CONSTANT(__omp_rtl_device_environment);
 
+uint32_t config::getAssumeTeamsOversubscription() {
+  return __omp_rtl_assume_teams_oversubscription;
+}
+
+uint32_t config::getAssumeThreadsOversubscription() {
+  return __omp_rtl_assume_threads_oversubscription;
+}
+
 uint32_t config::getDebugKind() {
   return __omp_rtl_debug_kind & __omp_rtl_device_environment.DeviceDebugKind;
 }

diff  --git a/openmp/libomptarget/DeviceRTL/src/Workshare.cpp b/openmp/libomptarget/DeviceRTL/src/Workshare.cpp
index b587b85cc00788..bcb7c5ad50a185 100644
--- a/openmp/libomptarget/DeviceRTL/src/Workshare.cpp
+++ b/openmp/libomptarget/DeviceRTL/src/Workshare.cpp
@@ -45,9 +45,6 @@ struct DynamicScheduleTracker {
 
 #pragma omp begin declare target device_type(nohost)
 
-extern int32_t __omp_rtl_assume_teams_oversubscription;
-extern int32_t __omp_rtl_assume_threads_oversubscription;
-
 // TODO: This variable is a hack inherited from the old runtime.
 static uint64_t SHARED(Cnt);
 
@@ -746,7 +743,7 @@ template <typename Ty> class StaticLoopChunker {
     // If we know we have more threads than iterations we can indicate that to
     // avoid an outer loop.
     bool OneIterationPerThread = false;
-    if (__omp_rtl_assume_threads_oversubscription) {
+    if (config::getAssumeThreadsOversubscription()) {
       ASSERT(NumThreads >= NumIters, "Broken assumption");
       OneIterationPerThread = true;
     }
@@ -788,7 +785,7 @@ template <typename Ty> class StaticLoopChunker {
     // If we know we have more blocks than iterations we can indicate that to
     // avoid an outer loop.
     bool OneIterationPerThread = false;
-    if (__omp_rtl_assume_teams_oversubscription) {
+    if (config::getAssumeTeamsOversubscription()) {
       ASSERT(NumBlocks >= NumIters, "Broken assumption");
       OneIterationPerThread = true;
     }
@@ -839,8 +836,8 @@ template <typename Ty> class StaticLoopChunker {
     // If we know we have more threads (across all blocks) than iterations we
     // can indicate that to avoid an outer loop.
     bool OneIterationPerThread = false;
-    if (__omp_rtl_assume_teams_oversubscription &
-        __omp_rtl_assume_threads_oversubscription) {
+    if (config::getAssumeTeamsOversubscription() &
+        config::getAssumeThreadsOversubscription()) {
       OneIterationPerThread = true;
       ASSERT(NumBlocks * NumThreads >= NumIters, "Broken assumption");
     }


        


More information about the Openmp-commits mailing list