Skip to content

Commit 96059b7

Browse files
committed
Fixup that scf.parallel induction variables were iterated in wrong (reversed) order, leading to issues in scf.parallel unrolling
1 parent ebe4ece commit 96059b7

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

mlir/lib/Util/Dependency.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -774,6 +774,10 @@ LogicalResult unrollScfParallel(
774774
IRMapping localRemap = remap;
775775
std::vector<unsigned> position =
776776
air::getMDVectorFromIterator(par_size, iter);
777+
std::reverse(
778+
position.begin(),
779+
position
780+
.end()); // scf.parallel induction vars. have LSD at highest index.
777781
for (unsigned i = 0; i < position.size(); i++) {
778782
localRemap.map(par.getInductionVars()[i],
779783
builder.create<arith::ConstantIndexOp>(

mlir/test/Transform/AIRDependencyScheduleOpt/loop_fusion.mlir

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -751,10 +751,10 @@ func.func @func8(%arg0: memref<512x1024xbf16>, %arg1: memref<256x4x4x128xbf16>,
751751
// CHECK-NEXT: air.channel.get async [{{.*}}] @channel_1[]
752752
// CHECK-NEXT: air.channel.put async [{{.*}}] @channel_2[%c0{{.*}}, %c0{{.*}}]
753753
// CHECK-NEXT: air.channel.put async [{{.*}}] @channel_2[%c0{{.*}}, %c0{{.*}}]
754-
// CHECK-NEXT: air.channel.put async [{{.*}}] @channel_2[%c1{{.*}}, %c0{{.*}}]
755-
// CHECK-NEXT: air.channel.put async [{{.*}}] @channel_2[%c1{{.*}}, %c0{{.*}}]
756754
// CHECK-NEXT: air.channel.put async [{{.*}}] @channel_2[%c0{{.*}}, %c1{{.*}}]
757755
// CHECK-NEXT: air.channel.put async [{{.*}}] @channel_2[%c0{{.*}}, %c1{{.*}}]
756+
// CHECK-NEXT: air.channel.put async [{{.*}}] @channel_2[%c1{{.*}}, %c0{{.*}}]
757+
// CHECK-NEXT: air.channel.put async [{{.*}}] @channel_2[%c1{{.*}}, %c0{{.*}}]
758758
// CHECK-NEXT: air.channel.put async [{{.*}}] @channel_2[%c1{{.*}}, %c1{{.*}}]
759759
// CHECK-NEXT: air.channel.put async [{{.*}}] @channel_2[%c1{{.*}}, %c1{{.*}}]
760760
// CHECK: scf.yield

mlir/test/Transform/AIRDependencyScheduleOpt/specialize-channel-wrap-and-stride.mlir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -655,8 +655,8 @@ module {
655655
// Scf.for on integer type.
656656
// CHECK-LABEL: test18
657657
// CHECK: air.channel.put async {{.*}} @channel_0[%c0{{.*}}, %c0{{.*}}] (%{{.*}}[%c0{{.*}}, %c0{{.*}}, %c0{{.*}}, %c0{{.*}}] [%c32{{.*}}, %c32{{.*}}, %c4{{.*}}, %c2{{.*}}] [%c512{{.*}}, %c2{{.*}}, %c128{{.*}}, %c1{{.*}}])
658-
// CHECK: air.channel.put async {{.*}} @channel_0[%c1{{.*}}, %c0{{.*}}] (%{{.*}}[%c0{{.*}}, %c0{{.*}}, %c0{{.*}}, %c16384{{.*}}] [%c32{{.*}}, %c32{{.*}}, %c4{{.*}}, %c2{{.*}}] [%c512{{.*}}, %c2{{.*}}, %c128{{.*}}, %c1{{.*}}])
659658
// CHECK: air.channel.put async {{.*}} @channel_0[%c0{{.*}}, %c1{{.*}}] (%{{.*}}[%c0{{.*}}, %c0{{.*}}, %c0{{.*}}, %c64{{.*}}] [%c32{{.*}}, %c32{{.*}}, %c4{{.*}}, %c2{{.*}}] [%c512{{.*}}, %c2{{.*}}, %c128{{.*}}, %c1{{.*}}])
659+
// CHECK: air.channel.put async {{.*}} @channel_0[%c1{{.*}}, %c0{{.*}}] (%{{.*}}[%c0{{.*}}, %c0{{.*}}, %c0{{.*}}, %c16384{{.*}}] [%c32{{.*}}, %c32{{.*}}, %c4{{.*}}, %c2{{.*}}] [%c512{{.*}}, %c2{{.*}}, %c128{{.*}}, %c1{{.*}}])
660660
// CHECK: air.channel.put async {{.*}} @channel_0[%c1{{.*}}, %c1{{.*}}] (%{{.*}}[%c0{{.*}}, %c0{{.*}}, %c0{{.*}}, %c16448{{.*}}] [%c32{{.*}}, %c32{{.*}}, %c4{{.*}}, %c2{{.*}}] [%c512{{.*}}, %c2{{.*}}, %c128{{.*}}, %c1{{.*}}])
661661

662662
func.func @test18(%arg0: memref<*xf32>, %arg1: memref<*xf32>) {

0 commit comments

Comments
 (0)