[all-commits] [llvm/llvm-project] 14e2cb: [MLIR][OpenMP] Normalize representation of entry b...
Sergio Afonso via All-commits
all-commits at lists.llvm.org
Tue Sep 24 07:43:25 PDT 2024
Branch: refs/heads/users/skatrak/block-args-02-asmfmt
Home: https://github.com/llvm/llvm-project
Commit: 14e2cb11c53e1ef82fbce474a1b48517e9b2f111
https://github.com/llvm/llvm-project/commit/14e2cb11c53e1ef82fbce474a1b48517e9b2f111
Author: Sergio Afonso <safonsof at amd.com>
Date: 2024-09-24 (Tue, 24 Sep 2024)
Changed paths:
M flang/test/Fir/convert-to-llvm-openmp-and-fir.fir
M flang/test/Lower/OpenMP/DelayedPrivatization/target-private-multiple-variables.f90
M flang/test/Lower/OpenMP/DelayedPrivatization/target-private-simple.f90
M flang/test/Lower/OpenMP/Todo/omp-default-clause-inner-loop.f90
M flang/test/Lower/OpenMP/common-block-map.f90
M flang/test/Lower/OpenMP/default-clause-byref.f90
M flang/test/Lower/OpenMP/default-clause.f90
M flang/test/Lower/OpenMP/delayed-privatization-private-firstprivate.f90
M flang/test/Lower/OpenMP/derived-type-map.f90
M flang/test/Lower/OpenMP/distribute-parallel-do-simd.f90
M flang/test/Lower/OpenMP/distribute-parallel-do.f90
M flang/test/Lower/OpenMP/firstprivate-commonblock.f90
M flang/test/Lower/OpenMP/hlfir-seqloop-parallel.f90
M flang/test/Lower/OpenMP/implicit-dsa.f90
M flang/test/Lower/OpenMP/map-component-ref.f90
M flang/test/Lower/OpenMP/parallel-firstprivate-clause-scalar.f90
M flang/test/Lower/OpenMP/parallel-private-clause.f90
M flang/test/Lower/OpenMP/parallel-reduction-add-byref.f90
M flang/test/Lower/OpenMP/parallel-reduction-add.f90
M flang/test/Lower/OpenMP/parallel-wsloop.f90
M flang/test/Lower/OpenMP/private-commonblock.f90
M flang/test/Lower/OpenMP/sections-array-reduction.f90
M flang/test/Lower/OpenMP/sections-reduction.f90
M flang/test/Lower/OpenMP/statement-function.f90
M flang/test/Lower/OpenMP/target.f90
M flang/test/Lower/OpenMP/unstructured.f90
M flang/test/Lower/OpenMP/wsloop-reduction-add-byref.f90
M flang/test/Lower/OpenMP/wsloop-reduction-add.f90
M flang/test/Lower/OpenMP/wsloop-reduction-logical-and-byref.f90
M flang/test/Lower/OpenMP/wsloop-reduction-logical-and.f90
M flang/test/Lower/OpenMP/wsloop-reduction-logical-eqv-byref.f90
M flang/test/Lower/OpenMP/wsloop-reduction-logical-eqv.f90
M flang/test/Lower/OpenMP/wsloop-reduction-logical-neqv-byref.f90
M flang/test/Lower/OpenMP/wsloop-reduction-logical-neqv.f90
M flang/test/Lower/OpenMP/wsloop-reduction-logical-or-byref.f90
M flang/test/Lower/OpenMP/wsloop-reduction-logical-or.f90
M flang/test/Lower/OpenMP/wsloop-reduction-mul-byref.f90
M flang/test/Lower/OpenMP/wsloop-reduction-mul.f90
M flang/test/Lower/OpenMP/wsloop-reduction-multi.f90
M flang/test/Lower/OpenMP/wsloop-reduction-multiple-clauses.f90
M flang/test/Transforms/omp-map-info-finalization.fir
M mlir/include/mlir/Dialect/OpenMP/OpenMPClauses.td
M mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
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
M mlir/test/Target/LLVMIR/omptarget-array-sectioning-host.mlir
M mlir/test/Target/LLVMIR/omptarget-byref-bycopy-generation-device.mlir
M mlir/test/Target/LLVMIR/omptarget-byref-bycopy-generation-host.mlir
M mlir/test/Target/LLVMIR/omptarget-constant-alloca-raise.mlir
M mlir/test/Target/LLVMIR/omptarget-constant-indexing-device-region.mlir
M mlir/test/Target/LLVMIR/omptarget-debug.mlir
M mlir/test/Target/LLVMIR/omptarget-debug2.mlir
M mlir/test/Target/LLVMIR/omptarget-declare-target-llvm-device.mlir
M mlir/test/Target/LLVMIR/omptarget-depend-host-only.mlir
M mlir/test/Target/LLVMIR/omptarget-depend.mlir
M mlir/test/Target/LLVMIR/omptarget-fortran-allocatable-types-host.mlir
M mlir/test/Target/LLVMIR/omptarget-fortran-common-block-host.mlir
M mlir/test/Target/LLVMIR/omptarget-nested-record-type-mapping-host.mlir
M mlir/test/Target/LLVMIR/omptarget-parallel-llvm.mlir
M mlir/test/Target/LLVMIR/omptarget-record-type-mapping-host.mlir
M mlir/test/Target/LLVMIR/omptarget-region-device-llvm.mlir
M mlir/test/Target/LLVMIR/omptarget-region-host-only.mlir
M mlir/test/Target/LLVMIR/omptarget-region-llvm.mlir
M mlir/test/Target/LLVMIR/omptarget-region-parallel-llvm.mlir
M mlir/test/Target/LLVMIR/omptarget-target-inside-task.mlir
M mlir/test/Target/LLVMIR/openmp-data-target-device.mlir
M mlir/test/Target/LLVMIR/openmp-parallel-reduction-cleanup.mlir
M mlir/test/Target/LLVMIR/openmp-parallel-reduction-multiblock.mlir
M mlir/test/Target/LLVMIR/openmp-private.mlir
M mlir/test/Target/LLVMIR/openmp-reduction-array-sections.mlir
M mlir/test/Target/LLVMIR/openmp-reduction-init-arg.mlir
M mlir/test/Target/LLVMIR/openmp-reduction-sections.mlir
M mlir/test/Target/LLVMIR/openmp-reduction.mlir
M mlir/test/Target/LLVMIR/openmp-target-use-device-nested.mlir
M mlir/test/Target/LLVMIR/openmp-task-target-device.mlir
M mlir/test/Target/LLVMIR/openmp-wsloop-reduction-cleanup.mlir
Log Message:
-----------
[MLIR][OpenMP] Normalize representation of entry block arg-defining clauses
This patch updates printing and parsing of operations including clauses that
define entry block arguments to the operation's region. This impacts
`in_reduction`, `map`, `private`, `reduction` and `task_reduction`.
The proposed representation to be used by all such clauses is the following:
```
<clause_name>([byref] [@<sym>] %value -> %block_arg [, ...] : <type>[, ...]) {
...
}
```
The `byref` tag is only allowed for reduction-like clauses and the `@<sym>` is
required and only allowed for the `private` and reduction-like clauses. The
`map` clause does not accept any of these two.
This change fixes some currently broken op representations, like `omp.teams` or
`omp.sections` reduction:
```
omp.teams reduction([byref] @<sym> -> %value : <type>) {
^bb0(%block_arg : <type>):
...
}
```
Additionally, it addresses some redundancy in the representation of the
previously mentioned cases, as well as e.g. `map` in `omp.target`. The problem
is that the block argument name after the arrow is not checked in any way,
which makes some misleading representations legal:
```mlir
omp.target map_entries(%x -> %arg1, %y -> %arg0, %z -> %doesnt_exist : !llvm.ptr, !llvm.ptr, !llvm.ptr) {
^bb0(%arg0 : !llvm.ptr, %arg1 : !llvm.ptr, %arg2 : !llvm.ptr):
...
}
```
In that case, `%x` maps to `%arg0`, contrary to what the representation states,
and `%z` maps to `%arg2`. `%doesnt_exist` is not resolved, so it would likely
cause issues if used anywhere inside of the operation's region.
The solution implemented in this patch makes it so that values introduced after
the arrow on the representation of these clauses implicitly define the
corresponding entry block arguments, removing the potential for these
problematic representations. This is what is already implemented for the
`private` and `reduction` clauses of `omp.parallel`.
There are a couple of consequences of this change:
- Entry block argument-defining clauses must come at the end of the operation's
representation and in alphabetical order. This is because they are
printed/parsed as part of the region and a standardized ordering is needed to
reliably match op arguments with their corresponding entry block arguments via
the `BlockArgOpenMPOpInterface`.
- We can no longer define per-clause assembly formats to be reused by all
operations that take these clauses, since they must be passed to a custom
printer including the region and arguments of all other entry block
argument-defining clauses. Code duplication and potential for introducing
issues is minimized by providing the generic `{print,parse}BlockArgRegion`
helpers and associated structures.
MLIR and Flang lowering unit tests are updated due to changes in the order and
formatting of impacted operations.
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