Skip to content

Commit 32dc480

Browse files
committed
[OpenMP][DeviceRTL] Fix an issue that thread array might be corrupted
The shared memory stack in the device runtime assumes no intervined uses. D135037 breaks the assumption, potentially causing the shared stack corruption. This patch moves the thread array to heap memory. Since it is already the slow path, it doesn't matter that much anyway. Reviewed By: jhuber6 Differential Revision: https://reviews.llvm.org/D135391
1 parent b9898e7 commit 32dc480

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

openmp/libomptarget/DeviceRTL/src/State.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,11 +263,11 @@ void state::enterDataEnvironment(IdentTy *Ident) {
263263
if (!atomic::load(ThreadStatesBitsPtr, atomic::seq_cst)) {
264264
uint32_t Bytes = sizeof(ThreadStates[0]) * mapping::getBlockSize();
265265
void *ThreadStatesPtr =
266-
memory::allocShared(Bytes, "Thread state array allocation");
266+
memory::allocGlobal(Bytes, "Thread state array allocation");
267267
if (!atomic::cas(ThreadStatesBitsPtr, uintptr_t(0),
268268
reinterpret_cast<uintptr_t>(ThreadStatesPtr),
269269
atomic::seq_cst, atomic::seq_cst))
270-
memory::freeShared(ThreadStatesPtr, Bytes,
270+
memory::freeGlobal(ThreadStatesPtr, Bytes,
271271
"Thread state array allocated multiple times");
272272
ASSERT(atomic::load(ThreadStatesBitsPtr, atomic::seq_cst) &&
273273
"Expected valid thread states bit!");

0 commit comments

Comments
 (0)