@@ -1404,6 +1404,22 @@ void acc::ParallelOp::addFirstPrivatization(
14041404 mlir::SymbolRefAttr::get (context, recipe.getSymName ().str ()));
14051405 setFirstprivatizationRecipesAttr (mlir::ArrayAttr::get (context, recipes));
14061406}
1407+
1408+ void acc::ParallelOp::addReduction (MLIRContext *context,
1409+ mlir::acc::ReductionOp op,
1410+ mlir::acc::ReductionRecipeOp recipe) {
1411+ getReductionOperandsMutable ().append (op.getResult ());
1412+
1413+ llvm::SmallVector<mlir::Attribute> recipes;
1414+
1415+ if (getReductionRecipesAttr ())
1416+ llvm::copy (getReductionRecipesAttr (), std::back_inserter (recipes));
1417+
1418+ recipes.push_back (
1419+ mlir::SymbolRefAttr::get (context, recipe.getSymName ().str ()));
1420+ setReductionRecipesAttr (mlir::ArrayAttr::get (context, recipes));
1421+ }
1422+
14071423static ParseResult parseNumGangs (
14081424 mlir::OpAsmParser &parser,
14091425 llvm::SmallVectorImpl<mlir::OpAsmParser::UnresolvedOperand> &operands,
@@ -2070,6 +2086,21 @@ void acc::SerialOp::addFirstPrivatization(
20702086 setFirstprivatizationRecipesAttr (mlir::ArrayAttr::get (context, recipes));
20712087}
20722088
2089+ void acc::SerialOp::addReduction (MLIRContext *context,
2090+ mlir::acc::ReductionOp op,
2091+ mlir::acc::ReductionRecipeOp recipe) {
2092+ getReductionOperandsMutable ().append (op.getResult ());
2093+
2094+ llvm::SmallVector<mlir::Attribute> recipes;
2095+
2096+ if (getReductionRecipesAttr ())
2097+ llvm::copy (getReductionRecipesAttr (), std::back_inserter (recipes));
2098+
2099+ recipes.push_back (
2100+ mlir::SymbolRefAttr::get (context, recipe.getSymName ().str ()));
2101+ setReductionRecipesAttr (mlir::ArrayAttr::get (context, recipes));
2102+ }
2103+
20732104// ===----------------------------------------------------------------------===//
20742105// KernelsOp
20752106// ===----------------------------------------------------------------------===//
@@ -3088,6 +3119,20 @@ void acc::LoopOp::addPrivatization(MLIRContext *context,
30883119 setPrivatizationRecipesAttr (mlir::ArrayAttr::get (context, recipes));
30893120}
30903121
3122+ void acc::LoopOp::addReduction (MLIRContext *context, mlir::acc::ReductionOp op,
3123+ mlir::acc::ReductionRecipeOp recipe) {
3124+ getReductionOperandsMutable ().append (op.getResult ());
3125+
3126+ llvm::SmallVector<mlir::Attribute> recipes;
3127+
3128+ if (getReductionRecipesAttr ())
3129+ llvm::copy (getReductionRecipesAttr (), std::back_inserter (recipes));
3130+
3131+ recipes.push_back (
3132+ mlir::SymbolRefAttr::get (context, recipe.getSymName ().str ()));
3133+ setReductionRecipesAttr (mlir::ArrayAttr::get (context, recipes));
3134+ }
3135+
30913136// ===----------------------------------------------------------------------===//
30923137// DataOp
30933138// ===----------------------------------------------------------------------===//
0 commit comments