[Mlir-commits] [mlir] 332b8cf - [MLIR][Affine] Fix affine.parallel op domain add
Uday Bondhugula
llvmlistbot at llvm.org
Mon Feb 20 20:46:49 PST 2023
Author: Uday Bondhugula
Date: 2023-02-21T10:16:08+05:30
New Revision: 332b8cf1f689c8df279d920c4571ad4d2fc30066
URL: https://github.com/llvm/llvm-project/commit/332b8cf1f689c8df279d920c4571ad4d2fc30066
DIFF: https://github.com/llvm/llvm-project/commit/332b8cf1f689c8df279d920c4571ad4d2fc30066.diff
LOG: [MLIR][Affine] Fix affine.parallel op domain add
Fix obvious bug in `addAffineParallelOpDomain` that would lead to
incorrect domain constraints for any affine.parallel op with
dimensionality greater than one.
Reviewed By: springerm
Differential Revision: https://reviews.llvm.org/D144349
Added:
Modified:
mlir/lib/Dialect/Affine/Analysis/AffineStructures.cpp
mlir/test/Transforms/memref-dependence-check.mlir
Removed:
################################################################################
diff --git a/mlir/lib/Dialect/Affine/Analysis/AffineStructures.cpp b/mlir/lib/Dialect/Affine/Analysis/AffineStructures.cpp
index bd226d5ed7d20..4a7effa4b89b1 100644
--- a/mlir/lib/Dialect/Affine/Analysis/AffineStructures.cpp
+++ b/mlir/lib/Dialect/Affine/Analysis/AffineStructures.cpp
@@ -648,7 +648,7 @@ FlatAffineValueConstraints::addAffineForOpDomain(AffineForOp forOp) {
LogicalResult FlatAffineValueConstraints::addAffineParallelOpDomain(
AffineParallelOp parallelOp) {
size_t ivPos = 0;
- for (auto iv : parallelOp.getIVs()) {
+ for (Value iv : parallelOp.getIVs()) {
unsigned pos;
if (!findVar(iv, &pos)) {
assert(false && "variable expected for the IV value");
@@ -668,6 +668,7 @@ LogicalResult FlatAffineValueConstraints::addAffineParallelOpDomain(
else if (failed(addBound(BoundType::UB, pos, upperBound,
parallelOp.getUpperBoundsOperands())))
return failure();
+ ++ivPos;
}
return success();
}
diff --git a/mlir/test/Transforms/memref-dependence-check.mlir b/mlir/test/Transforms/memref-dependence-check.mlir
index dd9773857541f..10f5c0c4463b9 100644
--- a/mlir/test/Transforms/memref-dependence-check.mlir
+++ b/mlir/test/Transforms/memref-dependence-check.mlir
@@ -1102,3 +1102,31 @@ func.func @affine_if_no_dependence() {
}
return
}
+
+// -----
+
+// CHECK-LABEL: func @affine_parallel_dep_check
+func.func @affine_parallel_dep_check() {
+ %memref_23 = memref.alloc() : memref<1x130xf32>
+ %memref_25 = memref.alloc() : memref<1x130x130xf32>
+ %cst = arith.constant 0.0 : f32
+ affine.parallel (%arg4, %arg5) = (0, 0) to (1, 130) {
+ affine.store %cst, %memref_25[%arg4, %arg5, 129] : memref<1x130x130xf32>
+ // expected-remark at above {{dependence from 0 to 0 at depth 1 = false}}
+ // expected-remark at above {{dependence from 0 to 0 at depth 2 = false}}
+ // expected-remark at above {{dependence from 0 to 0 at depth 3 = false}}
+ // expected-remark at above {{dependence from 0 to 1 at depth 1 = true}}
+ }
+ %memref_27 = memref.alloc() : memref<1x128x128xf32>
+ affine.parallel (%arg4) = (0) to (130) {
+ affine.parallel (%arg5, %arg6) = (0, 0) to (1, 130) {
+ affine.load %memref_25[0, %arg4 + %arg5, %arg6] : memref<1x130x130xf32>
+ // expected-remark at above {{dependence from 1 to 1 at depth 1 = false}}
+ // expected-remark at above {{dependence from 1 to 1 at depth 2 = false}}
+ // expected-remark at above {{dependence from 1 to 1 at depth 3 = false}}
+ // expected-remark at above {{dependence from 1 to 1 at depth 4 = false}}
+ // expected-remark at above {{dependence from 1 to 0 at depth 1 = false}}
+ }
+ }
+ return
+}
More information about the Mlir-commits
mailing list