Debian Codegraph @

gcc/testsuite/gfortran.dg/do_concurrent_13.f90

raw
1 ! { dg-do run }
2 ! { dg-additional-options "-fdump-tree-original" }
3
4 module m
5 implicit none
6 type t
7 integer :: y = 44
8 integer, pointer :: ptr(:) => null()
9 end type t
10
11 contains
12
13 subroutine sub(x, y)
14 integer :: i
15 type(t), pointer :: x, y(:)
16 type(t), pointer :: a, b(:)
17 logical :: error = .false.
18 integer, target :: tgt(6)
19 integer, target :: tgt2(7)
20
21 type(t), pointer :: x_saved
22 type(t), pointer :: y_saved(:)
23 type(t), pointer :: a_saved
24 type(t), pointer :: b_saved(:)
25
26 allocate(a, b(3))
27
28 x_saved => x
29 y_saved => y
30 a_saved => a
31 b_saved => b
32
33 x%y = 100
34 x%ptr => tgt
35 y(1)%y = 101
36 y(2)%y = 102
37 y(3)%y = 103
38 y(4)%y = 104
39 y(1)%ptr => tgt
40 y(2)%ptr => tgt
41 y(3)%ptr => tgt
42 y(4)%ptr => tgt
43
44 a%y = 105
45 a%ptr => tgt
46 b(1)%y = 106
47 b(2)%y = 107
48 b(3)%y = 108
49 b(1)%ptr => tgt
50 b(2)%ptr => tgt
51 b(3)%ptr => tgt
52
53 do concurrent (i = 1: 3) local_init(x,y,a,b) shared(error,tgt,tgt2,x_saved,y_saved,a_saved,b_saved) default(none)
54 if (.not.associated(x,x_saved)) error = .true.
55 if (.not.associated(y,y_saved)) error = .true.
56 if (.not.associated(a,a_saved)) error = .true.
57 if (.not.associated(b,b_saved)) error = .true.
58 if (x%y /= 100 &
59 .or. .not.associated (x%ptr, tgt) &
60 .or. y(1)%y /= 101 &
61 .or. y(2)%y /= 102 &
62 .or. y(3)%y /= 103 &
63 .or. y(4)%y /= 104 &
64 .or. .not.associated (y(1)%ptr, tgt) &
65 .or. .not.associated (y(2)%ptr, tgt) &
66 .or. .not.associated (y(3)%ptr, tgt) &
67 .or. .not.associated (y(4)%ptr, tgt) &
68 .or. a%y /= 105 &
69 .or. .not.associated (a%ptr, tgt) &
70 .or. b(1)%y /= 106 &
71 .or. b(2)%y /= 107 &
72 .or. b(3)%y /= 108 &
73 .or. .not.associated (b(1)%ptr, tgt) &
74 .or. .not.associated (b(2)%ptr, tgt) &
75 .or. .not.associated (b(3)%ptr, tgt)) &
76 error = .true.
77
78 if (i == 3) then
79 ! This is a hack - assuming no concurrency!
80 x%y = 900
81 y(1)%y = 901
82 a%y = 905
83 b(1)%y = 906
84 endif
85 x => null()
86 y => null()
87 a => null()
88 b => null()
89 end do
90
91 if (error) stop 1
92 if (.not.associated(x,x_saved)) stop 2
93 if (.not.associated(y,y_saved)) stop 3
94 if (.not.associated(a,a_saved)) stop 4
95 if (.not.associated(b,b_saved)) stop 5
96 ! Value a bit changed because of the hack above!
97 if (x%y /= 900 &
98 .or. .not.associated (x%ptr, tgt) &
99 .or. y(1)%y /= 901 &
100 .or. y(2)%y /= 102 &
101 .or. y(3)%y /= 103 &
102 .or. y(4)%y /= 104 &
103 .or. .not.associated (y(1)%ptr, tgt) &
104 .or. .not.associated (y(2)%ptr, tgt) &
105 .or. .not.associated (y(3)%ptr, tgt) &
106 .or. .not.associated (y(4)%ptr, tgt) &
107 .or. a%y /= 905 &
108 .or. .not.associated (a%ptr, tgt) &
109 .or. b(1)%y /= 906 &
110 .or. b(2)%y /= 107 &
111 .or. b(3)%y /= 108 &
112 .or. .not.associated (b(1)%ptr, tgt) &
113 .or. .not.associated (b(2)%ptr, tgt) &
114 .or. .not.associated (b(3)%ptr, tgt)) &
115 stop 6
116
117 ! Reset
118 x%y = 100
119 y(1)%y = 101
120 a%y = 105
121 b(1)%y = 106
122
123 do concurrent (i = 1: 3) local(x,y,a,b) shared(error) default(none)
124 x => null()
125 y => null()
126 a => null()
127 b => null()
128 end do
129
130 if (.not.associated(x,x_saved)) stop 7
131 if (.not.associated(y,y_saved)) stop 8
132 if (.not.associated(a,a_saved)) stop 9
133 if (.not.associated(b,b_saved)) stop 10
134 if (x%y /= 100 &
135 .or. .not.associated (x%ptr, tgt) &
136 .or. y(1)%y /= 101 &
137 .or. y(2)%y /= 102 &
138 .or. y(3)%y /= 103 &
139 .or. y(4)%y /= 104 &
140 .or. .not.associated (y(1)%ptr, tgt) &
141 .or. .not.associated (y(2)%ptr, tgt) &
142 .or. .not.associated (y(3)%ptr, tgt) &
143 .or. .not.associated (y(4)%ptr, tgt) &
144 .or. a%y /= 105 &
145 .or. .not.associated (a%ptr, tgt) &
146 .or. b(1)%y /= 106 &
147 .or. b(2)%y /= 107 &
148 .or. b(3)%y /= 108 &
149 .or. .not.associated (b(1)%ptr, tgt) &
150 .or. .not.associated (b(2)%ptr, tgt) &
151 .or. .not.associated (b(3)%ptr, tgt)) &
152 stop 11
153
154 do concurrent (i = 1: 3) local(x,y,a,b) shared(error,tgt,tgt2,x_saved,y_saved,a_saved,b_saved) default(none)
155 x => a_saved
156 y => b_saved
157 a => x_saved
158 b => y_saved
159 if (a%y /= 100 &
160 .or. .not.associated (a%ptr, tgt) &
161 .or. b(1)%y /= 101 &
162 .or. b(2)%y /= 102 &
163 .or. b(3)%y /= 103 &
164 .or. b(4)%y /= 104 &
165 .or. .not.associated (b(1)%ptr, tgt) &
166 .or. .not.associated (b(2)%ptr, tgt) &
167 .or. .not.associated (b(3)%ptr, tgt) &
168 .or. .not.associated (b(4)%ptr, tgt) &
169 .or. x%y /= 105 &
170 .or. .not.associated (x%ptr, tgt) &
171 .or. y(1)%y /= 106 &
172 .or. y(2)%y /= 107 &
173 .or. y(3)%y /= 108 &
174 .or. .not.associated (y(1)%ptr, tgt) &
175 .or. .not.associated (y(2)%ptr, tgt) &
176 .or. .not.associated (y(3)%ptr, tgt)) &
177 error = .true.
178 end do
179
180 if (.not.associated(x,x_saved)) stop 12
181 if (.not.associated(y,y_saved)) stop 13
182 if (.not.associated(a,a_saved)) stop 14
183 if (.not.associated(b,b_saved)) stop 15
184 if (x%y /= 100 &
185 .or. .not.associated (x%ptr, tgt) &
186 .or. y(1)%y /= 101 &
187 .or. y(2)%y /= 102 &
188 .or. y(3)%y /= 103 &
189 .or. y(4)%y /= 104 &
190 .or. .not.associated (y(1)%ptr, tgt) &
191 .or. .not.associated (y(2)%ptr, tgt) &
192 .or. .not.associated (y(3)%ptr, tgt) &
193 .or. .not.associated (y(4)%ptr, tgt) &
194 .or. a%y /= 105 &
195 .or. .not.associated (a%ptr, tgt) &
196 .or. b(1)%y /= 106 &
197 .or. b(2)%y /= 107 &
198 .or. b(3)%y /= 108 &
199 .or. .not.associated (b(1)%ptr, tgt) &
200 .or. .not.associated (b(2)%ptr, tgt) &
201 .or. .not.associated (b(3)%ptr, tgt)) &
202 stop 16
203 end
204 end
205
206 use m
207 implicit none
208 type(t), pointer :: q, r(:)
209 allocate(q, r(4))
210 call sub(q,r)
211 end