1 // RUN: %libomp-compile-and-run
8 omp_alloctrait_t at
[2];
9 omp_allocator_handle_t a
;
10 omp_allocator_handle_t f_a
;
13 at
[0].key
= omp_atk_pool_size
;
14 at
[0].value
= 2*1024*1024;
15 at
[1].key
= omp_atk_fallback
;
16 at
[1].value
= omp_atv_default_mem_fb
;
18 a
= omp_init_allocator(omp_large_cap_mem_space
, 2, at
);
19 f_a
= omp_init_allocator(omp_default_mem_space
, 2, at
);
20 printf("allocator large created: %p\n", (void *)a
);
21 printf("allocator default created: %p\n", (void *)f_a
);
23 #pragma omp parallel num_threads(2)
25 int i
= omp_get_thread_num();
26 ptr
[i
] = omp_alloc(1024 * 1024, f_a
);
28 nptr
[i
] = omp_realloc(ptr
[i
], 0, a
, f_a
);
30 printf("th %d, nptr %p\n", i
, nptr
[i
]);
34 // Both ptr pointers should be non-NULL
35 if (ptr
[0] == NULL
|| ptr
[1] == NULL
) {
36 printf("failed: pointers %p %p\n", ptr
[0], ptr
[1]);
39 // Both nptr pointers should be NULL
40 if (nptr
[0] != NULL
|| nptr
[1] != NULL
) {
41 printf("failed: pointers %p %p\n", nptr
[0], nptr
[1]);