| 1 |
implicit none |
| 2 |
integer, parameter :: N = 30 |
| 3 |
integer, parameter :: M = 3 |
| 4 |
|
| 5 |
integer :: a(M,N), b(M,N), c(M,N) |
| 6 |
integer :: x, y, shift |
| 7 |
integer :: i, j |
| 8 |
|
| 9 |
do i = 1, N |
| 10 |
a(1,i) = i*32 |
| 11 |
a(2,i) = i*17 |
| 12 |
a(3,i) = i*11 |
| 13 |
b(1,i) = i*7 |
| 14 |
b(2,i) = i*5 |
| 15 |
b(3,i) = i*3 |
| 16 |
end do |
| 17 |
|
| 18 |
x = 0 |
| 19 |
!$omp parallel do simd collapse(2) reduction(inscan,+: x) private(shift) |
| 20 |
do i = 1, N |
| 21 |
do j = 1, M |
| 22 |
x = x + a(j,i) |
| 23 |
x = x + b(j,i) |
| 24 |
!$omp scan inclusive(x) |
| 25 |
shift = i + 29*j |
| 26 |
c(j,i) = x + shift; |
| 27 |
end do |
| 28 |
end do |
| 29 |
|
| 30 |
y = 0 |
| 31 |
do i = 1, N |
| 32 |
do j = 1, M |
| 33 |
y = y + a(j,i) + b(j,i) |
| 34 |
if (c(j,i) /= y + i + 29*j) error stop 1 |
| 35 |
end do |
| 36 |
end do |
| 37 |
if (x /= y) error stop 2 |
| 38 |
|
| 39 |
x = 0 |
| 40 |
!$omp parallel do simd collapse(2) reduction(inscan,+: x) private(shift) |
| 41 |
do i = 1, N |
| 42 |
do j = 1, M |
| 43 |
shift = i + 29*j |
| 44 |
c(j,i) = x + shift; |
| 45 |
!$omp scan exclusive(x) |
| 46 |
x = x + a(j,i) |
| 47 |
x = x + b(j,i) |
| 48 |
end do |
| 49 |
end do |
| 50 |
|
| 51 |
y = 0 |
| 52 |
do i = 1, N |
| 53 |
do j = 1, M |
| 54 |
if (c(j,i) /= y + i + 29*j) error stop 1 |
| 55 |
y = y + a(j,i) + b(j,i) |
| 56 |
end do |
| 57 |
end do |
| 58 |
if (x /= y) error stop 2 |
| 59 |
end |