[Mlir-commits] [mlir] 1d49834 - [mlir][openacc] Relax verifier for the acc.reduction.recipe
Valentin Clement
llvmlistbot at llvm.org
Wed Jul 19 10:32:03 PDT 2023
Author: Valentin Clement
Date: 2023-07-19T10:31:37-07:00
New Revision: 1d49834280bf6b1aa618c71b8eac74fb424049b0
URL: https://github.com/llvm/llvm-project/commit/1d49834280bf6b1aa618c71b8eac74fb424049b0
DIFF: https://github.com/llvm/llvm-project/commit/1d49834280bf6b1aa618c71b8eac74fb424049b0.diff
LOG: [mlir][openacc] Relax verifier for the acc.reduction.recipe
Allow the init and combiner regions to have more
arguments to pass information.
Reviewed By: razvanlupusoru
Differential Revision: https://reviews.llvm.org/D155656
Added:
Modified:
mlir/include/mlir/Dialect/OpenACC/OpenACCOps.td
mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp
mlir/test/Dialect/OpenACC/invalid.mlir
Removed:
################################################################################
diff --git a/mlir/include/mlir/Dialect/OpenACC/OpenACCOps.td b/mlir/include/mlir/Dialect/OpenACC/OpenACCOps.td
index a40ae060ca0aeb..6c8fa8597e4e58 100644
--- a/mlir/include/mlir/Dialect/OpenACC/OpenACCOps.td
+++ b/mlir/include/mlir/Dialect/OpenACC/OpenACCOps.td
@@ -615,12 +615,14 @@ def OpenACC_ReductionRecipeOp : OpenACC_Op<"reduction.recipe",
mandatory regions.
1. The initializer region specifies how to initialize the local reduction
- value. The region has an argument that contains the value of the
+ value. The region has a first argument that contains the value of the
reduction accumulator at the start of the reduction. It is expected to
- `acc.yield` the new value.
+ `acc.yield` the new value. Extra arguments can be added to deal with
+ dynamic arrays.
2. The reduction region contains a sequences of operations to combine two
- values of the reduction type into one. It has two arguments and it is
- expected to `acc.yield` the combined value.
+ values of the reduction type into one. It has at least two arguments
+ and it is expected to `acc.yield` the combined value. Extra arguments
+ can be added to deal with dynamic arrays.
Example:
diff --git a/mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp b/mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp
index f5d5149389c8d6..c571cae88992dd 100644
--- a/mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp
+++ b/mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp
@@ -387,10 +387,10 @@ static LogicalResult verifyInitLikeSingleArgRegion(
if (region.empty())
return op->emitOpError() << "expects non-empty " << regionName << " region";
Block &firstBlock = region.front();
- if (firstBlock.getNumArguments() != 1 ||
+ if (firstBlock.getNumArguments() < 1 ||
firstBlock.getArgument(0).getType() != type)
return op->emitOpError() << "expects " << regionName
- << " region with one "
+ << " region first "
"argument of the "
<< regionType << " type";
@@ -463,11 +463,11 @@ LogicalResult acc::ReductionRecipeOp::verifyRegions() {
return emitOpError() << "expects non-empty combiner region";
Block &reductionBlock = getCombinerRegion().front();
- if (reductionBlock.getNumArguments() != 2 ||
+ if (reductionBlock.getNumArguments() < 2 ||
reductionBlock.getArgument(0).getType() != getType() ||
reductionBlock.getArgument(1).getType() != getType())
- return emitOpError() << "expects combiner region with two arguments of "
- << "the reduction type";
+ return emitOpError() << "expects combiner region with the first two "
+ << "arguments of the reduction type";
for (YieldOp yieldOp : getCombinerRegion().getOps<YieldOp>()) {
if (yieldOp.getOperands().size() != 1 ||
diff --git a/mlir/test/Dialect/OpenACC/invalid.mlir b/mlir/test/Dialect/OpenACC/invalid.mlir
index 2a36ccabbdd9c8..1a7e1d82a392d5 100644
--- a/mlir/test/Dialect/OpenACC/invalid.mlir
+++ b/mlir/test/Dialect/OpenACC/invalid.mlir
@@ -267,7 +267,7 @@ acc.private.recipe @privatization_i32 : !llvm.ptr<i32> init {
// -----
-// expected-error at +1 {{expects init region with one argument of the privatization type}}
+// expected-error at +1 {{expects init region first argument of the privatization type}}
acc.private.recipe @privatization_i32 : !llvm.ptr<i32> init {
^bb0(%arg0 : !llvm.ptr<f32>):
%c1 = arith.constant 1 : i32
@@ -291,7 +291,7 @@ acc.private.recipe @privatization_i32 : !llvm.ptr<f32> init {
// -----
-// expected-error at +1 {{expects destroy region with one argument of the privatization type}}
+// expected-error at +1 {{expects destroy region first argument of the privatization type}}
acc.private.recipe @privatization_i32 : !llvm.ptr<i32> init {
^bb0(%arg0 : !llvm.ptr<i32>):
%c1 = arith.constant 1 : i32
@@ -312,7 +312,7 @@ acc.firstprivate.recipe @privatization_i32 : !llvm.ptr<i32> init {
// -----
-// expected-error at +1 {{expects init region with one argument of the privatization type}}
+// expected-error at +1 {{expects init region first argument of the privatization type}}
acc.firstprivate.recipe @privatization_i32 : !llvm.ptr<i32> init {
^bb0(%arg0 : !llvm.ptr<f32>):
%c1 = arith.constant 1 : i32
@@ -379,7 +379,7 @@ acc.firstprivate.recipe @privatization_i32 : !llvm.ptr<i32> init {
// -----
-// expected-error at +1 {{destroy region with one argument of the privatization type}}
+// expected-error at +1 {{expects destroy region first argument of the privatization type}}
acc.firstprivate.recipe @privatization_i32 : i32 init {
^bb0(%arg0 : i32):
%0 = arith.constant 1 : i32
@@ -409,7 +409,7 @@ acc.reduction.recipe @reduction_i64 : i64 reduction_operator<add> init {
// -----
-// expected-error at +1 {{expects init region with one argument of the reduction type}}
+// expected-error at +1 {{expects init region first argument of the reduction type}}
acc.reduction.recipe @reduction_i64 : i64 reduction_operator<add> init {
^bb0(%0: i32):
%1 = arith.constant 0 : i64
@@ -427,7 +427,7 @@ acc.reduction.recipe @reduction_i64 : i64 reduction_operator<add> init {
// -----
-// expected-error at +1 {{expects combiner region with two arguments of the reduction type}}
+// expected-error at +1 {{expects combiner region with the first two arguments of the reduction type}}
acc.reduction.recipe @reduction_i64 : i64 reduction_operator<add> init {
^bb0(%0: i64):
%1 = arith.constant 0 : i64
@@ -439,7 +439,7 @@ acc.reduction.recipe @reduction_i64 : i64 reduction_operator<add> init {
// -----
-// expected-error at +1 {{expects combiner region with two arguments of the reduction type}}
+// expected-error at +1 {{expects combiner region with the first two arguments of the reduction type}}
acc.reduction.recipe @reduction_i64 : i64 reduction_operator<add> init {
^bb0(%0: i64):
%1 = arith.constant 0 : i64
More information about the Mlir-commits
mailing list