diff --git a/mlir/include/mlir/Dialect/OpenACC/OpenACCOps.td b/mlir/include/mlir/Dialect/OpenACC/OpenACCOps.td --- a/mlir/include/mlir/Dialect/OpenACC/OpenACCOps.td +++ b/mlir/include/mlir/Dialect/OpenACC/OpenACCOps.td @@ -565,12 +565,14 @@ 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 --- a/mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp +++ b/mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp @@ -377,10 +377,10 @@ 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"; @@ -453,11 +453,11 @@ 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()) { if (yieldOp.getOperands().size() != 1 || diff --git a/mlir/test/Dialect/OpenACC/invalid.mlir b/mlir/test/Dialect/OpenACC/invalid.mlir --- a/mlir/test/Dialect/OpenACC/invalid.mlir +++ b/mlir/test/Dialect/OpenACC/invalid.mlir @@ -267,7 +267,7 @@ // ----- -// expected-error@+1 {{expects init region with one argument of the privatization type}} +// expected-error@+1 {{expects init region first argument of the privatization type}} acc.private.recipe @privatization_i32 : !llvm.ptr init { ^bb0(%arg0 : !llvm.ptr): %c1 = arith.constant 1 : i32 @@ -291,7 +291,7 @@ // ----- -// expected-error@+1 {{expects destroy region with one argument of the privatization type}} +// expected-error@+1 {{expects destroy region first argument of the privatization type}} acc.private.recipe @privatization_i32 : !llvm.ptr init { ^bb0(%arg0 : !llvm.ptr): %c1 = arith.constant 1 : i32 @@ -312,7 +312,7 @@ // ----- -// expected-error@+1 {{expects init region with one argument of the privatization type}} +// expected-error@+1 {{expects init region first argument of the privatization type}} acc.firstprivate.recipe @privatization_i32 : !llvm.ptr init { ^bb0(%arg0 : !llvm.ptr): %c1 = arith.constant 1 : i32 @@ -379,7 +379,7 @@ // ----- -// expected-error@+1 {{destroy region with one argument of the privatization type}} +// expected-error@+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 @@ // ----- -// expected-error@+1 {{expects init region with one argument of the reduction type}} +// expected-error@+1 {{expects init region first argument of the reduction type}} acc.reduction.recipe @reduction_i64 : i64 reduction_operator init { ^bb0(%0: i32): %1 = arith.constant 0 : i64 @@ -427,7 +427,7 @@ // ----- -// expected-error@+1 {{expects combiner region with two arguments of the reduction type}} +// expected-error@+1 {{expects combiner region with the first two arguments of the reduction type}} acc.reduction.recipe @reduction_i64 : i64 reduction_operator init { ^bb0(%0: i64): %1 = arith.constant 0 : i64 @@ -439,7 +439,7 @@ // ----- -// expected-error@+1 {{expects combiner region with two arguments of the reduction type}} +// expected-error@+1 {{expects combiner region with the first two arguments of the reduction type}} acc.reduction.recipe @reduction_i64 : i64 reduction_operator init { ^bb0(%0: i64): %1 = arith.constant 0 : i64