[all-commits] [llvm/llvm-project] c79474: [flang][cuda] Support non-allocatable module-level...

Zhen Wang via All-commits all-commits at lists.llvm.org
Wed Apr 1 11:43:26 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: c794742bd7f41c80b764b58019258cafd87f4a6a
      https://github.com/llvm/llvm-project/commit/c794742bd7f41c80b764b58019258cafd87f4a6a
  Author: Zhen Wang <zhenw at nvidia.com>
  Date:   2026-04-01 (Wed, 01 Apr 2026)

  Changed paths:
    M flang-rt/lib/cuda/registration.cpp
    M flang/include/flang/Evaluate/tools.h
    M flang/include/flang/Runtime/CUDA/registration.h
    M flang/lib/Optimizer/CodeGen/CodeGen.cpp
    M flang/lib/Optimizer/Transforms/CUDA/CUFAddConstructor.cpp
    M flang/lib/Optimizer/Transforms/CUDA/CUFOpConversionLate.cpp
    M flang/test/Fir/CUDA/cuda-code-gen.mlir
    M flang/test/Fir/CUDA/cuda-constructor-2.f90
    M flang/test/Fir/CUDA/cuda-device-address.mlir
    M flang/test/Lower/CUDA/cuda-data-transfer.cuf

  Log Message:
  -----------
  [flang][cuda] Support non-allocatable module-level managed variables (#189753)

Add support for non-allocatable module-level CUDA managed variables
using pointer indirection through a companion global in
__nv_managed_data__. The CUDA runtime populates this pointer with the
unified memory address via __cudaRegisterManagedVar and
__cudaInitModule.

- Create a .managed.ptr companion global in the __nv_managed_data__
section and register it with _FortranACUFRegisterManagedVariable
- Call __cudaInitModule once after all variables are registered, only
when non-allocatable managed globals are present, to populate managed
pointers
- Annotate managed globals in gpu.module with nvvm.managed for PTX
.attribute(.managed) generation
- Suppress cuf.data_transfer for assignments to/from non-allocatable
module managed variables, since cudaMemcpy would target the shadow
address rather than the actual unified memory
- Preserve cuf.data_transfer for device_var = managed_var assignments
where explicit transfer is still required

Note: This PR depends on
[#189751](https://github.com/llvm/llvm-project/pull/189751) (MLIR:
nvvm.managed attribute).



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