File tree 2 files changed +56
-1
lines changed
lib/Conversion/SCFToCalyx
test/Conversion/SCFToCalyx
2 files changed +56
-1
lines changed Original file line number Diff line number Diff line change @@ -1894,7 +1894,6 @@ class BuildParGroups : public calyx::FuncOpPartialLoweringPattern {
1894
1894
OpBuilder insideBuilder (newParOp);
1895
1895
Block *currBlock = nullptr ;
1896
1896
auto ®ion = newParOp.getRegion ();
1897
- IRMapping operandMap;
1898
1897
1899
1898
// extract lower bounds, upper bounds, and steps as integer index values
1900
1899
SmallVector<int64_t > lbVals, ubVals, stepVals;
@@ -1920,6 +1919,11 @@ class BuildParGroups : public calyx::FuncOpPartialLoweringPattern {
1920
1919
SmallVector<int64_t > indices = lbVals;
1921
1920
1922
1921
while (true ) {
1922
+ // Each iteration starts with a fresh mapping, so each new block’s
1923
+ // argument of a region-based operation (such as `scf.for`) get re-mapped
1924
+ // independently.
1925
+ IRMapping operandMap;
1926
+
1923
1927
// Create a new block in the region for the current combination of indices
1924
1928
currBlock = ®ion.emplaceBlock ();
1925
1929
insideBuilder.setInsertionPointToEnd (currBlock);
Original file line number Diff line number Diff line change @@ -530,3 +530,54 @@ module {
530
530
return %res : si32
531
531
}
532
532
}
533
+
534
+ // Test parallel op lowering when it has region-based nested ops, such as `scf.for`
535
+
536
+ // -----
537
+
538
+ // CHECK: calyx.control {
539
+ // CHECK: calyx.seq {
540
+ // CHECK: calyx.par {
541
+ // CHECK: calyx.seq {
542
+ // CHECK: calyx.enable @init_for_0_induction_var
543
+ // CHECK: calyx.repeat 2 {
544
+ // CHECK: calyx.seq {
545
+ // CHECK: calyx.enable @bb0_0
546
+ // CHECK: calyx.enable @bb0_1
547
+ // CHECK: calyx.enable @incr_for_0_induction_var
548
+ // CHECK: }
549
+ // CHECK: }
550
+ // CHECK: }
551
+ // CHECK: calyx.seq {
552
+ // CHECK: calyx.enable @init_for_1_induction_var
553
+ // CHECK: calyx.repeat 2 {
554
+ // CHECK: calyx.seq {
555
+ // CHECK: calyx.enable @bb0_2
556
+ // CHECK: calyx.enable @bb0_3
557
+ // CHECK: calyx.enable @incr_for_1_induction_var
558
+ // CHECK: }
559
+ // CHECK: }
560
+ // CHECK: }
561
+ // CHECK: }
562
+ // CHECK: }
563
+ // CHECK: }
564
+ // CHECK: } {toplevel}
565
+
566
+ module {
567
+ func.func @main () {
568
+ %c2 = arith.constant 2 : index
569
+ %c1 = arith.constant 1 : index
570
+ %c0 = arith.constant 0 : index
571
+ %alloc = memref.alloc () : memref <6 xi32 >
572
+ %alloc_1 = memref.alloc () : memref <6 xi32 >
573
+ scf.parallel (%arg2 ) = (%c0 ) to (%c2 ) step (%c1 ) {
574
+ scf.for %arg3 = %c0 to %c2 step %c1 {
575
+ %1 = memref.load %alloc_1 [%arg3 ] : memref <6 xi32 >
576
+ %2 = arith.shli %arg2 , %c1 : index
577
+ memref.store %1 , %alloc [%2 ] : memref <6 xi32 >
578
+ }
579
+ scf.reduce
580
+ }
581
+ return
582
+ }
583
+ }
You can’t perform that action at this time.
0 commit comments