Skip to content

Commit 2adadc1

Browse files
committed
R5: Removing the check for matching scan variables and reduction variables
1 parent 5c984a0 commit 2adadc1

File tree

2 files changed

+3
-49
lines changed

2 files changed

+3
-49
lines changed

mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3167,38 +3167,19 @@ LogicalResult ScanOp::verify() {
31673167
return emitError(
31683168
"Exactly one of EXCLUSIVE or INCLUSIVE clause is expected");
31693169
}
3170-
const OperandRange &scanVars =
3171-
hasExclusiveVars() ? getExclusiveVars() : getInclusiveVars();
3172-
auto verifyScanVarsInReduction = [&scanVars](ValueRange reductionVars) {
3173-
for (const auto &it : scanVars)
3174-
if (!llvm::is_contained(reductionVars, it))
3175-
return false;
3176-
return true;
3177-
};
31783170
if (mlir::omp::WsloopOp parentWsLoopOp =
31793171
(*this)->getParentOfType<mlir::omp::WsloopOp>()) {
31803172
if (parentWsLoopOp.getReductionModAttr() &&
31813173
parentWsLoopOp.getReductionModAttr().getValue() ==
31823174
mlir::omp::ReductionModifier::inscan) {
3183-
auto iface = llvm::cast<mlir::omp::BlockArgOpenMPOpInterface>(
3184-
parentWsLoopOp.getOperation());
3185-
if (!verifyScanVarsInReduction(iface.getReductionBlockArgs())) {
3186-
return emitError(
3187-
"List item should appear in REDUCTION clause of the parent");
3188-
}
31893175
return success();
31903176
}
3191-
} else if (mlir::omp::SimdOp parentSimdOp =
3192-
(*this)->getParentOfType<mlir::omp::SimdOp>()) {
3177+
}
3178+
if (mlir::omp::SimdOp parentSimdOp =
3179+
(*this)->getParentOfType<mlir::omp::SimdOp>()) {
31933180
if (parentSimdOp.getReductionModAttr() &&
31943181
parentSimdOp.getReductionModAttr().getValue() ==
31953182
mlir::omp::ReductionModifier::inscan) {
3196-
auto iface = llvm::cast<mlir::omp::BlockArgOpenMPOpInterface>(
3197-
parentSimdOp.getOperation());
3198-
if (!verifyScanVarsInReduction(iface.getReductionBlockArgs())) {
3199-
return emitError(
3200-
"List item should appear in REDUCTION clause of the parent");
3201-
}
32023183
return success();
32033184
}
32043185
}

mlir/test/Dialect/OpenMP/invalid.mlir

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1837,33 +1837,6 @@ combiner {
18371837
omp.yield (%1 : f32)
18381838
}
18391839

1840-
func.func @scan_test_1(%lb: i32, %ub: i32, %step: i32) {
1841-
%test1f32 = "test.f32"() : () -> (!llvm.ptr)
1842-
%test2f32 = "test.f32"() : () -> (!llvm.ptr)
1843-
omp.wsloop reduction(mod:inscan, @add_f32 %test1f32 -> %arg1 : !llvm.ptr) {
1844-
omp.loop_nest (%i, %j) : i32 = (%lb, %ub) to (%ub, %lb) step (%step, %step) {
1845-
// expected-error @below {{List item should appear in REDUCTION clause of the parent}}
1846-
omp.scan inclusive(%test2f32 : !llvm.ptr)
1847-
omp.yield
1848-
}
1849-
}
1850-
return
1851-
}
1852-
1853-
// -----
1854-
1855-
omp.declare_reduction @add_f32 : f32
1856-
init {
1857-
^bb0(%arg: f32):
1858-
%0 = arith.constant 0.0 : f32
1859-
omp.yield (%0 : f32)
1860-
}
1861-
combiner {
1862-
^bb1(%arg0: f32, %arg1: f32):
1863-
%1 = arith.addf %arg0, %arg1 : f32
1864-
omp.yield (%1 : f32)
1865-
}
1866-
18671840
func.func @scan_test_2(%lb: i32, %ub: i32, %step: i32) {
18681841
%test1f32 = "test.f32"() : () -> (!llvm.ptr)
18691842
omp.wsloop reduction(mod:inscan, @add_f32 %test1f32 -> %arg1 : !llvm.ptr) {

0 commit comments

Comments
 (0)