[Openmp-commits] [openmp] 19248d3 - [OpenMP][deviceRTLs] Added `[[clang::loader_uninitialized]]` explicitly

Shilei Tian via Openmp-commits openmp-commits at lists.llvm.org
Thu Jan 28 05:17:03 PST 2021


Author: Shilei Tian
Date: 2021-01-28T08:12:49-05:00
New Revision: 19248d30e4ed5250fa84abbbd52fc7b835918a45

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

LOG: [OpenMP][deviceRTLs] Added `[[clang::loader_uninitialized]]` explicitly

`[[clang::loader_uninitialized]]` is in macro `SHARED` but it doesn't
work for array like `parallelLevel`, so the variable will be zero initialized.
There is also a similar issue for `omptarget_nvptx_device_State` which is in
global address space. Its c'tor is also generated, which was not in the past when
building the `deviceRTLs` with CUDA. In this patch, we added the attribute to
the two variables explicitly.

Reviewed By: jdoerfert

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

Added: 
    

Modified: 
    openmp/libomptarget/deviceRTLs/common/src/omp_data.cu

Removed: 
    


################################################################################
diff  --git a/openmp/libomptarget/deviceRTLs/common/src/omp_data.cu b/openmp/libomptarget/deviceRTLs/common/src/omp_data.cu
index b91afd7476fe..4736d07108e0 100644
--- a/openmp/libomptarget/deviceRTLs/common/src/omp_data.cu
+++ b/openmp/libomptarget/deviceRTLs/common/src/omp_data.cu
@@ -25,7 +25,8 @@ DEVICE omptarget_device_environmentTy omptarget_device_environment;
 // global data holding OpenMP state information
 ////////////////////////////////////////////////////////////////////////////////
 
-DEVICE
+// OpenMP will try to call its ctor if we don't add the attribute explicitly
+[[clang::loader_uninitialized]] DEVICE
     omptarget_nvptx_Queue<omptarget_nvptx_ThreadPrivateContext, OMP_STATE_COUNT>
         omptarget_nvptx_device_State[MAX_SM];
 
@@ -33,7 +34,9 @@ DEVICE omptarget_nvptx_SimpleMemoryManager omptarget_nvptx_simpleMemoryManager;
 DEVICE uint32_t SHARED(usedMemIdx);
 DEVICE uint32_t SHARED(usedSlotIdx);
 
-DEVICE uint8_t parallelLevel[MAX_THREADS_PER_TEAM / WARPSIZE];
+// SHARED doesn't work with array so we add the attribute explicitly.
+[[clang::loader_uninitialized]] DEVICE uint8_t
+    parallelLevel[MAX_THREADS_PER_TEAM / WARPSIZE];
 #pragma omp allocate(parallelLevel) allocator(omp_pteam_mem_alloc)
 DEVICE uint16_t SHARED(threadLimit);
 DEVICE uint16_t SHARED(threadsInTeam);


        


More information about the Openmp-commits mailing list