Use the new reduction design in acc.loop operation.
Depends on D151146
Reviewed By: razvanlupusoru, jeanPerier
Differential Revision: https://reviews.llvm.org/D151164
Variadic<IntOrIndex>:$tileOperands,
Variadic<OpenACC_PointerLikeTypeInterface>:$privateOperands,
OptionalAttr<SymbolRefArrayAttr>:$privatizations,
- OptionalAttr<OpenACC_ReductionOperatorAttr>:$reductionOp,
- Variadic<AnyType>:$reductionOperands);
+ Variadic<AnyType>:$reductionOperands,
+ OptionalAttr<SymbolRefArrayAttr>:$reductionRecipes);
let results = (outs Variadic<AnyType>:$results);
$privateOperands, type($privateOperands), $privatizations)
`)`
| `tile` `(` $tileOperands `:` type($tileOperands) `)`
- | `reduction` `(` $reductionOperands `:` type($reductionOperands) `)`
+ | `reduction` `(` custom<SymOperandList>(
+ $reductionOperands, type($reductionOperands), $reductionRecipes)
+ `)`
)
$region
( `(` type($results)^ `)` )?
"privatizations")))
return failure();
+ if (failed(checkSymOperandList<mlir::acc::ReductionRecipeOp>(
+ *this, getReductionRecipes(), getReductionOperands(), "reduction",
+ "reductions")))
+ return failure();
+
// Check non-empty body().
if (getRegion().empty())
return emitError("expected non-empty body.");
// -----
acc.reduction.recipe @reduction_add_i64 : i64 reduction_operator<add> init {
-^bb0(%0: i64):
- %1 = arith.constant 0 : i64
- acc.yield %1 : i64
+^bb0(%arg0: i64):
+ %0 = arith.constant 0 : i64
+ acc.yield %0 : i64
} combiner {
-^bb0(%0: i64, %1: i64):
- %2 = arith.addi %0, %1 : i64
- acc.yield %2 : i64
+^bb0(%arg0: i64, %arg1: i64):
+ %0 = arith.addi %arg0, %arg1 : i64
+ acc.yield %0 : i64
}
// CHECK-LABEL: acc.reduction.recipe @reduction_add_i64 : i64 reduction_operator <add> init {
func.func @acc_reduc_test(%a : i64) -> () {
acc.parallel reduction(@reduction_add_i64 -> %a : i64) {
+ acc.loop reduction(@reduction_add_i64 -> %a : i64) {
+ acc.yield
+ }
+ acc.yield
}
return
}
// CHECK-LABEL: func.func @acc_reduc_test(
// CHECK-SAME: %[[ARG0:.*]]: i64)
// CHECK: acc.parallel reduction(@reduction_add_i64 -> %[[ARG0]] : i64)
+// CHECK: acc.loop reduction(@reduction_add_i64 -> %[[ARG0]] : i64)
// -----