[all-commits] [llvm/llvm-project] 8472bc: [flang][cuda] Don't allocate managed descriptors f...
khaki3 via All-commits
all-commits at lists.llvm.org
Mon Jun 8 10:38:45 PDT 2026
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 8472bc79bf157925c87c3acb7dbb4ac4ddb3070d
https://github.com/llvm/llvm-project/commit/8472bc79bf157925c87c3acb7dbb4ac4ddb3070d
Author: khaki3 <47756807+khaki3 at users.noreply.github.com>
Date: 2026-06-08 (Mon, 08 Jun 2026)
Changed paths:
M flang/lib/Optimizer/CodeGen/CodeGen.cpp
M flang/test/Fir/CUDA/cuda-code-gen.mlir
Log Message:
-----------
[flang][cuda] Don't allocate managed descriptors for OpenACC data-clause boxes (#201957)
Example:
```fortran
module m
real(8), allocatable :: u(:,:,:,:) ! device-resident allocatable
contains
subroutine core(uf, n)
integer :: n
real(8) :: uf(n,n,n,5)
!$acc kernels loop present(uf) ! descriptor built for uf
...
end subroutine
subroutine wrap(n)
call core(u, n)
end subroutine
end module
```
In this code, the descriptor for `present(uf)` is only used by `acc`
data-clause ops (the kernel gets the clause result, not the box), so it
never needs to be device-accessible. But `isDeviceAllocation()` is true,
so it's allocated via `_FortranACUFAllocDescriptor` in managed memory
and never freed — leaking it and leaving stale descriptors when the
address is reused.
Fix: allocate a descriptor in managed memory only when truly
device-accessible — used by a GPU kernel launch
(`isUsedByGPULaunchFunc`), or device-allocated and not consumed by an
`acc` data-clause op. Add `isUsedByOpenACCDataClause` and gate the
`isDeviceAllocation` branch with it.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list