Debian Codegraph @

gcc/testsuite/gfortran.dg/goacc/routine-4.f90

raw
1 ! Test invalid calls to routines.
2
3 ! { dg-additional-options "-Wopenacc-parallelism" } for testing/documenting
4 ! aspects of that functionality.
5
6 module param
7 integer, parameter :: N = 32
8 end module param
9
10 program main
11 use param
12 integer :: i
13 integer :: a(N)
14
15 do i = 1, N
16 a(i) = i
17 end do
18
19 !
20 ! Seq routine tests.
21 !
22
23 !$acc parallel copy (a)
24 !$acc loop
25 do i = 1, N
26 call seq (a)
27 end do
28
29 !$acc loop gang
30 do i = 1, N
31 call seq (a)
32 end do
33
34 !$acc loop worker
35 do i = 1, N
36 call seq (a)
37 end do
38
39 !$acc loop vector
40 do i = 1, N
41 call seq (a)
42 end do
43 !$acc end parallel
44
45 !
46 ! Gang routines loops.
47 !
48
49 !$acc parallel copy (a)
50 !$acc loop ! { dg-warning "insufficient partitioning" }
51 do i = 1, N
52 call gang (a)
53 end do
54
55 !$acc loop gang ! { dg-message "containing loop" }
56 do i = 1, N
57 call gang (a) ! { dg-error "routine call uses same" }
58 end do
59
60 !$acc loop worker ! { dg-message "containing loop" }
61 do i = 1, N
62 call gang (a) ! { dg-error "routine call uses same" }
63 end do
64
65 !$acc loop vector ! { dg-message "containing loop" }
66 do i = 1, N
67 call gang (a) ! { dg-error "routine call uses same" }
68 end do
69 !$acc end parallel
70
71 !
72 ! Worker routines loops.
73 !
74
75 !$acc parallel copy (a)
76 !$acc loop
77 do i = 1, N
78 call worker (a)
79 end do
80
81 !$acc loop gang
82 do i = 1, N
83 call worker (a)
84 end do
85
86 !$acc loop worker ! { dg-message "containing loop" }
87 do i = 1, N
88 call worker (a) ! { dg-error "routine call uses same" }
89 end do
90
91 !$acc loop vector ! { dg-message "containing loop" }
92 do i = 1, N
93 call worker (a) ! { dg-error "routine call uses same" }
94 end do
95 !$acc end parallel
96
97 !
98 ! Vector routines loops.
99 !
100
101 !$acc parallel copy (a)
102 !$acc loop
103 do i = 1, N
104 call vector (a)
105 end do
106
107 !$acc loop gang
108 do i = 1, N
109 call vector (a)
110 end do
111
112 !$acc loop worker
113 do i = 1, N
114 call vector (a)
115 end do
116
117 !$acc loop vector ! { dg-message "containing loop" }
118 do i = 1, N
119 call vector (a) ! { dg-error "routine call uses same" }
120 end do
121 !$acc end parallel
122 contains
123
124 subroutine gang (a) ! { dg-message "declared here" 3 }
125 !$acc routine gang
126 ! { dg-warning "region is gang partitioned but does not contain gang partitioned code" "" { target *-*-* } .-2 }
127 ! { dg-warning "region is worker partitioned but does not contain worker partitioned code" "" { target *-*-* } .-3 }
128 ! { dg-warning "region is vector partitioned but does not contain vector partitioned code" "" { target *-*-* } .-4 }
129 integer, intent (inout) :: a(N)
130 integer :: i
131
132 do i = 1, N
133 a(i) = a(i) - a(i)
134 end do
135 end subroutine gang
136
137 subroutine worker (a) ! { dg-message "declared here" 2 }
138 !$acc routine worker
139 ! { dg-warning "region is worker partitioned but does not contain worker partitioned code" "" { target *-*-* } .-2 }
140 ! { dg-warning "region is vector partitioned but does not contain vector partitioned code" "" { target *-*-* } .-3 }
141 integer, intent (inout) :: a(N)
142 integer :: i
143
144 do i = 1, N
145 a(i) = a(i) - a(i)
146 end do
147 end subroutine worker
148
149 subroutine vector (a) ! { dg-message "declared here" }
150 !$acc routine vector
151 ! { dg-warning "region is vector partitioned but does not contain vector partitioned code" "" { target *-*-* } .-2 }
152 integer, intent (inout) :: a(N)
153 integer :: i
154
155 do i = 1, N
156 a(i) = a(i) - a(i)
157 end do
158 end subroutine vector
159
160 subroutine seq (a)
161 !$acc routine seq
162 integer, intent (inout) :: a(N)
163 integer :: i
164
165 do i = 1, N
166 a(i) = a(i) - a(i)
167 end do
168 end subroutine seq
169 end program main