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

Dominik Adamski via Openmp-commits openmp-commits at lists.llvm.org
Thu Jan 11 06:24:48 PST 2024


https://github.com/DominikAdamski updated https://github.com/llvm/llvm-project/pull/77767

>From d48fb6a064f08be0697f714834bcda8f1b813ecd Mon Sep 17 00:00:00 2001
From: Dominik Adamski <dominik.adamski at amd.com>
Date: Thu, 11 Jan 2024 07:25:38 -0600
Subject: [PATCH 1/3] [OpenMP] Add missing weak definitions of missing
 variables

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,
__kmpc_for_static_loop.
---
 openmp/libomptarget/DeviceRTL/src/Configuration.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/openmp/libomptarget/DeviceRTL/src/Configuration.cpp b/openmp/libomptarget/DeviceRTL/src/Configuration.cpp
index ab1608b1cfb0ae..c9f95c0def222d 100644
--- a/openmp/libomptarget/DeviceRTL/src/Configuration.cpp
+++ b/openmp/libomptarget/DeviceRTL/src/Configuration.cpp
@@ -23,6 +23,8 @@ 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.

>From 4b75fcd74f043eca4fa5333964ddfac094b61f6d Mon Sep 17 00:00:00 2001
From: Dominik Adamski <dominik.adamski at amd.com>
Date: Thu, 11 Jan 2024 07:37:46 -0600
Subject: [PATCH 2/3] fix_formatting

---
 openmp/libomptarget/DeviceRTL/src/Configuration.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/openmp/libomptarget/DeviceRTL/src/Configuration.cpp b/openmp/libomptarget/DeviceRTL/src/Configuration.cpp
index c9f95c0def222d..63b6c1ccc0ed39 100644
--- a/openmp/libomptarget/DeviceRTL/src/Configuration.cpp
+++ b/openmp/libomptarget/DeviceRTL/src/Configuration.cpp
@@ -23,7 +23,8 @@ 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_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

>From 2e54c62d3e001d76603ed5b621817f8af073136f Mon Sep 17 00:00:00 2001
From: Dominik Adamski <dominik.adamski at amd.com>
Date: Thu, 11 Jan 2024 08:23:57 -0600
Subject: [PATCH 3/3] Applied remarks

---
 openmp/libomptarget/DeviceRTL/include/Configuration.h |  6 ++++++
 openmp/libomptarget/DeviceRTL/src/Configuration.cpp   |  8 ++++++++
 openmp/libomptarget/DeviceRTL/src/Workshare.cpp       | 11 ++++-------
 3 files changed, 18 insertions(+), 7 deletions(-)

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 63b6c1ccc0ed39..ef0c3663536f5e 100644
--- a/openmp/libomptarget/DeviceRTL/src/Configuration.cpp
+++ b/openmp/libomptarget/DeviceRTL/src/Configuration.cpp
@@ -33,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