[all-commits] [llvm/llvm-project] 571df0: [OpenMP][MLIR] Refactor and extend current map sup...

agozillon via All-commits all-commits at lists.llvm.org
Tue Sep 19 06:31:10 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 571df0132daa903ed2c5ad5776e4d264b823de40
      https://github.com/llvm/llvm-project/commit/571df0132daa903ed2c5ad5776e4d264b823de40
  Author: Andrew Gozillon <Andrew.Gozillon at amd.com>
  Date:   2023-09-19 (Tue, 19 Sep 2023)

  Changed paths:
    M mlir/include/mlir/Dialect/OpenMP/CMakeLists.txt
    M mlir/include/mlir/Dialect/OpenMP/OpenMPDialect.h
    M mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
    M mlir/lib/Conversion/OpenMPToLLVM/OpenMPToLLVM.cpp
    M mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
    M mlir/test/Conversion/OpenMPToLLVM/convert-to-llvmir.mlir
    M mlir/test/Dialect/OpenMP/invalid.mlir
    M mlir/test/Dialect/OpenMP/ops.mlir

  Log Message:
  -----------
  [OpenMP][MLIR] Refactor and extend current map support by adding MapInfoOp and DataBoundsOp operations to the OpenMP Dialect

This patch adds two new operations:

The first is the DataBoundsOp, which is based on OpenACC's DataBoundsOp,
which holds stride, index, extent, lower bound and upper bounds
which will be used in future follow up patches to perform initial
array sectioning of mapped arrays, and Fortran pointer and
allocatable mapping. Similarly to OpenACC, this new OpenMP
DataBoundsOp also comes with a new OpenMP type, which
helps to restrict operations to accepting only
DataBoundsOp as an input or output where necessary
(or other related operations that implement this type as
a return).

The patch also adds the MapInfoOp which rolls up some of
the old map information stored in target
operations into this new operation, and adds new
information that will be utilised in the lowering of mapped
variables, e.g. the aforementioned DataBoundsOp, but also a
new ByCapture OpenMP MLIR attribute, and isImplicit boolean
attribute. Both the ByCapture and isImplicit arguments will
affect the lowering from the OpenMP dialect to LLVM-IR in
minor but important ways, such as shifting the final maptype
or generating different load/store combinations to maintain
semantics with the OpenMP standard and alignment with the
current Clang OpenMP output as best as possible.

This MapInfoOp operation is slightly based on OpenACC's
DataEntryOp, the main difference other than some slightly
different fields (e,g, isImplicit/MapType/ByCapture) is that
OpenACC's data operations "inherit" (the MLIR ODS
equivalent) from this operation, whereas in OpenMP operations
that utilise MapInfoOp's are composed of/contain them.

A series of these MapInfoOp (one per map clause list item) is
now held by target operations that represent OpenMP
directives that utilise map clauses, e.g. TargetOp. MapInfoOp's
do not have their own specialised lowering to LLVM-IR, instead
the lowering is dependent on the particular container of the
MapInfoOp's, e.g. TargetOp has its own lowering to LLVM-IR
which utilised the information stored inside of MapInfoOp's to
affect it's lowering and the end result of the LLVM-IR generated,
which in turn can differ for host and device.

This patch contains these operations, minor changes to the
printing and parsing to support them, changes to tests (only
those relevant to this segment of the patch, other test
additions and changes are in other dependent
patches in this series) and some alterations to the OpenMPToLLVM
rewriter to support the new OpenMP type and operations.

This patch is one in a series that are dependent on each
other:

https://reviews.llvm.org/D158734
https://reviews.llvm.org/D158735
https://reviews.llvm.org/D158737

Reviewers: kiranchandramohan, TIFitis, razvanlupusoru

Differential Revision: https://reviews.llvm.org/D158732


  Commit: 8fde6f41a0e5a2b280e46521ed2236fab5c03412
      https://github.com/llvm/llvm-project/commit/8fde6f41a0e5a2b280e46521ed2236fab5c03412
  Author: Andrew Gozillon <Andrew.Gozillon at amd.com>
  Date:   2023-09-19 (Tue, 19 Sep 2023)

  Changed paths:
    M flang/include/flang/Lower/OpenMP.h
    M flang/lib/Lower/Bridge.cpp
    M flang/lib/Lower/DirectivesCommon.h
    M flang/lib/Lower/OpenACC.cpp
    M flang/lib/Lower/OpenMP.cpp
    M flang/test/Fir/convert-to-llvm-openmp-and-fir.fir
    A flang/test/Lower/OpenMP/array-bounds.f90
    M flang/test/Lower/OpenMP/location.f90
    M flang/test/Lower/OpenMP/omp-target-early-outlining.f90
    M flang/test/Lower/OpenMP/target.f90

  Log Message:
  -----------
  [Flang][OpenMP] Add lowering from PFT to new MapEntry and Bounds operations and tie them to relevant Target operations

