i386: Add OPTION_MASK_ISA2_EVEX512 for some AVX512 instructions.
[official-gcc.git] / libgomp / testsuite / libgomp.fortran / alloc-11.f90
blobe85e2faa11e1750c170f2945d3c06d07d187c7eb
1 ! { dg-additional-sources alloc-7.c }
2 ! { dg-additional-options -Wno-complain-wrong-lang }
4 module m
5 use omp_lib
6 use iso_c_binding
7 implicit none
9 type (omp_alloctrait), parameter :: traits2(*) &
10 = [ omp_alloctrait (omp_atk_alignment, 16), &
11 omp_alloctrait (omp_atk_sync_hint, omp_atv_default), &
12 omp_alloctrait (omp_atk_access, omp_atv_default), &
13 omp_alloctrait (omp_atk_pool_size, 1024), &
14 omp_alloctrait (omp_atk_fallback, omp_atv_default_mem_fb), &
15 omp_alloctrait (omp_atk_partition, omp_atv_environment)]
16 type (omp_alloctrait) :: traits3(7) &
17 = [ omp_alloctrait (omp_atk_sync_hint, omp_atv_uncontended), &
18 omp_alloctrait (omp_atk_alignment, 32), &
19 omp_alloctrait (omp_atk_access, omp_atv_all), &
20 omp_alloctrait (omp_atk_pool_size, 512), &
21 omp_alloctrait (omp_atk_fallback, omp_atv_allocator_fb), &
22 omp_alloctrait (omp_atk_fb_data, 0), &
23 omp_alloctrait (omp_atk_partition, omp_atv_default)]
25 type (omp_alloctrait), parameter :: traits4(*) &
26 = [ omp_alloctrait (omp_atk_alignment, 128), &
27 omp_alloctrait (omp_atk_pool_size, 1024), &
28 omp_alloctrait (omp_atk_fallback, omp_atv_null_fb)]
30 interface
31 integer(c_int) function get__alignof_int () bind(C)
32 import :: c_int
33 end
34 end interface
35 end module m
37 program main
38 use m
39 implicit none (external, type)
40 type(c_ptr) :: p, q, r
41 integer, pointer, contiguous :: ip(:), iq(:), ir(:)
42 type (omp_alloctrait) :: traits(3)
43 type (omp_alloctrait) :: traits5(2)
44 integer (omp_allocator_handle_kind) :: a, a2
45 integer (c_ptrdiff_t) :: iptr
47 traits = [ omp_alloctrait (omp_atk_alignment, 64), &
48 omp_alloctrait (omp_atk_fallback, omp_atv_null_fb), &
49 omp_alloctrait (omp_atk_pool_size, 4096)]
50 traits5 = [ omp_alloctrait (omp_atk_fallback, omp_atv_null_fb), &
51 omp_alloctrait (omp_atk_pool_size, 4096)]
53 p = omp_alloc (3 * c_sizeof (0), omp_default_mem_alloc)
54 call c_f_pointer (p, ip, [3])
55 if (mod (TRANSFER (p, iptr), get__alignof_int ()) /= 0) &
56 stop 1
57 ip(1) = 1
58 ip(2) = 2
59 ip(3) = 3
60 p = omp_realloc (p, 4 * c_sizeof (0), omp_default_mem_alloc, omp_default_mem_alloc)
61 call c_f_pointer (p, ip, [4])
62 if (mod (TRANSFER (p, iptr), get__alignof_int ()) /= 0 &
63 .or. ip(1) /= 1 .or. ip(2) /= 2 .or. ip(3) /= 3) &
64 stop 2
65 ip(1) = 4
66 ip(2) = 5
67 ip(3) = 6
68 ip(4) = 7
69 p = omp_realloc (p, 2 * c_sizeof (0), omp_default_mem_alloc, omp_default_mem_alloc)
70 call c_f_pointer (p, ip, [2])
71 if (mod (TRANSFER (p, iptr), get__alignof_int ()) /= 0 &
72 .or. ip(1) /= 4 .or. ip(2) /= 5) &
73 stop 3
74 ip(1) = 8
75 ip(2) = 9
76 if (c_associated (omp_realloc (p, 0_c_size_t, omp_null_allocator, omp_default_mem_alloc))) &
77 stop 4
78 p = omp_realloc (c_null_ptr, 2 * c_sizeof (0), omp_default_mem_alloc, omp_null_allocator)
79 call c_f_pointer (p, ip, [2])
80 if (mod (TRANSFER (p, iptr), get__alignof_int ()) /= 0) &
81 stop 5
82 ip(1) = 1
83 ip(2) = 2
84 p = omp_realloc (p, 5 * c_sizeof (0), omp_default_mem_alloc, omp_default_mem_alloc)
85 call c_f_pointer (p, ip, [5])
86 if (mod (TRANSFER (p, iptr), get__alignof_int ()) /= 0 &
87 .or. ip(1) /= 1 .or. ip(2) /= 2) &
88 stop 6
89 ip(1) = 3
90 ip(2) = 4
91 ip(3) = 5
92 ip(4) = 6
93 ip(5) = 7
94 call omp_free (p, omp_null_allocator)
95 call omp_set_default_allocator (omp_default_mem_alloc)
96 if (c_associated (omp_realloc (c_null_ptr, 0_c_size_t, omp_null_allocator, omp_null_allocator))) &
97 stop 7
98 p = omp_alloc (c_sizeof (0), omp_null_allocator)
99 call c_f_pointer (p, ip, [1])
100 if (mod (TRANSFER (p, iptr), get__alignof_int ()) /= 0) &
101 stop 8
102 ip(1) = 3
103 p = omp_realloc (p, 3 * c_sizeof (0), omp_null_allocator, omp_null_allocator)
104 call c_f_pointer (p, ip, [3])
105 if (mod (TRANSFER (p, iptr), get__alignof_int ()) /= 0 &
106 .or. ip(1) /= 3) &
107 stop 9
108 ip(1) = 4
109 ip(2) = 5
110 ip(3) = 6
111 if (c_associated (omp_realloc (p, 0_c_size_t, omp_null_allocator, omp_get_default_allocator ()))) &
112 stop 10
113 a = omp_init_allocator (omp_default_mem_space, 3, traits)
114 if (a == omp_null_allocator) &
115 stop 11
116 p = omp_alloc (c_sizeof (0), a)
117 call c_f_pointer (p, ip, [1])
118 if (mod (TRANSFER (p, iptr), 64) /= 0) &
119 stop 12
120 ip(1) = 7
121 p = omp_realloc (p, 3072_c_size_t, a, a)
122 call c_f_pointer (p, ip, [3072 / c_sizeof (0)])
123 if (mod (TRANSFER (p, iptr), 64) /= 0 &
124 .or. ip(1) /= 7) &
125 stop 13
126 ip(1) = 1
127 ip(3072 / c_sizeof (0)) = 2
128 q = omp_alloc (c_sizeof (0), a)
129 call c_f_pointer (q, iq, [1])
130 if (mod (TRANSFER (q, iptr), 64) /= 0) &
131 stop 14
132 iq(1) = 8
133 if (c_associated (omp_realloc (q, 3072_c_size_t, a, a))) &
134 stop 15
135 call omp_free (p, a)
136 call omp_free (q, a)
137 p = omp_alloc (c_sizeof (0), a)
138 call c_f_pointer (p, ip, [1])
139 ip(1) = 42
140 p = omp_realloc (p, 3072_c_size_t, a, a)
141 call c_f_pointer (p, ip, [3072 / c_sizeof (0)])
142 if (ip(1) /= 42) &
143 stop 16
144 ip(1) = 3
145 ip(3072 / c_sizeof (0)) = 4
146 ! ignore return value
147 r = omp_realloc (p, 0_c_size_t, omp_null_allocator, omp_null_allocator)
148 call omp_set_default_allocator (a)
149 if (omp_get_default_allocator () /= a) &
150 stop 17
151 p = omp_alloc (31_c_size_t, omp_null_allocator)
152 if (.not. c_associated (p)) &
153 stop 18
154 p = omp_realloc (p, 3072_c_size_t, omp_null_allocator, omp_null_allocator)
155 if (.not. c_associated (p)) &
156 stop 19
157 q = omp_alloc (c_sizeof (0), omp_null_allocator)
158 if (.not. c_associated (q)) &
159 stop 20
160 if (c_associated (omp_realloc (q, 3072_c_size_t, omp_null_allocator, omp_null_allocator))) &
161 stop 21
162 call omp_free (p, a)
163 call omp_free (q, a)
164 call omp_destroy_allocator (a)
166 a = omp_init_allocator (omp_default_mem_space, 2, traits5)
167 if (a == omp_null_allocator) &
168 stop 22
169 call omp_set_default_allocator (a)
170 if (omp_get_default_allocator () /= a) &
171 stop 23
172 p = omp_alloc (3071_c_size_t, omp_null_allocator)
173 if (.not. c_associated (p)) &
174 stop 24
175 p = omp_realloc (p, 3072_c_size_t, omp_null_allocator, omp_null_allocator)
176 if (.not. c_associated (p)) &
177 stop 25
178 q = omp_alloc (c_sizeof (0), omp_null_allocator)
179 if (.not. c_associated (q)) &
180 stop 26
181 if (c_associated (omp_realloc (q, 3072_c_size_t, omp_null_allocator, omp_null_allocator))) &
182 stop 27
183 call omp_free (p, a)
184 call omp_free (q, a)
185 call omp_destroy_allocator (a)
187 a = omp_init_allocator (omp_default_mem_space, size (traits2), traits2)
188 if (a == omp_null_allocator) &
189 stop 28
190 if (traits3(6)%key /= omp_atk_fb_data) &
191 stop 29
192 traits3(6)%value = a
193 a2 = omp_init_allocator (omp_default_mem_space, size (traits3), traits3)
194 if (a2 == omp_null_allocator) &
195 stop 30
196 p = omp_alloc (c_sizeof (0), a2)
197 call c_f_pointer (p, ip, [1])
198 if (mod (TRANSFER (p, iptr), 32) /= 0) &
199 stop 31
200 ip(1) = 84
201 p = omp_realloc (p, 380_c_size_t, a2, a2)
202 call c_f_pointer (p, ip, [380 / c_sizeof (0)])
203 if (mod (TRANSFER (p, iptr), 32) /= 0 &
204 .or. ip(1) /= 84) &
205 stop 32
206 ip(1) = 5
207 ip(380 / c_sizeof (0)) = 6
208 q = omp_alloc (c_sizeof (0), a2)
209 call c_f_pointer (q, iq, [1])
210 if (mod (TRANSFER (q, iptr), 32) /= 0) &
211 stop 33
212 iq(1) = 42
213 q = omp_realloc (q, 768_c_size_t, a2, a2)
214 call c_f_pointer (q, iq, [768 / c_sizeof (0)])
215 if (mod (TRANSFER (q, iptr), 16) /= 0 &
216 .or. iq(1) /= 42) &
217 stop 34
218 iq(1) = 7
219 iq(768 / c_sizeof (0)) = 8
220 r = omp_realloc (c_null_ptr, 512_c_size_t, a2, omp_null_allocator)
221 call c_f_pointer (r, ir, [512 / c_sizeof (0)])
222 if (mod (TRANSFER (r, iptr), get__alignof_int ()) /= 0) &
223 stop 35
224 ir(1) = 9
225 ir(512 / c_sizeof (0)) = 10
226 call omp_free (p, omp_null_allocator)
227 call omp_free (q, a2)
228 call omp_free (r, omp_null_allocator)
229 p = omp_alloc (c_sizeof (0), a2)
230 call c_f_pointer (p, ip, [1])
231 if (mod (TRANSFER (p, iptr), 32) /= 0) &
232 stop 36
233 ip(1) = 85
234 p = omp_realloc (p, 320_c_size_t, a, a2)
235 call c_f_pointer (p, ip, [320 / c_sizeof (0)])
236 if (mod (TRANSFER (p, iptr), 16) /= 0 &
237 .or. ip(1) /= 85) &
238 stop 37
239 ip(1) = 5
240 ip(320 / c_sizeof (0)) = 6
241 q = omp_alloc (c_sizeof (0), a)
242 call c_f_pointer (q, iq, [1])
243 if (mod (TRANSFER (q, iptr), 16) /= 0) &
244 stop 38
245 iq(1) = 43
246 q = omp_realloc (q, 320_c_size_t, a2, a)
247 call c_f_pointer (q, iq, [320 / c_sizeof (0)])
248 if (mod (TRANSFER (q, iptr), 32) /= 0 &
249 .or. iq(1) /= 43) &
250 stop 39
251 iq(1) = 44
252 iq(320 / c_sizeof (0)) = 8
253 q = omp_realloc (q, 568_c_size_t, a2, a2)
254 call c_f_pointer (q, iq, [568 / c_sizeof (0)])
255 if (mod (TRANSFER (q, iptr), 16) /= 0 &
256 .or. iq(1) /= 44) &
257 stop 40
258 iq(1) = 7
259 iq(568 / c_sizeof (0)) = 8
260 call omp_free (p, omp_null_allocator)
261 call omp_free (q, a2)
262 call omp_destroy_allocator (a2)
263 call omp_destroy_allocator (a)
265 a = omp_init_allocator (omp_default_mem_space, size (traits4), traits4)
266 if (a == omp_null_allocator) &
267 stop 41
268 if (traits3(6)%key /= omp_atk_fb_data) &
269 stop 1
270 traits3(6)%value = a
271 a2 = omp_init_allocator (omp_default_mem_space, size (traits3), traits3)
272 if (a2 == omp_null_allocator) &
273 stop 42
274 call omp_set_default_allocator (a2)
275 p = omp_realloc (c_null_ptr, 420_c_size_t, omp_null_allocator, omp_null_allocator)
276 call c_f_pointer (p, ip, [420 / c_sizeof (0)])
277 if (mod (TRANSFER (p, iptr), 32) /= 0) &
278 stop 43
279 ip(1) = 5
280 ip(420 / c_sizeof (0)) = 6
281 q = omp_realloc (c_null_ptr, c_sizeof (0), omp_null_allocator, omp_null_allocator)
282 call c_f_pointer (q, iq, [1])
283 if (mod (TRANSFER (q, iptr), 32) /= 0) &
284 stop 44
285 iq(1) = 99
286 q = omp_realloc (q, 700_c_size_t, omp_null_allocator, omp_null_allocator)
287 call c_f_pointer (q, iq, [700 / c_sizeof (0)])
288 if (mod (TRANSFER (q, iptr), 128) /= 0 &
289 .or. iq(1) /= 99) &
290 stop 45
291 iq(1) = 7
292 iq(700 / c_sizeof (0)) = 8
293 if (c_associated (omp_realloc (c_null_ptr, 768_c_size_t, omp_null_allocator, omp_null_allocator))) &
294 stop 46
295 call omp_free (p, omp_null_allocator)
296 if (c_associated (omp_realloc (q, 0_c_size_t, omp_null_allocator, omp_null_allocator))) &
297 stop 47
298 call omp_free (c_null_ptr, omp_null_allocator)
299 call omp_free (c_null_ptr, omp_null_allocator)
300 call omp_destroy_allocator (a2)
301 call omp_destroy_allocator (a)
302 end program main