5 struct S
{ int a
, b
; };
8 foo (int x
, int *p
, int *q
, int px
, omp_allocator_handle_t h
, int fl
)
10 int y
= 0, r
= 0, i
, i1
, l
, l2
[4], l3
, n
= 8;
11 int i2
, j2
, n2
= 9, l4
;
12 int i3
, j3
, n3
= 10, l5
;
13 int i4
, j4
, n4
= 11, l6
;
16 int r2
[4] = { 0, 0, 0, 0 };
18 struct S s
= { 27, 29 };
19 for (i
= 0; i
< 4; i
++)
21 for (i
= 0; i
< 3; i
++)
23 for (i
= 0; i
< x
; i
++)
25 #pragma omp parallel private (y, v) firstprivate (x) allocate (align (32) : x) allocate (align (128) : y) allocate (v)
27 int *volatile p1
= &x
;
28 int *volatile p2
= &y
;
37 if (x
!= 43 || y
!= 1)
39 if (v
[0] != 7 || v
[41] != 8)
41 if ((fl
& 2) && (((uintptr_t) p1
| (uintptr_t) p2
42 | (uintptr_t) &v
[0]) & 63) != 0)
44 if ((((uintptr_t) p1
) & 31) != 0)
46 if ((((uintptr_t) p2
) & 127) != 0)
51 #pragma omp parallel private (y) firstprivate (x, w) allocate (allocator (h), align (32) : x) allocate (align (128), allocator (h):y) allocate(allocator(h):w)
53 int *volatile p1
= &x
;
54 int *volatile p2
= &y
;
55 if (x
!= 42 || w
[17] != 17 || w
[41] != 41)
62 if (x
!= 43 || y
!= 1 || w
[19] != 20)
64 if ((fl
& 1) && (((uintptr_t) p1
| (uintptr_t) p2
65 | (uintptr_t) &w
[0]) & 63) != 0)
67 if ((((uintptr_t) p1
) & 31) != 0)
69 if ((((uintptr_t) p2
) & 127) != 0)
73 #pragma omp parallel for private (y) firstprivate (x) allocate (allocator (h), align (32) : x, y, r) allocate (align (128), allocator (h) : l, n) reduction(+: r) lastprivate (l) linear (n: 16)
74 for (i
= 0; i
< 64; i
++)
82 if ((fl
& 1) && (((uintptr_t) &x
| (uintptr_t) &y
| (uintptr_t) &r
83 | (uintptr_t) &l
| (uintptr_t) &n
) & 63) != 0)
85 if ((((uintptr_t) &x
| (uintptr_t) &y
| (uintptr_t) &r
) & 31) != 0)
87 if ((((uintptr_t) &l
| (uintptr_t) &n
) & 127) != 0)
93 #pragma omp for lastprivate (l2) private (i1) allocate (allocator (h): l2, l3) allocate (allocator (h),align(16): i1) lastprivate (conditional: l3)
94 for (i1
= 0; i1
< 64; i1
++)
102 if ((fl
& 1) && (((uintptr_t) &l2
[0] | (uintptr_t) &l3
| (uintptr_t) &i1
) & 63) != 0)
104 if ((((uintptr_t) &i1
) & 15) != 0)
107 #pragma omp for collapse(2) lastprivate(l4, i2, j2) linear (n2:17) allocate (allocator (h), align (8): n2, l4, i2, j2)
108 for (i2
= 3; i2
< 5; i2
++)
109 for (j2
= 17; j2
< 22; j2
+= 2)
113 if ((fl
& 1) && (((uintptr_t) &l4
| (uintptr_t) &n2
114 | (uintptr_t) &i2
| (uintptr_t) &j2
) & 63) != 0)
116 if ((((uintptr_t) &l4
| (uintptr_t) &n2
| (uintptr_t) &i2
| (uintptr_t) &j2
) & 7) != 0)
119 #pragma omp for collapse(2) lastprivate(l5, i3, j3) linear (n3:17) schedule (static, 3) allocate (align (16): n3, l5, i3, j3)
120 for (i3
= 3; i3
< 5; i3
++)
121 for (j3
= 17; j3
< 23; j3
+= 2)
125 if ((fl
& 2) && (((uintptr_t) &l5
| (uintptr_t) &n3
126 | (uintptr_t) &i3
| (uintptr_t) &j3
) & 63) != 0)
128 if ((((uintptr_t) &l5
| (uintptr_t) &n3
| (uintptr_t) &i3
| (uintptr_t) &j3
) & 15) != 0)
131 #pragma omp for collapse(2) lastprivate(l6, i4, j4) linear (n4:17) schedule (dynamic) allocate (align (16), allocator (h): n4, l6, i4, j4)
132 for (i4
= 3; i4
< 5; i4
++)
133 for (j4
= 17; j4
< 22; j4
+= 2)
137 if ((fl
& 1) && (((uintptr_t) &l6
| (uintptr_t) &n4
138 | (uintptr_t) &i4
| (uintptr_t) &j4
) & 63) != 0)
140 if ((((uintptr_t) &l6
| (uintptr_t) &n4
| (uintptr_t) &i4
| (uintptr_t) &j4
) & 15) != 0)
143 #pragma omp for lastprivate (i5) allocate (align (32): i5)
144 for (i5
= 1; i5
< 17; i5
+= 3)
146 if ((fl
& 2) && (((uintptr_t) &i5
) & 63) != 0)
148 if ((((uintptr_t) &i5
) & 31) != 0)
151 #pragma omp for reduction(+:p[2:px], q[:3], r2) allocate(align (16), allocator (h): p, q, r2)
152 for (i
= 0; i
< 32; i
++)
160 /* Can't really rely on alignment of &p[0], the implementation could
161 allocate the whole array or do what GCC does and allocate only part
163 if ((fl
& 1) && (((uintptr_t) &q
[0] | (uintptr_t) &r2
[0]) & 63) != 0)
165 if ((((uintptr_t) &q
[0] | (uintptr_t) &r2
[0]) & 15) != 0)
168 #pragma omp task private(y) firstprivate(x) allocate(align (8) : x, y)
170 int *volatile p1
= &x
;
171 int *volatile p2
= &y
;
176 if (x
!= 43 || y
!= 21)
178 if ((fl
& 2) && (((uintptr_t) p1
| (uintptr_t) p2
) & 63) != 0)
180 if ((((uintptr_t) p1
| (uintptr_t) p2
) & 7) != 0)
183 #pragma omp task private(y) firstprivate(x) allocate(allocator (h),align(32): x, y)
185 int *volatile p1
= &x
;
186 int *volatile p2
= &y
;
191 if (x
!= 43 || y
!= 21)
193 if ((fl
& 1) && (((uintptr_t) p1
| (uintptr_t) p2
) & 63) != 0)
195 if ((((uintptr_t) p1
| (uintptr_t) p2
) & 31) != 0)
198 #pragma omp task private(y) firstprivate(s) allocate(align(16): s, y)
200 int *volatile p1
= &s
.a
;
201 int *volatile p2
= &s
.b
;
202 int *volatile p3
= &y
;
203 if (s
.a
!= 27 || s
.b
!= 29)
208 if (s
.a
!= 28 || s
.b
!= 30 || y
!= 21)
210 if ((fl
& 2) && (((uintptr_t) p1
| (uintptr_t) p3
) & 63) != 0)
212 if ((((uintptr_t) p1
| (uintptr_t) p3
) & 15) != 0)
215 #pragma omp task private(y) firstprivate(s) allocate(allocator (h): s, y)
217 int *volatile p1
= &s
.a
;
218 int *volatile p2
= &s
.b
;
219 int *volatile p3
= &y
;
220 if (s
.a
!= 27 || s
.b
!= 29)
225 if (s
.a
!= 28 || s
.b
!= 30 || y
!= 21)
227 if ((fl
& 1) && (((uintptr_t) p1
| (uintptr_t) p3
) & 63) != 0)
231 if (r
!= 64 * 63 / 2 || l
!= 63 || n
!= 8 + 16 * 64)
233 if (l2
[0] != 63 || l2
[1] != 63 + 1 || l2
[2] != 63 + 2 || l2
[3] != 63 + 3 || l3
!= 36)
235 if (i2
!= 5 || j2
!= 23 || n2
!= 9 + 6 * 17 || l4
!= 4 * 31 + 21)
237 if (i3
!= 5 || j3
!= 23 || n3
!= 10 + 6 * 17 || l5
!= 4 * 31 + 21)
239 if (i4
!= 5 || j4
!= 23 || n4
!= 11 + 6 * 17 || l6
!= 4 * 31 + 21)
243 if (p
[2] != (32 * 31) / 2 || p
[3] != 2 * (32 * 31) / 2
244 || q
[0] != 3 * (32 * 31) / 2 || q
[2] != 4 * (32 * 31) / 2
245 || r2
[0] != 5 * (32 * 31) / 2 || r2
[3] != 6 * (32 * 31) / 2)
249 #pragma omp parallel shared (x, y, r, n5) firstprivate (h)
252 n5
= omp_get_num_threads ();
253 #pragma omp scope private (y) firstprivate (x) reduction(+:r) \
254 allocate (allocator (h), align (32): x) \
255 allocate (align (128), allocator (h): y) \
256 allocate (align (32), allocator (h): r)
258 int *volatile p1
= &x
;
259 int *volatile p2
= &y
;
267 if (x
!= 43 || y
!= 1 || r
!= 1)
269 if ((fl
& 1) && (((uintptr_t) p1
| (uintptr_t) p2
270 | (uintptr_t) &r
) & 63) != 0)
272 if ((((uintptr_t) p1
| (uintptr_t) &r
) & 31) != 0)
274 if ((((uintptr_t) p2
) & 127) != 0)
278 if (x
!= 42 || r
!= n5
)
283 bar (int x
, omp_allocator_handle_t h
)
285 int y
= 0, r
= 0, i
, i1
, l
, l2
[4], l3
, n
= 8;
286 int i2
, j2
, n2
= 9, l4
;
287 int i3
, j3
, n3
= 10, l5
;
288 int i4
, j4
, n4
= 11, l6
;
290 struct S s
= { 27, 29 };
292 #pragma omp parallel private (y) firstprivate (x) allocate (x, y)
300 if (x
!= 43 || y
!= 1)
305 #pragma omp parallel private (y) firstprivate (x) allocate (allocator (h): x, y)
313 if (x
!= 43 || y
!= 1)
317 #pragma omp parallel for private (y) firstprivate (x) allocate (allocator (h): x, y, r, l, n) reduction(+: r) lastprivate (l) linear (n: 16)
318 for (i
= 0; i
< 64; i
++)
330 #pragma omp for lastprivate (l2) private (i1) allocate (allocator (h): l2, l3, i1) lastprivate (conditional: l3)
331 for (i1
= 0; i1
< 64; i1
++)
340 #pragma omp for collapse(2) lastprivate(l4, i2, j2) linear (n2:17) allocate (allocator (h): n2, l4, i2, j2)
341 for (i2
= 3; i2
< 5; i2
++)
342 for (j2
= 17; j2
< 22; j2
+= 2)
347 #pragma omp for collapse(2) lastprivate(l5, i3, j3) linear (n3:17) schedule (static, 3) allocate (n3, l5, i3, j3)
348 for (i3
= 3; i3
< 5; i3
++)
349 for (j3
= 17; j3
< 23; j3
+= 2)
354 #pragma omp for collapse(2) lastprivate(l6, i4, j4) linear (n4:17) schedule (dynamic) allocate (allocator (h): n4, l6, i4, j4)
355 for (i4
= 3; i4
< 5; i4
++)
356 for (j4
= 17; j4
< 22; j4
+= 2)
361 #pragma omp for lastprivate (i5) allocate (i5)
362 for (i5
= 1; i5
< 17; i5
+= 3)
364 #pragma omp task private(y) firstprivate(x) allocate(x, y)
370 if (x
!= 43 || y
!= 21)
373 #pragma omp task private(y) firstprivate(x) allocate(allocator (h): x, y)
379 if (x
!= 43 || y
!= 21)
382 #pragma omp task private(y) firstprivate(s) allocate(s, y)
384 if (s
.a
!= 27 || s
.b
!= 29)
389 if (s
.a
!= 28 || s
.b
!= 30 || y
!= 21)
392 #pragma omp task private(y) firstprivate(s) allocate(allocator (h), align (16): s, y)
394 if (s
.a
!= 27 || s
.b
!= 29)
399 if (s
.a
!= 28 || s
.b
!= 30 || y
!= 21)
403 if (r
!= 64 * 63 / 2 || l
!= 63 || n
!= 8 + 16 * 64)
405 if (l2
[0] != 63 || l2
[1] != 63 + 1 || l2
[2] != 63 + 2 || l2
[3] != 63 + 3 || l3
!= 36)
407 if (i2
!= 5 || j2
!= 23 || n2
!= 9 + 6 * 17 || l4
!= 4 * 31 + 21)
409 if (i3
!= 5 || j3
!= 23 || n3
!= 10 + 6 * 17 || l5
!= 4 * 31 + 21)
411 if (i4
!= 5 || j4
!= 23 || n4
!= 11 + 6 * 17 || l6
!= 4 * 31 + 21)
420 omp_alloctrait_t traits
[3]
421 = { { omp_atk_alignment
, 64 },
422 { omp_atk_fallback
, omp_atv_null_fb
} };
423 omp_allocator_handle_t a
424 = omp_init_allocator (omp_default_mem_space
, 2, traits
);
426 if (a
== omp_null_allocator
)
428 omp_set_default_allocator (omp_default_mem_alloc
);
429 foo (42, p
, q
, 2, omp_null_allocator
, 0);
430 foo (42, p
, q
, 2, omp_default_mem_alloc
, 0);
431 foo (42, p
, q
, 2, a
, 1);
432 omp_set_default_allocator (a
);
433 foo (42, p
, q
, 2, omp_null_allocator
, 3);
434 foo (42, p
, q
, 2, omp_default_mem_alloc
, 2);
436 omp_destroy_allocator (a
);