| 1 |
typedef enum omp_allocator_handle_t |
| 2 |
#if __cplusplus >= 201103L |
| 3 |
: __UINTPTR_TYPE__ |
| 4 |
#endif |
| 5 |
{ |
| 6 |
omp_null_allocator = 0, |
| 7 |
omp_default_mem_alloc = 1, |
| 8 |
omp_large_cap_mem_alloc = 2, |
| 9 |
omp_const_mem_alloc = 3, |
| 10 |
omp_high_bw_mem_alloc = 4, |
| 11 |
omp_low_lat_mem_alloc = 5, |
| 12 |
omp_cgroup_mem_alloc = 6, |
| 13 |
omp_pteam_mem_alloc = 7, |
| 14 |
omp_thread_mem_alloc = 8, |
| 15 |
__omp_allocator_handle_t_max__ = __UINTPTR_MAX__ |
| 16 |
} omp_allocator_handle_t; |
| 17 |
|
| 18 |
int bar (int, int *, int); |
| 19 |
omp_allocator_handle_t baz (void); |
| 20 |
|
| 21 |
void |
| 22 |
foo (int x, int z) |
| 23 |
{ |
| 24 |
int y[16] = { 0 }, r = 0, i; |
| 25 |
omp_allocator_handle_t h = baz (); |
| 26 |
#pragma omp parallel allocate (x) allocate (omp_default_mem_alloc : y) \ |
| 27 |
allocate ((omp_allocator_handle_t) omp_default_mem_alloc:z) firstprivate (x, y, z) |
| 28 |
bar (x, y, z); |
| 29 |
#pragma omp task private (x) firstprivate (z) allocate (omp_low_lat_mem_alloc:x,z) |
| 30 |
bar (0, &x, z); |
| 31 |
#pragma omp taskwait |
| 32 |
#pragma omp target teams distribute parallel for private (x) firstprivate (y) \ |
| 33 |
allocate ((omp_allocator_handle_t)(omp_default_mem_alloc + 0):z) \ |
| 34 |
allocate (omp_default_mem_alloc: x, y) allocate (omp_low_lat_mem_alloc: r) \ |
| 35 |
lastprivate (z) reduction(+:r) |
| 36 |
for (i = 0; i < 64; i++) |
| 37 |
{ |
| 38 |
z = bar (0, &x, 0); |
| 39 |
r += bar (1, y, 0); |
| 40 |
} |
| 41 |
#pragma omp single private (x) allocate (h:x) |
| 42 |
; |
| 43 |
#pragma omp single allocate (*&h : x) private (x) |
| 44 |
; |
| 45 |
#pragma omp parallel shared (r, x, z) |
| 46 |
#pragma omp single firstprivate (r) allocate (x, r, z) private (x, z) |
| 47 |
; |
| 48 |
#pragma omp for allocate (x) private (x) |
| 49 |
for (i = 0; i < 64; i++) |
| 50 |
x = 1; |
| 51 |
#pragma omp sections private (x) allocate (omp_low_lat_mem_alloc: x) |
| 52 |
{ |
| 53 |
x = 1; |
| 54 |
#pragma omp section |
| 55 |
x = 2; |
| 56 |
#pragma omp section |
| 57 |
x = 3; |
| 58 |
} |
| 59 |
#pragma omp taskgroup task_reduction(+:r) allocate (omp_default_mem_alloc : r) |
| 60 |
#pragma omp task in_reduction(+:r) allocate (omp_default_mem_alloc : r) |
| 61 |
r += bar (r, &r, 0); |
| 62 |
#pragma omp teams private (x) firstprivate (y) allocate (h : x, y) |
| 63 |
bar (x, y, 0); |
| 64 |
#pragma omp taskloop lastprivate (x) reduction (+:r) allocate (h : x, r) |
| 65 |
for (i = 0; i < 16; i++) |
| 66 |
{ |
| 67 |
r += bar (0, &r, 0); |
| 68 |
x = i; |
| 69 |
} |
| 70 |
#pragma omp taskgroup task_reduction(+:r) allocate (omp_default_mem_alloc : r) |
| 71 |
#pragma omp taskloop firstprivate (x) in_reduction (+:r) \ |
| 72 |
allocate (omp_default_mem_alloc : x, r) |
| 73 |
for (i = 0; i < 16; i++) |
| 74 |
r += bar (x, &r, 0); |
| 75 |
#pragma omp taskwait |
| 76 |
} |
| 77 |
|
| 78 |
void |
| 79 |
qux (const omp_allocator_handle_t h) |
| 80 |
{ |
| 81 |
int x = 0; |
| 82 |
#pragma omp parallel firstprivate (x) allocate (h: x) |
| 83 |
x = 1; |
| 84 |
} |