1// RUN: %libomp-compile-and-run
2
3#include <stdio.h>
4#include <omp.h>
5
6int main()
7{
8 omp_alloctrait_t at[2];
9 omp_allocator_handle_t a;
10 void *p[2];
11 at[0].key = omp_atk_pool_size;
12 at[0].value = 2*1024*1024;
13 at[1].key = omp_atk_fallback;
14 at[1].value = omp_atv_default_mem_fb;
15 a = omp_init_allocator(omp_large_cap_mem_space, 2, at);
16 printf("allocator large created: %p\n", (void *)a);
17 #pragma omp parallel num_threads(2)
18 {
19 int i = omp_get_thread_num();
20 p[i] = omp_calloc(1024, 0, a);
21 #pragma omp barrier
22 printf(format: "th %d, ptr %p\n", i, p[i]);
23 omp_free(p[i], a);
24 }
25 // Both pointers should be NULL
26 if (p[0] == NULL && p[1] == NULL) {
27 printf(format: "passed\n");
28 return 0;
29 } else {
30 printf(format: "failed: pointers %p %p\n", p[0], p[1]);
31 return 1;
32 }
33}
34

source code of openmp/runtime/test/api/omp_calloc_size_0.c