| 1 |
! { dg-additional-options "-fdump-tree-gimple" } |
| 2 |
|
| 3 |
! Test that reduction on compute construct implies a copy of the reduction variable |
| 4 |
|
| 5 |
subroutine test |
| 6 |
implicit none |
| 7 |
integer i |
| 8 |
integer a(100), s1, p1 |
| 9 |
integer r1 |
| 10 |
real b(100), s2 |
| 11 |
logical c(100), r2 |
| 12 |
double precision d(100), s3 |
| 13 |
complex e(100), s4 |
| 14 |
p1 = 1 |
| 15 |
|
| 16 |
!$acc parallel reduction(+:s1, s2, s3, s4) reduction(*:p1) |
| 17 |
do i = 1, 100 |
| 18 |
s1 = s1 + a(i) |
| 19 |
p1 = p1 * a(i) |
| 20 |
s2 = s2 + b(i) |
| 21 |
s3 = s3 + d(i) |
| 22 |
s4 = s4 + e(i) |
| 23 |
end do |
| 24 |
!$acc end parallel |
| 25 |
|
| 26 |
!$acc parallel reduction (max:r1) |
| 27 |
do i = 1,10 |
| 28 |
if (r1 <= a(i)) then |
| 29 |
r1 = a(i) |
| 30 |
end if |
| 31 |
end do |
| 32 |
!$acc end parallel |
| 33 |
|
| 34 |
!$acc parallel reduction (min:r1) |
| 35 |
do i = 1,10 |
| 36 |
if (r1 >= a(i)) then |
| 37 |
r1 = a(i) |
| 38 |
end if |
| 39 |
end do |
| 40 |
!$acc end parallel |
| 41 |
|
| 42 |
!$acc parallel reduction (iand:r1) |
| 43 |
do i = 1,10 |
| 44 |
r1 = iand (r1, a(i)) |
| 45 |
end do |
| 46 |
!$acc end parallel |
| 47 |
|
| 48 |
!$acc parallel reduction (ior:r1) |
| 49 |
do i = 1,10 |
| 50 |
r1 = ior (r1, a(i)) |
| 51 |
end do |
| 52 |
!$acc end parallel |
| 53 |
|
| 54 |
!$acc parallel reduction (ieor:r1) |
| 55 |
do i = 1,10 |
| 56 |
r1 = ieor (r1, a(i)) |
| 57 |
end do |
| 58 |
!$acc end parallel |
| 59 |
|
| 60 |
!$acc parallel reduction (.and.:r2) |
| 61 |
do i = 1,10 |
| 62 |
r2 = r2 .and. c(i) |
| 63 |
end do |
| 64 |
!$acc end parallel |
| 65 |
|
| 66 |
!$acc parallel reduction (.or.:r2) |
| 67 |
do i = 1,10 |
| 68 |
r2 = r2 .or. c(i) |
| 69 |
end do |
| 70 |
!$acc end parallel |
| 71 |
|
| 72 |
!$acc parallel reduction (.eqv.:r2) |
| 73 |
do i = 1,10 |
| 74 |
r2 = r2 .eqv. c(i) |
| 75 |
end do |
| 76 |
!$acc end parallel |
| 77 |
|
| 78 |
!$acc parallel reduction (.neqv.:r2) |
| 79 |
do i = 1,10 |
| 80 |
r2 = r2 .neqv. c(i) |
| 81 |
end do |
| 82 |
!$acc end parallel |
| 83 |
|
| 84 |
!$acc serial reduction(+:s1, s2, s3, s4) reduction(*:p1) |
| 85 |
do i = 1, 100 |
| 86 |
s1 = s1 + a(i) |
| 87 |
p1 = p1 * a(i) |
| 88 |
s2 = s2 + b(i) |
| 89 |
s3 = s3 + d(i) |
| 90 |
s4 = s4 + e(i) |
| 91 |
end do |
| 92 |
!$acc end serial |
| 93 |
|
| 94 |
!$acc serial reduction (max:r1) |
| 95 |
do i = 1,10 |
| 96 |
if (r1 <= a(i)) then |
| 97 |
r1 = a(i) |
| 98 |
end if |
| 99 |
end do |
| 100 |
!$acc end serial |
| 101 |
|
| 102 |
!$acc serial reduction (min:r1) |
| 103 |
do i = 1,10 |
| 104 |
if (r1 >= a(i)) then |
| 105 |
r1 = a(i) |
| 106 |
end if |
| 107 |
end do |
| 108 |
!$acc end serial |
| 109 |
|
| 110 |
!$acc serial reduction (iand:r1) |
| 111 |
do i = 1,10 |
| 112 |
r1 = iand (r1, a(i)) |
| 113 |
end do |
| 114 |
!$acc end serial |
| 115 |
|
| 116 |
!$acc serial reduction (ior:r1) |
| 117 |
do i = 1,10 |
| 118 |
r1 = ior (r1, a(i)) |
| 119 |
end do |
| 120 |
!$acc end serial |
| 121 |
|
| 122 |
!$acc serial reduction (ieor:r1) |
| 123 |
do i = 1,10 |
| 124 |
r1 = ieor (r1, a(i)) |
| 125 |
end do |
| 126 |
!$acc end serial |
| 127 |
|
| 128 |
!$acc serial reduction (.and.:r2) |
| 129 |
do i = 1,10 |
| 130 |
r2 = r2 .and. c(i) |
| 131 |
end do |
| 132 |
!$acc end serial |
| 133 |
|
| 134 |
!$acc serial reduction (.or.:r2) |
| 135 |
do i = 1,10 |
| 136 |
r2 = r2 .or. c(i) |
| 137 |
end do |
| 138 |
!$acc end serial |
| 139 |
|
| 140 |
!$acc serial reduction (.eqv.:r2) |
| 141 |
do i = 1,10 |
| 142 |
r2 = r2 .eqv. c(i) |
| 143 |
end do |
| 144 |
!$acc end serial |
| 145 |
|
| 146 |
!$acc serial reduction (.neqv.:r2) |
| 147 |
do i = 1,10 |
| 148 |
r2 = r2 .neqv. c(i) |
| 149 |
end do |
| 150 |
!$acc end serial |
| 151 |
|
| 152 |
end subroutine test |
| 153 |
|
| 154 |
! { dg-final { scan-tree-dump-times "map\\(tofrom:s1 \\\[len: \[0-9\]+\\\]\\)" 2 "gimple" } } |
| 155 |
! { dg-final { scan-tree-dump-times "map\\(tofrom:r1 \\\[len: \[0-9\]+\\\]\\)" 10 "gimple" } } |
| 156 |
! { dg-final { scan-tree-dump-times "map\\(tofrom:r2 \\\[len: \[0-9\]+\\\]\\)" 8 "gimple" } } |
| 157 |
! { dg-final { scan-tree-dump-times "map\\(tofrom:s2 \\\[len: \[0-9\]+\\\]\\)" 2 "gimple" } } |
| 158 |
! { dg-final { scan-tree-dump-times "map\\(tofrom:s3 \\\[len: \[0-9\]+\\\]\\)" 2 "gimple" } } |
| 159 |
! { dg-final { scan-tree-dump-times "map\\(tofrom:s4 \\\[len: \[0-9\]+\\\]\\)" 2 "gimple" } } |
| 160 |
! { dg-final { scan-tree-dump-times "map\\(tofrom:p1 \\\[len: \[0-9\]+\\\]\\)" 2 "gimple" } } |