| 1 |
! This test case is expected to fail due to errors. |
| 2 |
|
| 3 |
module mm |
| 4 |
|
| 5 |
implicit none |
| 6 |
integer, parameter :: N = 30 |
| 7 |
integer, parameter :: M = 3 |
| 8 |
|
| 9 |
integer :: a(M,N), b(M,N), c(M,N) |
| 10 |
|
| 11 |
contains |
| 12 |
|
| 13 |
subroutine dostuff (index, flag) |
| 14 |
integer :: index, flag |
| 15 |
end subroutine |
| 16 |
|
| 17 |
! These functions should compile without error. |
| 18 |
subroutine good1 () |
| 19 |
integer :: i, j, x, shift |
| 20 |
|
| 21 |
x = 0 |
| 22 |
!$omp parallel do simd collapse(2) reduction(inscan,+: x) private(shift) |
| 23 |
do i = 1, N |
| 24 |
do j = 1, M |
| 25 |
x = x + a(j,i) |
| 26 |
x = x + b(j,i) |
| 27 |
!$omp scan inclusive(x) |
| 28 |
shift = i + 29*j |
| 29 |
c(j,i) = x + shift; |
| 30 |
end do |
| 31 |
end do |
| 32 |
end subroutine |
| 33 |
|
| 34 |
subroutine good2 () |
| 35 |
integer :: i, j, x, shift |
| 36 |
|
| 37 |
x = 0 |
| 38 |
!$omp parallel do simd collapse(2) reduction(inscan,+: x) private(shift) |
| 39 |
do i = 1, N |
| 40 |
do j = 1, M |
| 41 |
shift = i + 29*j |
| 42 |
c(j,i) = x + shift; |
| 43 |
!$omp scan exclusive(x) |
| 44 |
x = x + a(j,i) |
| 45 |
x = x + b(j,i) |
| 46 |
end do |
| 47 |
end do |
| 48 |
end subroutine |
| 49 |
|
| 50 |
! Adding intervening code should trigger an error. |
| 51 |
subroutine bad1 () |
| 52 |
integer :: i, j, x, shift |
| 53 |
|
| 54 |
x = 0 |
| 55 |
!$omp parallel do simd collapse(2) reduction(inscan,+: x) private(shift) ! { dg-error "inner loops must be perfectly nested" } |
| 56 |
do i = 1, N |
| 57 |
call dostuff (i, 0) |
| 58 |
do j = 1, M |
| 59 |
x = x + a(j,i) |
| 60 |
x = x + b(j,i) |
| 61 |
!$omp scan inclusive(x) |
| 62 |
shift = i + 29*j |
| 63 |
c(j,i) = x + shift; |
| 64 |
end do |
| 65 |
end do |
| 66 |
end subroutine |
| 67 |
|
| 68 |
subroutine bad2 () |
| 69 |
integer :: i, j, x, shift |
| 70 |
|
| 71 |
x = 0 |
| 72 |
!$omp parallel do simd collapse(2) reduction(inscan,+: x) private(shift) ! { dg-error "inner loops must be perfectly nested" } |
| 73 |
do i = 1, N |
| 74 |
do j = 1, M |
| 75 |
shift = i + 29*j |
| 76 |
c(j,i) = x + shift; |
| 77 |
!$omp scan exclusive(x) |
| 78 |
x = x + a(j,i) |
| 79 |
x = x + b(j,i) |
| 80 |
end do |
| 81 |
call dostuff (i, 1) |
| 82 |
end do |
| 83 |
end subroutine |
| 84 |
|
| 85 |
end module |