[Openmp-commits] [PATCH] D113963: [OpenMP] Fix initializer not working on AMDGPU

Joseph Huber via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Mon Nov 15 20:06:23 PST 2021

jhuber6 created this revision.
jhuber6 added a reviewer: jdoerfert.
Herald added subscribers: guansong, t-tye, tpr, dstuttard, yaxunl, kzhuravl.
jhuber6 requested review of this revision.
Herald added subscribers: openmp-commits, sstefan1, wdng.
Herald added a project: OpenMP.

The RAII class used for debugging RTL entry used a shared variable to
keep track of the current depth. This used a global initializer, which
isn't supported on AMDGPU. This patch removes the initializer and
instead sets it to zero when the state is initialized in the runtime.

  rG LLVM Github Monorepo



Index: openmp/libomptarget/DeviceRTL/src/State.cpp
--- openmp/libomptarget/DeviceRTL/src/State.cpp
+++ openmp/libomptarget/DeviceRTL/src/State.cpp
@@ -113,6 +113,7 @@
 static SharedMemorySmartStackTy SHARED(SharedMemorySmartStack);
 void SharedMemorySmartStackTy::init(bool IsSPMD) {
+  DebugEntryRAII::init();
   Usage[mapping::getThreadIdInBlock()] = 0;
Index: openmp/libomptarget/DeviceRTL/src/Debug.cpp
--- openmp/libomptarget/DeviceRTL/src/Debug.cpp
+++ openmp/libomptarget/DeviceRTL/src/Debug.cpp
@@ -32,7 +32,7 @@
 /// Current indentation level for the function trace. Only accessed by thread 0.
-static uint32_t Level = 0;
+static uint32_t Level;
 #pragma omp allocate(Level) allocator(omp_pteam_mem_alloc)
 DebugEntryRAII::DebugEntryRAII(const char *File, const unsigned Line,
@@ -55,4 +55,6 @@
+void DebugEntryRAII::init() { Level = 0; }
 #pragma omp end declare target
Index: openmp/libomptarget/DeviceRTL/include/Debug.h
--- openmp/libomptarget/DeviceRTL/include/Debug.h
+++ openmp/libomptarget/DeviceRTL/include/Debug.h
@@ -65,6 +65,8 @@
 struct DebugEntryRAII {
   DebugEntryRAII(const char *File, const unsigned Line, const char *Function);
+  static void init();

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D113963.387483.patch
Type: text/x-patch
Size: 1456 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20211116/42b703c8/attachment.bin>

More information about the Openmp-commits mailing list