[Openmp-commits] [openmp] fd5853d - [Libomptarget] Reduce shared memory stack size to 512 and a message when it is exceeded

Joseph Huber via Openmp-commits openmp-commits at lists.llvm.org
Mon Jan 31 12:20:05 PST 2022


Author: Joseph Huber
Date: 2022-01-31T15:19:48-05:00
New Revision: fd5853dae6b9a49c8fea0acdc91093e5acd1ca58

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

LOG: [Libomptarget] Reduce shared memory stack size to 512 and a message when it is exceeded

Reduces the shared memory size used for globalization to 512 bytes from
2048 to reduce the pressure on shared memory. This patch ado adds a
debug mesage to indicate when the shared memory was insufficient.

Reviewed By: jdoerfert

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

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/openmp/libomptarget/DeviceRTL/CMakeLists.txt b/openmp/libomptarget/DeviceRTL/CMakeLists.txt
index 2e52bdf4d90bf..d8b9e40802b85 100644
--- a/openmp/libomptarget/DeviceRTL/CMakeLists.txt
+++ b/openmp/libomptarget/DeviceRTL/CMakeLists.txt
@@ -122,7 +122,7 @@ set(src_files
   ${source_directory}/Workshare.cpp
 )
 
-set(clang_opt_flags -O1 -mllvm -openmp-opt-disable -DSHARED_SCRATCHPAD_SIZE=2048)
+set(clang_opt_flags -O1 -mllvm -openmp-opt-disable -DSHARED_SCRATCHPAD_SIZE=512)
 set(link_opt_flags  -O1        -openmp-opt-disable)
 
 # Prepend -I to each list element

diff  --git a/openmp/libomptarget/DeviceRTL/src/State.cpp b/openmp/libomptarget/DeviceRTL/src/State.cpp
index 754c7067faac3..800176eb5eda5 100644
--- a/openmp/libomptarget/DeviceRTL/src/State.cpp
+++ b/openmp/libomptarget/DeviceRTL/src/State.cpp
@@ -136,6 +136,9 @@ void *SharedMemorySmartStackTy::push(uint64_t Bytes) {
     return Ptr;
   }
 
+  if (config::isDebugMode(config::DebugKind::CommonIssues))
+    PRINT("Shared memory stack full, fallback to dynamic allocation of global "
+          "memory will negatively impact performance.");
   void *GlobalMemory = memory::allocGlobal(
       AlignedBytes, "Slow path shared memory allocation, insufficient "
                     "shared memory stack memory!");


        


More information about the Openmp-commits mailing list