[all-commits] [llvm/llvm-project] f25e9f: [MLIR][OpenMP] Introduce overlapped record type ma...

agozillon via All-commits all-commits at lists.llvm.org
Fri Aug 22 07:42:43 PDT 2025


  Branch: refs/heads/users/agozillo/declare-target-to-3
  Home:   https://github.com/llvm/llvm-project
  Commit: f25e9f879a51cff7b915099e432ebc959dbdd821
      https://github.com/llvm/llvm-project/commit/f25e9f879a51cff7b915099e432ebc959dbdd821
  Author: agozillon <Andrew.Gozillon at amd.com>
  Date:   2025-08-22 (Fri, 22 Aug 2025)

  Changed paths:
    M mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp

  Log Message:
  -----------
  [MLIR][OpenMP] Introduce overlapped record type map support

This PR introduces a new additional type of map lowering for record types that Clang currently supports, in which a user can map a top-level record type and then individual members with different mapping, effectively creating a sort of "overlapping" mapping that we attempt to cut around.

This is currently most predominantly used in Fortran, when mapping descriptors and there data, we map the descriptor and its data with separate map modifiers and "cut around" the pointer data, so that wedo not overwrite it unless the runtime deems it a neccesary action based on its reference counting mechanism. However, it is a mechanism that will come in handy/trigger when a user explitily maps a record type (derived type or structure) and then explicitly maps a member with a different map type.

These additions were predominantly in the OpenMPToLLVMIRTranslation.cpp file and phase, however, one Flang test that checks end-to-end IR compilation (as far as we care for now at least) was altered.

2/3 required PRs to enable declare target to mapping, should look at PR 3/3 to check for full green passes (this one will fail a number due to some dependencies).

Co-authored-by: Raghu Maddhipatla raghu.maddhipatla at amd.com


  Commit: 2c8bfedf09f80e91c23f1e529e7832a42c202116
      https://github.com/llvm/llvm-project/commit/2c8bfedf09f80e91c23f1e529e7832a42c202116
  Author: agozillon <Andrew.Gozillon at amd.com>
  Date:   2025-08-22 (Fri, 22 Aug 2025)

  Changed paths:
    M flang/include/flang/Optimizer/Builder/FIRBuilder.h

  Log Message:
  -----------
  [Flang][OpenMP] Additional global address space modifications for device

A prior PR added a portion of the global address space modifications required for declare target to, this PR seeks to add a small amount more leftover from that PR.

The intent is to allow for more correct IR that the backends (in particular AMDGPU) can treat more aptly for optimisations and code correctness

1/3 required PRs to enable declare target to mapping, should look at PR 3/3 to check for full green passes (this one will fail a number due to some dependencies).

Co-authored-by: Raghu Maddhipatla raghu.maddhipatla at amd.com


  Commit: fbdebb1c7c95b3a343cd03de0abbd8c7f1b6c7f6
      https://github.com/llvm/llvm-project/commit/fbdebb1c7c95b3a343cd03de0abbd8c7f1b6c7f6
  Author: agozillon <Andrew.Gozillon at amd.com>
  Date:   2025-08-22 (Fri, 22 Aug 2025)

  Changed paths:
    M llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp

  Log Message:
  -----------
  [Flang][OpenMP] Additional global address space modifications for device

A prior PR added a portion of the global address space modifications required for declare target to, this PR seeks to add a small amount more leftover from that PR.

The intent is to allow for more correct IR that the backends (in particular AMDGPU) can treat more aptly for optimisations and code correctness

1/3 required PRs to enable declare target to mapping, should look at PR 3/3 to check for full green passes (this one will fail a number due to some dependencies).

Co-authored-by: Raghu Maddhipatla raghu.maddhipatla at amd.com


  Commit: 09d422b3ddadee5c9e535dfb710050dff2769e34
      https://github.com/llvm/llvm-project/commit/09d422b3ddadee5c9e535dfb710050dff2769e34
  Author: agozillon <Andrew.Gozillon at amd.com>
  Date:   2025-08-22 (Fri, 22 Aug 2025)

  Changed paths:
    M flang/lib/Optimizer/OpenMP/MapInfoFinalization.cpp
    M flang/test/Lower/OpenMP/DelayedPrivatization/target-private-allocatable.f90
    M flang/test/Lower/OpenMP/DelayedPrivatization/target-teams-private-implicit-scalar-map.f90
    M flang/test/Lower/OpenMP/allocatable-array-bounds.f90
    M flang/test/Lower/OpenMP/allocatable-map.f90
    M flang/test/Lower/OpenMP/array-bounds.f90
    M flang/test/Lower/OpenMP/declare-mapper.f90
    M flang/test/Lower/OpenMP/declare-target-link-tarop-cap.f90
    M flang/test/Lower/OpenMP/defaultmap.f90
    M flang/test/Lower/OpenMP/derived-type-allocatable-map.f90
    M flang/test/Lower/OpenMP/optional-argument-map-3.f90
    M flang/test/Lower/OpenMP/target-enter-data-default-openmp52.f90
    M flang/test/Lower/OpenMP/target.f90
    M flang/test/Lower/volatile-openmp.f90
    M flang/test/Transforms/omp-map-info-finalization.fir
    M llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
    M mlir/include/mlir/Dialect/OpenMP/OpenMPEnums.td
    M mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
    A mlir/test/Target/LLVMIR/omptarget-declare-target-to-device.mlir
    A offload/test/offloading/fortran/declare-target-to-allocatable-vars-in-target-with-update.f90
    A offload/test/offloading/fortran/declare-target-to-vars-target-region-and-update.f90
    A offload/test/offloading/fortran/declare-target-to-zero-index-allocatable-target-map.f90

  Log Message:
  -----------
  [Flang][OpenMP][MLIR] Initial declare target to for variables implementation

While the infrastructure for declare target to/enter and link for variables exists in the MLIR dialect and at the Flang level, the current lowering from MLIR -> LLVM IR isn't in place, it's only in place for variables that have the link clause applied.

This PR aims to extend that lowering to an initial implementation that incorporates declare target to as well, which primarily requires changes in the OpenMPToLLVMIRTranslation phase. However, a minor addition to the OpenMP dialect was required to extend the declare target enumerator to include a default None field as well.

This also requires a minor change to the Flang lowering's MapInfoFinlization.cpp pass to alter the map type for descriptors to deal with cases where a variable is marked declare to. Currently, when a descriptor variable is mapped declare target to the descriptor component can become attatched, and cannot be updated, this results in issues when an unusual allocation range is specified (effectively an off-by X error). The current solution is to map the descriptor always, as we always require an up-to-date version of this data. However, this also requires an interlinked PR that adds a more intricate type of mapping of structures/record types that clang currently implements, to circumvent the overwriting of the pointer in the descriptor.

3/3 required PRs to enable declare target to mapping, this PR should pass all tests and provide an all green CI.

Co-authored-by: Raghu Maddhipatla raghu.maddhipatla at amd.com


Compare: https://github.com/llvm/llvm-project/compare/f2c5f4d417e2...09d422b3ddad

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