1 // RUN: %libomp-compile-and-run
7 omp_alloctrait_t at
[2];
8 omp_allocator_handle_t a
;
9 omp_allocator_handle_t f_a
;
12 at
[0].key
= omp_atk_pool_size
;
13 at
[0].value
= 2 * 1024 * 1024;
14 at
[1].key
= omp_atk_fallback
;
15 at
[1].value
= omp_atv_default_mem_fb
;
17 a
= omp_init_allocator(omp_large_cap_mem_space
, 2, at
);
18 f_a
= omp_init_allocator(omp_default_mem_space
, 2, at
);
19 printf("allocator large created: %p\n", (void *)a
);
20 printf("allocator default created: %p\n", (void *)f_a
);
22 #pragma omp parallel num_threads(2)
24 int i
= omp_get_thread_num();
25 ptr
[i
] = omp_alloc(1024 * 1024, f_a
);
27 nptr
[i
] = omp_realloc(ptr
[i
], 1024 * 1024, a
, f_a
);
29 printf("th %d, nptr %p\n", i
, nptr
[i
]);
32 // Both pointers should be non-NULL
33 if (nptr
[0] != NULL
&& nptr
[1] != NULL
) {
37 printf("failed: pointers %p %p\n", nptr
[0], nptr
[1]);