[all-commits] [llvm/llvm-project] 7fd6cb: [Flang][OpenMP] Derived type member map fortran of...

agozillon via All-commits all-commits at lists.llvm.org
Fri May 10 12:17:00 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 7fd6cb293975b05406e24aba1cc8e83275cb6bf9
      https://github.com/llvm/llvm-project/commit/7fd6cb293975b05406e24aba1cc8e83275cb6bf9
  Author: Andrew Gozillon <Andrew.Gozillon at amd.com>
  Date:   2024-05-10 (Fri, 10 May 2024)

  Changed paths:
    A offload/test/offloading/fortran/target-map-derived-type-full-1.f90
    A offload/test/offloading/fortran/target-map-derived-type-full-2.f90
    A offload/test/offloading/fortran/target-map-derived-type-full-implicit-1.f90
    A offload/test/offloading/fortran/target-map-derived-type-full-implicit-2.f90
    A offload/test/offloading/fortran/target-map-double-large-nested-dtype-multi-member.f90
    A offload/test/offloading/fortran/target-map-double-nested-dtype-array-bounds.f90
    A offload/test/offloading/fortran/target-map-double-nested-dtype-double-array-bounds.f90
    A offload/test/offloading/fortran/target-map-double-nested-dtype-single-member.f90
    A offload/test/offloading/fortran/target-map-dtype-arr-bounds-member-enter-exit-update.f90
    A offload/test/offloading/fortran/target-map-dtype-arr-bounds-member-enter-exit.f90
    A offload/test/offloading/fortran/target-map-dtype-explicit-individual-array-member.f90
    A offload/test/offloading/fortran/target-map-dtype-multi-explicit-array-3D-member-bounds.f90
    A offload/test/offloading/fortran/target-map-dtype-multi-explicit-array-member-bounds.f90
    A offload/test/offloading/fortran/target-map-dtype-multi-explicit-array-member.f90
    A offload/test/offloading/fortran/target-map-dtype-multi-explicit-member.f90
    M offload/test/offloading/fortran/target-map-enter-exit-array-2.f90
    M offload/test/offloading/fortran/target-map-enter-exit-array-bounds.f90
    M offload/test/offloading/fortran/target-map-enter-exit-scalar.f90
    A offload/test/offloading/fortran/target-map-individual-dtype-member-map.f90
    A offload/test/offloading/fortran/target-map-large-nested-dtype-multi-member.f90
    A offload/test/offloading/fortran/target-map-nested-dtype-complex-member.f90
    A offload/test/offloading/fortran/target-map-nested-dtype-derived-member.f90
    A offload/test/offloading/fortran/target-map-nested-dtype-multi-member.f90
    A offload/test/offloading/fortran/target-map-nested-dtype-single-member.f90
    A offload/test/offloading/fortran/target-map-two-dtype-explicit-member.f90
    A offload/test/offloading/fortran/target-map-two-dtype-individual-member-array-1D-bounds.f90
    A offload/test/offloading/fortran/target-map-two-dtype-mixed-implicit-explicit-capture-1.f90
    A offload/test/offloading/fortran/target-map-two-dtype-mixed-implicit-explicit-capture-2.f90
    A offload/test/offloading/fortran/target-map-two-dtype-multi-member-array-1D-bounds.f90
    A offload/test/offloading/fortran/target-map-two-nested-dtype-member-array-map.f90

  Log Message:
  -----------
  [Flang][OpenMP] Derived type member map fortran offload runtime tests

This is a large series of runtime tests that help to add coverage for the specific cases intended to be supported by the PR stack
that extends derived type map support in Flang+OpenMP. Primarily this will add functionality coverage, there's cases where
things may work, but not optimally (or at least similarly to the status quo in Clang), addiitonal IR tests are added in the
relevant segments of the related PRs to test for breakages like that.

Pull Request: https://github.com/llvm/llvm-project/pull/82850


  Commit: 50df0ff515697090983b3cb951c48377bcfb6ddf
      https://github.com/llvm/llvm-project/commit/50df0ff515697090983b3cb951c48377bcfb6ddf
  Author: Andrew Gozillon <Andrew.Gozillon at amd.com>
  Date:   2024-05-10 (Fri, 10 May 2024)

  Changed paths:
    M mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
    M mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
    M mlir/test/Dialect/OpenMP/ops.mlir

  Log Message:
  -----------
  [OpenMP][MLIR] Add new arguments to map_info to help support record type maps

This PR adds two new fields to omp.map_info, one BoolAttr and one I64ArrayAttr.

The BoolAttr is named partial_map, and is a flag that indicates if the record type captured by
the map_info operation is a partial map, or if it is mapped in its entirety, this currently helps
the later lowering determine the type of map entries that need to be generated.

The I64ArrayAttr named members_index is intended to track the placement of each member
map_info operations (and by extension mapped member variable) placement in the parent
record type. This may need to be extended to an N-D array for nested member mapping.

Pull Request: https://github.com/llvm/llvm-project/pull/82851


  Commit: 462435f089b7ca67ed1eed60f369e16b71e76b74
      https://github.com/llvm/llvm-project/commit/462435f089b7ca67ed1eed60f369e16b71e76b74
  Author: Andrew Gozillon <Andrew.Gozillon at amd.com>
  Date:   2024-05-10 (Fri, 10 May 2024)

  Changed paths:
    M mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
    M mlir/test/Target/LLVMIR/omptarget-fortran-allocatable-types-host.mlir
    M mlir/test/Target/LLVMIR/omptarget-llvm.mlir
    A mlir/test/Target/LLVMIR/omptarget-nested-record-type-mapping-host.mlir
    A mlir/test/Target/LLVMIR/omptarget-record-type-mapping-host.mlir

  Log Message:
  -----------
  [OpenMP][MLIR] Extend record member map support for omp dialect to LLVM-IR

