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:
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";
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 ||
// -----
-// 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<i32> init {
^bb0(%arg0 : !llvm.ptr<f32>):
%c1 = arith.constant 1 : i32
// -----
-// 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<i32> init {
^bb0(%arg0 : !llvm.ptr<i32>):
%c1 = arith.constant 1 : i32
// -----
-// 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<i32> init {
^bb0(%arg0 : !llvm.ptr<f32>):
%c1 = arith.constant 1 : i32
// -----
-// 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
// -----
-// 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<add> init {
^bb0(%0: i32):
%1 = arith.constant 0 : i64
// -----
-// 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<add> init {
^bb0(%0: i64):
%1 = arith.constant 0 : i64
// -----
-// 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<add> init {
^bb0(%0: i64):
%1 = arith.constant 0 : i64