1 ! { dg-additional-sources alloc-7.c }
2 ! { dg-additional-options -Wno-complain-wrong-lang }
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
)]
31 integer(c_int
) function get__alignof_int () bind(C
)
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) &
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) &
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) &
76 if (c_associated (omp_realloc (p
, 0_c_size_t
, omp_null_allocator
, omp_default_mem_alloc
))) &
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) &
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) &
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
))) &
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) &
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 &
111 if (c_associated (omp_realloc (p
, 0_c_size_t
, omp_null_allocator
, omp_get_default_allocator ()))) &
113 a
= omp_init_allocator (omp_default_mem_space
, 3, traits
)
114 if (a
== omp_null_allocator
) &
116 p
= omp_alloc (c_sizeof (0), a
)
117 call c_f_pointer (p
, ip
, [1])
118 if (mod (TRANSFER (p
, iptr
), 64) /= 0) &
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 &
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) &
133 if (c_associated (omp_realloc (q
, 3072_c_size_t
, a
, a
))) &
137 p
= omp_alloc (c_sizeof (0), a
)
138 call c_f_pointer (p
, ip
, [1])
140 p
= omp_realloc (p
, 3072_c_size_t
, a
, a
)
141 call c_f_pointer (p
, ip
, [3072 / c_sizeof (0)])
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
) &
151 p
= omp_alloc (31_c_size_t
, omp_null_allocator
)
152 if (.not
. c_associated (p
)) &
154 p
= omp_realloc (p
, 3072_c_size_t
, omp_null_allocator
, omp_null_allocator
)
155 if (.not
. c_associated (p
)) &
157 q
= omp_alloc (c_sizeof (0), omp_null_allocator
)
158 if (.not
. c_associated (q
)) &
160 if (c_associated (omp_realloc (q
, 3072_c_size_t
, omp_null_allocator
, omp_null_allocator
))) &
164 call omp_destroy_allocator (a
)
166 a
= omp_init_allocator (omp_default_mem_space
, 2, traits5
)
167 if (a
== omp_null_allocator
) &
169 call omp_set_default_allocator (a
)
170 if (omp_get_default_allocator () /= a
) &
172 p
= omp_alloc (3071_c_size_t
, omp_null_allocator
)
173 if (.not
. c_associated (p
)) &
175 p
= omp_realloc (p
, 3072_c_size_t
, omp_null_allocator
, omp_null_allocator
)
176 if (.not
. c_associated (p
)) &
178 q
= omp_alloc (c_sizeof (0), omp_null_allocator
)
179 if (.not
. c_associated (q
)) &
181 if (c_associated (omp_realloc (q
, 3072_c_size_t
, omp_null_allocator
, omp_null_allocator
))) &
185 call omp_destroy_allocator (a
)
187 a
= omp_init_allocator (omp_default_mem_space
, size (traits2
), traits2
)
188 if (a
== omp_null_allocator
) &
190 if (traits3(6)%key /= omp_atk_fb_data
) &
193 a2
= omp_init_allocator (omp_default_mem_space
, size (traits3
), traits3
)
194 if (a2
== omp_null_allocator
) &
196 p
= omp_alloc (c_sizeof (0), a2
)
197 call c_f_pointer (p
, ip
, [1])
198 if (mod (TRANSFER (p
, iptr
), 32) /= 0) &
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 &
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) &
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 &
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) &
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) &
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 &
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) &
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 &
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 &
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
) &
268 if (traits3(6)%key /= omp_atk_fb_data
) &
271 a2
= omp_init_allocator (omp_default_mem_space
, size (traits3
), traits3
)
272 if (a2
== omp_null_allocator
) &
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) &
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) &
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 &
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
))) &
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
))) &
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
)