This patch seeks to refactor slightly and extend the current record type map
support that was put in place for Fortran's descriptor types to handle explicit
member mapping for record types at a single level of depth (the case of explicit
mapping of nested record types is currently unsupported).

This patch seeks to support this by extending the OpenMPToLLVMIRTranslation phase
to more generally support record types, building on the prior groundwork in the
Fortran allocatables/pointers patch. It now supports different kinds of record type
mapping, in this case full record type mapping and then explicit member mapping
in which there is a special case for certain types when mapped individually to not
require any parent map link in the kernel argument structure. To facilitate this
required:
   *  The movement of the setting of the map flag type "ptr_and_obj" to respective
         frontends, now supporting it as a possible flag that can be read and printed
         in mlir form. Some minor changes to declare target map type setting was
         neccesary for this.
   * The addition of a member index array operand, which tracks the position
       of the member in the parent, required for caclulating the appropriate size
       to offload to the target, alongside the parents offload pointer (always the
       first member currently being mapped).
   * A partial mapping attribute operand, to indicate if the entire record type is
       being mapped or just member components, aiding the ability to lower
       record types in the different manners that are possible.
   * Refactoring bounds calculation for record types and general arrays to one
       location (as well as load/store generation prior to assigning to the kernel
       argument structure), as a side affect enter/exit/update/data mapping
       should now be more correct and fully support bounds mapping, previously
       this would have only worked for target.

Pull Request: https://github.com/llvm/llvm-project/pull/82852


  Commit: 435e850ba97ab567a14b6c84d2b27cadb771cb27
      https://github.com/llvm/llvm-project/commit/435e850ba97ab567a14b6c84d2b27cadb771cb27
  Author: Andrew Gozillon <Andrew.Gozillon at amd.com>
  Date:   2024-05-10 (Fri, 10 May 2024)

  Changed paths:
    M flang/docs/OpenMP-descriptor-management.md
    M flang/include/flang/Optimizer/Transforms/Passes.h
    M flang/include/flang/Optimizer/Transforms/Passes.td
    M flang/include/flang/Tools/CLOptions.inc
    M flang/lib/Lower/OpenMP/ClauseProcessor.cpp
    M flang/lib/Lower/OpenMP/ClauseProcessor.h
    M flang/lib/Lower/OpenMP/OpenMP.cpp
    M flang/lib/Lower/OpenMP/Utils.cpp
    M flang/lib/Lower/OpenMP/Utils.h
    M flang/lib/Optimizer/Transforms/CMakeLists.txt
    R flang/lib/Optimizer/Transforms/OMPDescriptorMapInfoGen.cpp
    A flang/lib/Optimizer/Transforms/OMPMapInfoFinalization.cpp
    M flang/test/Fir/convert-to-llvm-openmp-and-fir.fir
    M flang/test/Integration/OpenMP/map-types-and-sizes.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
    A flang/test/Lower/OpenMP/derived-type-map.f90
    M flang/test/Lower/OpenMP/map-component-ref.f90
    M flang/test/Lower/OpenMP/target.f90
    R flang/test/Transforms/omp-descriptor-map-info-gen.fir
    A flang/test/Transforms/omp-map-info-finalization.fir

  Log Message:
  -----------
  [Flang][OpenMP][MLIR] Initial derived type member map support

This patch is one in a series of four patches that seeks to refactor
slightly and extend the current record type map support that was
put in place for Fortran's descriptor types to handle explicit
member mapping for record types at a single level of depth.

For example, the below case where two members of a Fortran
derived type are mapped explicitly:

''''
  type :: scalar_and_array
    real(4) :: real
    integer(4) :: array(10)
    integer(4) :: int
  end type scalar_and_array
  type(scalar_and_array) :: scalar_arr

  !$omp target map(tofrom: scalar_arr%int, scalar_arr%real)
''''

Current cases of derived type mapping left for future work are:
  > explicit member mapping of nested members (e.g. two layers of
     record types where we explicitly map a member from the internal
     record type)
  > Fortran's automagical mapping of all elements and nested elements
     of a derived type
  > explicit member mapping of a derived type and then constituient members
     (redundant in Fortran due to former case but still legal as far as I am aware)
  > explicit member mapping of a record type (may be handled reasonably, just
     not fully tested in this iteration)
  > explicit member mapping for Fortran allocatable types (a variation of nested
     record types)

This patch seeks to support this by extending the Flang-new OpenMP lowering to
support generation of this newly required information, creating the neccessary
parent <-to-> member map_info links, calculating the member indices and
setting if it's a partial map.

The OMPDescriptorMapInfoGen pass has also been generalized into a map
finalization phase, now named OMPMapInfoFinalization. This pass was extended
to support the insertion of member maps into the BlockArg and MapOperands of
relevant map carrying operations. Similar to the method in which descriptor types
are expanded and constituient members inserted.

Pull Request: https://github.com/llvm/llvm-project/pull/82853


Compare: https://github.com/llvm/llvm-project/compare/d009bd7c69ee...435e850ba97a

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