[all-commits] [llvm/llvm-project] aba79e: [Flang][OpenMP] Improve use_device_addr code gener...

Dominik Adamski via All-commits all-commits at lists.llvm.org
Thu Sep 17 12:47:38 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: aba79e62699d157a36bb95b3ac5eabb4f8b48e29
      https://github.com/llvm/llvm-project/commit/aba79e62699d157a36bb95b3ac5eabb4f8b48e29
  Author: Dominik Adamski <dominik.adamski at amd.com>
  Date:   2026-09-17 (Thu, 17 Sep 2026)

  Changed paths:
    M flang/lib/Optimizer/OpenMP/MapInfoFinalization.cpp
    A flang/test/Lower/OpenMP/use-device-addr-performance.f90
    M offload/include/omptarget.h
    M offload/libomptarget/exports
    M offload/libomptarget/interface.cpp
    A offload/test/offloading/fortran/target-use-device-addr-opt.f90

  Log Message:
  -----------
  [Flang][OpenMP] Improve use_device_addr code generation (#221265)

Currently, the `use_device_addr` implementation reuses the standard
mapping mechanism, which is suboptimal for code like:

```
SUBROUTINE device_addr_func(x)
    INTEGER, TARGET, INTENT(IN)    :: x(:)
    !$omp target data use_device_addr (x)
        CALL bar_offload(c_loc(x))
```

For such code, Flang maps the temporary descriptor for the x array to
the GPU. This unnecessary mapping is time-consuming and can be a large
bottleneck for Fortran-to-C function wrappers that use `use_device_addr`
to pass a C pointer for offload code.

For `use_device_addr`, we only need to update the base address in the
descriptor that is used inside `use_device_addr`. This is cheaper than
mapping the whole descriptor to the GPU.

Scope of changes:

1) Modified mapping for the use_device_addr clause. Map only the
descriptor and do not check whether it is present on the GPU.
2) Generated a copy of the host descriptor with an updated base address
   for the use_device_addr code region.

---------

Signed-off-by: Dominik Adamski <dominik.adamski at amd.com>



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