[llvm-branch-commits] [llvm] [mlir] [MLIR][OpenMP] Support device shared memory for recipe ops (PR #238364)
Akash Banerjee via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Tue Nov 3 09:50:37 PST 2026
================
@@ -2484,6 +2752,10 @@ cleanupPrivateVars(T op, llvm::IRBuilderBase &builder,
for (PrivateVarsInfo::VarInfo &var : privateVarsInfo.vars) {
if (mightUseDeviceSharedMem &&
omp::allocaUsesRequireSharedMem(var.blockArg)) {
+ // Free the init-region internal allocations before the top-level private
+ // storage, in reverse order.
+ for (const DeviceSharedAlloc &alloc : llvm::reverse(var.sharedAllocs))
----------------
TIFitis wrote:
The new shared-allocation cleanup pattern breaks default AMDGPU compilation of a runtime-sized array privatised on target and accessed inside a nested parallel. I've attached a minimal reproducer below:
```
subroutine test(n, y)
use omp_lib
integer :: n, y, x(n)
!$omp target private(x) map(from:y)
x(1) = 42
!$omp parallel num_threads(128)
if (omp_get_thread_num() == 0) y = x(1)
!$omp end parallel
!$omp end target
end subroutine
program main
integer :: y
call test(4, y)
if (y /= 42) stop 1
end program
```
https://github.com/llvm/llvm-project/pull/238364
More information about the llvm-branch-commits
mailing list