This patch builds on top of a prior patch in review which adds a new map
and bounds operation by modifying the OpenMP PFT lowering to support
these operations and generate them from the PFT.

A significant amount of the support for the Bounds operation is borrowed
from OpenACC's own current implementation and lowering, just ported
over to OpenMP.

The patch also adds very preliminary/initial support for lowering to
a new Capture attribute, which is stored on the new Map Operation,
which helps the later lowering from OpenMP -> LLVM IR by indicating
how a map argument should be handled. This capture type will
influence how a map argument is accessed on device and passed by
the host (different load/store handling etc.). It is reflective of a
similar piece of information stored in the Clang AST which performs a
similar role.

As well as some minor adjustments to how the map type (map bitshift
which dictates to the runtime how it should handle an argument) is
generated to further support more use-cases for future patches that
build on this work.

Finally it adds the map entry operation creation and tying it to the relevant
target operations as well as the addition of some new tests and alteration
of previous tests to support the new changes.

Depends on D158732

reviewers: kiranchandramohan, TIFitis, clementval, razvanlupusoru

Differential Revision: https://reviews.llvm.org/D158734


  Commit: eaa0d281b62cf0e1e538c24b69b2acde7b0fa665
      https://github.com/llvm/llvm-project/commit/eaa0d281b62cf0e1e538c24b69b2acde7b0fa665
  Author: Andrew Gozillon <Andrew.Gozillon at amd.com>
  Date:   2023-09-19 (Tue, 19 Sep 2023)

  Changed paths:
    M flang/lib/Optimizer/Transforms/OMPEarlyOutlining.cpp

  Log Message:
  -----------
  [Flang][MLIR][OpenMP] Update OMPEarlyOutlining to support Bounds, MapEntry and declare target globals

This patch is a required change for the device side IR to
maintain apporpiate links for declare target variables to
their global variables for later lowering.

It is also a requirement to clone over map bounds and
entry operations to maintain the correct information for
later lowering of the IR.

It simply tries to clone over the relevant information
maintaining the appropriate links they would have
maintained prior to the pass, rather than redirecting
them to new function arguments which causes a
loss of information in the case of Declare Target
and map information.

Depends on D158734

reviewers: TIFitis, razvanlupusoru

Differential Revision: https://reviews.llvm.org/D158735


  Commit: b05d436ec65e5e57a4e617211433ee0523792953
      https://github.com/llvm/llvm-project/commit/b05d436ec65e5e57a4e617211433ee0523792953
  Author: Andrew Gozillon <Andrew.Gozillon at amd.com>
  Date:   2023-09-19 (Tue, 19 Sep 2023)

  Changed paths:
    M mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
    M mlir/test/Target/LLVMIR/omptarget-llvm.mlir
    M mlir/test/Target/LLVMIR/omptarget-region-device-llvm.mlir
    M mlir/test/Target/LLVMIR/omptarget-region-llvm-target-device.mlir
    M mlir/test/Target/LLVMIR/omptarget-region-llvm.mlir
    M mlir/test/Target/LLVMIR/omptarget-region-parallel-llvm.mlir

  Log Message:
  -----------
  [MLIR][OpenMP] Alterations to LLVM-IR lowering of OpenMP Dialect due to Bounds and MapEntry operations

This patch adjusts the lower to LLVM-IR inside of
OpenMPToLLVMIRTranslation to faciliate the changes made
to Target related operations to add the new Map related
operations. It also includes adjustments to tests to support
these changes, primarily modifying the MLIR as opposed to
the LLVM-IR, the LLVM-IR should be identical after this patch.

Depends on D158735

Reviewers: kiranchandramohan, TIFitis, razvanlupusoru

Differential Revision: https://reviews.llvm.org/D158737


Compare: https://github.com/llvm/llvm-project/compare/9120e854486d...b05d436ec65e


More information about the All-commits mailing list