[OpenMP][MLIR] Add omp.canonical_loop operation, !omp.cli type, omp.new_cli operation by jsjodin · Pull Request #71712 · llvm/llvm-project (original) (raw)

@llvm/pr-subscribers-flang-openmp
@llvm/pr-subscribers-mlir

@llvm/pr-subscribers-mlir-openmp

Author: Jan Leyonberg (jsjodin)

Changes

This work is a continuation of #65380.

This patch adds the omp.canonical_loop to represent canonical loops in OpenMP. This will expand how loops are represented in the OMP dialect. It also allows simpler code generation by using canonical loop codegen the OpenMPIRBuilder. The !omp.cli type and omp.new_cli operation are added to be able to represent dependencies between canonical loops and future loop transformation operations.

Compared to #65380, instead of returning CLI values from the omp.canonical_loop operations and propagating the CLI values by using omp.yield, we introduce a new operation omp.new_cli that creates a new CLI value which can be passed to a omp.canonical_loop op to associate the value with that loop. This eliminates the need for using omp.yield, and since the CLI values are optional inputs to omp.canonical_loop there is no need to use them unless loop transformations are used.


Full diff: https://github.com/llvm/llvm-project/pull/71712.diff

3 Files Affected:

diff --git a/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td b/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td index 99ac5cfb7b9e922..e544be3e6564b03 100644 --- a/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td +++ b/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td @@ -405,6 +405,170 @@ def SingleOp : OpenMP_Op<"single", [AttrSizedOperandSegments]> { let hasVerifier = 1; }

+//===---------------------------------------------------------------------===// +// OpenMP Canonical Loop Info Type +//===---------------------------------------------------------------------===// + +def CanonicalLoopInfoType : OpenMP_Type<"CanonicalLoopInfo", "cli"> {

+} + + +//===---------------------------------------------------------------------===// +// OpenMP Canonical Loop Operation +//===---------------------------------------------------------------------===// +def CanonicalLoopOp : OpenMP_Op<"canonical_loop", [SingleBlockImplicitTerminator<"omp::YieldOp">]> {

+//===----------------------------------------------------------------------===// +// CanonicaLoopOp +//===----------------------------------------------------------------------===// + +Value mlir::omp::CanonicalLoopOp::getInductionVar() {

diff --git a/mlir/test/Dialect/OpenMP/cli.mlir b/mlir/test/Dialect/OpenMP/cli.mlir new file mode 100644 index 000000000000000..a397b442fd61d96 --- /dev/null +++ b/mlir/test/Dialect/OpenMP/cli.mlir @@ -0,0 +1,56 @@ +// RUN: mlir-opt %s | mlir-opt | FileCheck %s + +// CHECK-LABEL: @omp_canonloop_raw +// CHECK-SAME: (%[[tc:.*]]: i32) +func.func @omp_canonloop_raw(%tc : i32) -> () {