| 1 |
! Test optional fusing of forall assignments in the scheduling analysis |
| 2 |
! from lower-hlfir-ordered-assignments pass. Assignments are fused in the |
| 3 |
! same loop nest if they are given the same run id. |
| 4 |
|
| 5 |
! RUN: bbc -hlfir -o - -pass-pipeline="builtin.module(lower-hlfir-ordered-assignments{fuse-assignments=false})" --debug-only=flang-ordered-assignment -flang-dbg-order-assignment-schedule-only %s 2>&1 | FileCheck %s --check-prefix NOFUSE |
| 6 |
|
| 7 |
! RUN: bbc -hlfir -o - -pass-pipeline="builtin.module(lower-hlfir-ordered-assignments{fuse-assignments=true})" --debug-only=flang-ordered-assignment -flang-dbg-order-assignment-schedule-only %s 2>&1 | FileCheck %s --check-prefix FUSE |
| 8 |
|
| 9 |
! REQUIRES: asserts |
| 10 |
|
| 11 |
subroutine fusable_assign_easy(x, y, z) |
| 12 |
integer :: x(:), y(:), z(:) |
| 13 |
forall(i=1:10) |
| 14 |
x(i) = 42 |
| 15 |
z(i) = 42 |
| 16 |
end forall |
| 17 |
end subroutine |
| 18 |
!NOFUSE-LABEL: ------------ scheduling forall in _QPfusable_assign_easy ------------ |
| 19 |
!NOFUSE-NEXT: run 1 evaluate: forall/region_assign1 |
| 20 |
!NOFUSE-NEXT: run 2 evaluate: forall/region_assign2 |
| 21 |
|
| 22 |
!FUSE-LABEL: ------------ scheduling forall in _QPfusable_assign_easy ------------ |
| 23 |
!FUSE-NEXT: run 1 evaluate: forall/region_assign1 |
| 24 |
!FUSE-NEXT: run 1 evaluate: forall/region_assign2 |
| 25 |
|
| 26 |
subroutine fusable_assign(x, y, z) |
| 27 |
integer :: x(:), y(:), z(:) |
| 28 |
forall(i=1:10) |
| 29 |
x(i) = y(i) |
| 30 |
z(i) = y(11-i) |
| 31 |
end forall |
| 32 |
end subroutine |
| 33 |
!NOFUSE-LABEL: ------------ scheduling forall in _QPfusable_assign ------------ |
| 34 |
!NOFUSE-NEXT: run 1 evaluate: forall/region_assign1 |
| 35 |
!NOFUSE-NEXT: run 2 evaluate: forall/region_assign2 |
| 36 |
|
| 37 |
!FUSE-LABEL: ------------ scheduling forall in _QPfusable_assign ------------ |
| 38 |
!FUSE-NEXT: run 1 evaluate: forall/region_assign1 |
| 39 |
!FUSE-NEXT: run 1 evaluate: forall/region_assign2 |
| 40 |
|
| 41 |
subroutine unfusable_assign_1(x, y, z) |
| 42 |
integer :: x(:), y(:), z(:) |
| 43 |
forall(i=1:10) |
| 44 |
x(i) = y(i) |
| 45 |
z(i) = x(11-i) |
| 46 |
end forall |
| 47 |
end subroutine |
| 48 |
!NOFUSE-LABEL: ------------ scheduling forall in _QPunfusable_assign_1 ------------ |
| 49 |
!NOFUSE-NEXT: run 1 evaluate: forall/region_assign1 |
| 50 |
!NOFUSE-NEXT: run 2 evaluate: forall/region_assign2 |
| 51 |
|
| 52 |
!FUSE-LABEL: ------------ scheduling forall in _QPunfusable_assign_1 ------------ |
| 53 |
!FUSE-NEXT: run 1 evaluate: forall/region_assign1 |
| 54 |
!FUSE-NEXT: conflict: R/W: <block argument> of type '!fir.box<!fir.array<?xi32>>' at index: 0 W:<block argument> of type '!fir.box<!fir.array<?xi32>>' at index: 0 |
| 55 |
!FUSE-NEXT: run 2 evaluate: forall/region_assign2 |
| 56 |
|
| 57 |
subroutine unfusable_assign_2(x, y) |
| 58 |
integer :: x(:), y(:) |
| 59 |
forall(i=1:10) |
| 60 |
x(i) = y(i) |
| 61 |
x(i+1) = y(i+1) |
| 62 |
end forall |
| 63 |
end subroutine |
| 64 |
!NOFUSE-LABEL: ------------ scheduling forall in _QPunfusable_assign_2 ------------ |
| 65 |
!NOFUSE-NEXT: run 1 evaluate: forall/region_assign1 |
| 66 |
!NOFUSE-NEXT: run 2 evaluate: forall/region_assign2 |
| 67 |
|
| 68 |
!FUSE-LABEL: ------------ scheduling forall in _QPunfusable_assign_2 ------------ |
| 69 |
!FUSE-NEXT: run 1 evaluate: forall/region_assign1 |
| 70 |
!FUSE-NEXT: conflict: R/W: <block argument> of type '!fir.box<!fir.array<?xi32>>' at index: 0 W:<block argument> of type '!fir.box<!fir.array<?xi32>>' at index: 0 |
| 71 |
!FUSE-NEXT: run 2 evaluate: forall/region_assign2 |
| 72 |
|
| 73 |
subroutine unfusable_assign_3(x, y, z) |
| 74 |
integer :: x(:, :), y(:, :), z(:, :) |
| 75 |
forall(i=1:10) |
| 76 |
forall(j=1:z(i, i)) x(i, j) = y(i, j) |
| 77 |
z(i, :) = y(i, :) |
| 78 |
end forall |
| 79 |
end subroutine |
| 80 |
!NOFUSE-LABEL: ------------ scheduling forall in _QPunfusable_assign_3 ------------ |
| 81 |
!NOFUSE-NEXT: run 1 evaluate: forall/forall1/region_assign1 |
| 82 |
!NOFUSE-NEXT: run 2 evaluate: forall/region_assign1 |
| 83 |
|
| 84 |
!FUSE-LABEL: ------------ scheduling forall in _QPunfusable_assign_3 ------------ |
| 85 |
!FUSE-NEXT: run 1 evaluate: forall/forall1/region_assign1 |
| 86 |
!FUSE-NEXT: conflict: R/W: <block argument> of type '!fir.box<!fir.array<?x?xi32>>' at index: 2 W:<block argument> of type '!fir.box<!fir.array<?x?xi32>>' at index: 2 |
| 87 |
!FUSE-NEXT: run 2 evaluate: forall/region_assign1 |
| 88 |
|
| 89 |
subroutine unfusable_assign_4(x, y, z) |
| 90 |
integer :: x(:, :), y(:, :), z(:, :) |
| 91 |
forall(i=1:10) |
| 92 |
x(i, :) = y(i, :) |
| 93 |
forall(j=1:x(i, i)) z(i, j) = y(i, j) |
| 94 |
end forall |
| 95 |
end subroutine |
| 96 |
!NOFUSE-LABEL: ------------ scheduling forall in _QPunfusable_assign_4 ------------ |
| 97 |
!NOFUSE-NEXT: run 1 evaluate: forall/region_assign1 |
| 98 |
!NOFUSE-NEXT: run 2 evaluate: forall/forall1/region_assign1 |
| 99 |
|
| 100 |
!FUSE-LABEL: ------------ scheduling forall in _QPunfusable_assign_4 ------------ |
| 101 |
!FUSE-NEXT: run 1 evaluate: forall/region_assign1 |
| 102 |
!FUSE-NEXT: conflict: R/W: <block argument> of type '!fir.box<!fir.array<?x?xi32>>' at index: 0 W:<block argument> of type '!fir.box<!fir.array<?x?xi32>>' at index: 0 |
| 103 |
!FUSE-NEXT: run 2 evaluate: forall/forall1/region_assign1 |