[Openmp-commits] [openmp] 374cd0f - [OpenMP] Fix initializer not working on AMDGPU
Joseph Huber via Openmp-commits
openmp-commits at lists.llvm.org
Tue Nov 16 05:17:25 PST 2021
Author: Joseph Huber
Date: 2021-11-16T08:17:15-05:00
New Revision: 374cd0fb6102a8726da0e6036b3c484aca32c61e
URL: https://github.com/llvm/llvm-project/commit/374cd0fb6102a8726da0e6036b3c484aca32c61e
DIFF: https://github.com/llvm/llvm-project/commit/374cd0fb6102a8726da0e6036b3c484aca32c61e.diff
LOG: [OpenMP] Fix initializer not working on AMDGPU
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.
Reviewed By: jdoerfert, JonChesterfield
Differential Revision: https://reviews.llvm.org/D113963
Added:
Modified:
openmp/libomptarget/DeviceRTL/include/Debug.h
openmp/libomptarget/DeviceRTL/src/Debug.cpp
openmp/libomptarget/DeviceRTL/src/State.cpp
Removed:
################################################################################
diff --git a/openmp/libomptarget/DeviceRTL/include/Debug.h b/openmp/libomptarget/DeviceRTL/include/Debug.h
index f66d5667c1094..18c43f30ab624 100644
--- a/openmp/libomptarget/DeviceRTL/include/Debug.h
+++ b/openmp/libomptarget/DeviceRTL/include/Debug.h
@@ -57,6 +57,8 @@ int printf(const char *format, ...);
struct DebugEntryRAII {
DebugEntryRAII(const char *File, const unsigned Line, const char *Function);
~DebugEntryRAII();
+
+ static void init();
};
#endif
diff --git a/openmp/libomptarget/DeviceRTL/src/Debug.cpp b/openmp/libomptarget/DeviceRTL/src/Debug.cpp
index fc9b2ed2265a1..79be7289556f7 100644
--- a/openmp/libomptarget/DeviceRTL/src/Debug.cpp
+++ b/openmp/libomptarget/DeviceRTL/src/Debug.cpp
@@ -55,7 +55,7 @@ int32_t __llvm_omp_vprintf(const char *Format, void *Arguments, uint32_t Size) {
}
/// 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,
@@ -78,4 +78,6 @@ DebugEntryRAII::~DebugEntryRAII() {
Level--;
}
+void DebugEntryRAII::init() { Level = 0; }
+
#pragma omp end declare target
diff --git a/openmp/libomptarget/DeviceRTL/src/State.cpp b/openmp/libomptarget/DeviceRTL/src/State.cpp
index a16fa1b1a0fac..d6ae00b1850dd 100644
--- a/openmp/libomptarget/DeviceRTL/src/State.cpp
+++ b/openmp/libomptarget/DeviceRTL/src/State.cpp
@@ -366,8 +366,10 @@ void *&state::lookupPtr(ValueKind Kind, bool IsReadonly) {
void state::init(bool IsSPMD) {
SharedMemorySmartStack.init(IsSPMD);
- if (mapping::isInitialThreadInLevel0(IsSPMD))
+ if (mapping::isInitialThreadInLevel0(IsSPMD)) {
TeamState.init(IsSPMD);
+ DebugEntryRAII::init();
+ }
ThreadStates[mapping::getThreadIdInBlock()] = nullptr;
}
More information about the Openmp-commits
mailing list