[PATCH] D75449: [MLIR][GPU] fix loop trip count computation in LoopsToGPU
Tobias Gysi via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 2 05:52:10 PST 2020
gysit created this revision.
gysit added a reviewer: herhut.
Herald added subscribers: llvm-commits, Joonsoo, liufengdb, lucyrfox, mgester, arpith-jacob, csigg, nicolasvasilache, antiagainst, shauheen, burmako, jpienaar, rriddle, mehdi_amini.
Herald added a reviewer: mravishankar.
Herald added a project: LLVM.
Added brackets to fix the loop trip count computation. The brackets ensure the bounds are subtracted before we divide the result by the step of the loop.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D75449
Files:
mlir/lib/Conversion/LoopsToGPU/LoopsToGPU.cpp
mlir/test/Conversion/LoopsToGPU/parallel_loop.mlir
Index: mlir/test/Conversion/LoopsToGPU/parallel_loop.mlir
===================================================================
--- mlir/test/Conversion/LoopsToGPU/parallel_loop.mlir
+++ mlir/test/Conversion/LoopsToGPU/parallel_loop.mlir
@@ -15,7 +15,7 @@
return
}
-// CHECK: #[[MAP0:.*]] = affine_map<()[s0, s1, s2] -> (s0 - s1 ceildiv s2)>
+// CHECK: #[[MAP0:.*]] = affine_map<()[s0, s1, s2] -> ((s0 - s1) ceildiv s2)>
// CHECK: #[[MAP1:.*]] = affine_map<(d0)[s0, s1] -> (d0 * s0 + s1)>
// CHECK: module {
@@ -66,7 +66,7 @@
return
}
-// CHECK: #[[MAP0:.*]] = affine_map<()[s0, s1, s2] -> (s0 - s1 ceildiv s2)>
+// CHECK: #[[MAP0:.*]] = affine_map<()[s0, s1, s2] -> ((s0 - s1) ceildiv s2)>
// CHECK: #[[MAP1:.*]] = affine_map<(d0)[s0, s1] -> (d0 * s0 + s1)>
// CHECK: module {
@@ -115,7 +115,7 @@
return
}
-// CHECK: #[[MAP0:.*]] = affine_map<()[s0, s1, s2] -> (s0 - s1 ceildiv s2)>
+// CHECK: #[[MAP0:.*]] = affine_map<()[s0, s1, s2] -> ((s0 - s1) ceildiv s2)>
// CHECK: #[[MAP1:.*]] = affine_map<(d0)[s0, s1] -> (d0 * s0 + s1)>
// CHECK: module {
@@ -166,7 +166,7 @@
return
}
-// CHECK: #[[MAP0:.*]] = affine_map<()[s0, s1, s2] -> (s0 - s1 ceildiv s2)>
+// CHECK: #[[MAP0:.*]] = affine_map<()[s0, s1, s2] -> ((s0 - s1) ceildiv s2)>
// CHECK: #[[MAP1:.*]] = affine_map<(d0)[s0, s1] -> (d0 * s0 + s1)>
// CHECK: module {
@@ -241,7 +241,7 @@
}
// CHECK: #[[MAP0:.*]] = affine_map<(d0, d1)[s0, s1] -> (d0 * s1 + s0 + d1)>
-// CHECK: #[[MAP1:.*]] = affine_map<()[s0, s1, s2] -> (s0 - s1 ceildiv s2)>
+// CHECK: #[[MAP1:.*]] = affine_map<()[s0, s1, s2] -> ((s0 - s1) ceildiv s2)>
// CHECK: #[[MAP2:.*]] = affine_map<(d0)[s0, s1] -> (d0 * s0 + s1)>
// CHECK: #[[MAP3:.*]] = affine_map<(d0)[s0] -> (2, -d0 + s0)>
// CHECK: #[[MAP4:.*]] = affine_map<(d0)[s0] -> (3, -d0 + s0)>
Index: mlir/lib/Conversion/LoopsToGPU/LoopsToGPU.cpp
===================================================================
--- mlir/lib/Conversion/LoopsToGPU/LoopsToGPU.cpp
+++ mlir/lib/Conversion/LoopsToGPU/LoopsToGPU.cpp
@@ -653,8 +653,8 @@
// affine.apply here so that it composes nicely with the provided map.
AffineMap stepMap =
AffineMap::get(0, 3,
- (rewriter.getAffineSymbolExpr(0) -
- rewriter.getAffineSymbolExpr(1).ceilDiv(
+ ((rewriter.getAffineSymbolExpr(0) -
+ rewriter.getAffineSymbolExpr(1)).ceilDiv(
rewriter.getAffineSymbolExpr(2))));
Value launchBound = rewriter.create<AffineApplyOp>(
loc, annotation.boundMap.compose(stepMap),
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D75449.247613.patch
Type: text/x-patch
Size: 2806 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200302/81c4054f/attachment.bin>
More information about the llvm-commits
mailing list