Skip to content

Commit 74f15d9

Browse files
committed
[mlir][openacc] Add check for the private list in acc.serial
Add the missing check on private list information. The check is the same than the one done for acc.parallel. Depends on D151146 Reviewed By: razvanlupusoru, jeanPerier Differential Revision: https://reviews.llvm.org/D151149
1 parent eaf29b3 commit 74f15d9

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

mlir/include/mlir/Dialect/OpenACC/OpenACCOps.td

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -705,8 +705,8 @@ def OpenACC_SerialOp : OpenACC_Op<"serial",
705705
Optional<I1>:$ifCond,
706706
Optional<I1>:$selfCond,
707707
UnitAttr:$selfAttr,
708-
OptionalAttr<OpenACC_ReductionOperatorAttr>:$reductionOp,
709708
Variadic<AnyType>:$reductionOperands,
709+
OptionalAttr<SymbolRefArrayAttr>:$reductionRecipes,
710710
Variadic<OpenACC_PointerLikeTypeInterface>:$gangPrivateOperands,
711711
OptionalAttr<SymbolRefArrayAttr>:$privatizations,
712712
Variadic<AnyType>:$gangFirstPrivateOperands,
@@ -735,7 +735,9 @@ def OpenACC_SerialOp : OpenACC_Op<"serial",
735735
| `wait` `(` $waitOperands `:` type($waitOperands) `)`
736736
| `self` `(` $selfCond `)`
737737
| `if` `(` $ifCond `)`
738-
| `reduction` `(` $reductionOperands `:` type($reductionOperands) `)`
738+
| `reduction` `(` custom<SymOperandList>(
739+
$reductionOperands, type($reductionOperands), $reductionRecipes)
740+
`)`
739741
)
740742
$region attr-dict-with-keyword
741743
}];

mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,10 @@ LogicalResult acc::SerialOp::verify() {
584584
*this, getPrivatizations(), getGangPrivateOperands(), "private",
585585
"privatizations")))
586586
return failure();
587+
if (failed(checkSymOperandList<mlir::acc::ReductionRecipeOp>(
588+
*this, getReductionRecipes(), getReductionOperands(), "reduction",
589+
"reductions")))
590+
return failure();
587591
return checkDataOperands<acc::SerialOp>(*this, getDataClauseOperands());
588592
}
589593

mlir/test/Dialect/OpenACC/ops.mlir

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1440,3 +1440,25 @@ func.func @acc_reduc_test(%a : i64) -> () {
14401440
// CHECK-LABEL: func.func @acc_reduc_test(
14411441
// CHECK-SAME: %[[ARG0:.*]]: i64)
14421442
// CHECK: acc.parallel reduction(@reduction_add_i64 -> %[[ARG0]] : i64)
1443+
1444+
// -----
1445+
1446+
acc.reduction.recipe @reduction_add_i64 : i64 reduction_operator<add> init {
1447+
^bb0(%0: i64):
1448+
%1 = arith.constant 0 : i64
1449+
acc.yield %1 : i64
1450+
} combiner {
1451+
^bb0(%0: i64, %1: i64):
1452+
%2 = arith.addi %0, %1 : i64
1453+
acc.yield %2 : i64
1454+
}
1455+
1456+
func.func @acc_reduc_test(%a : i64) -> () {
1457+
acc.serial reduction(@reduction_add_i64 -> %a : i64) {
1458+
}
1459+
return
1460+
}
1461+
1462+
// CHECK-LABEL: func.func @acc_reduc_test(
1463+
// CHECK-SAME: %[[ARG0:.*]]: i64)
1464+
// CHECK: acc.serial reduction(@reduction_add_i64 -> %[[ARG0]] : i64)

0 commit comments

Comments
 (0)