1 // RUN: %libomp-compile-and-run
14 omp_alloctrait_t at
[3];
15 omp_allocator_handle_t a
;
17 at
[0].key
= omp_atk_pool_size
;
18 at
[0].value
= 16*1024*1024;
19 at
[1].key
= omp_atk_fallback
;
20 at
[1].value
= omp_atv_null_fb
;
21 a
= omp_init_allocator(omp_large_cap_mem_space
, 2, at
);
22 printf("allocator large created: %p\n", (void *)a
);
23 #pragma omp parallel num_threads(8)
25 int i
= omp_get_thread_num();
26 p
[i
] = omp_aligned_calloc(AL0
, 1024*128, 8, a
); // API's alignment only
28 printf("th %d, ptr %p\n", i
, p
[i
]);
29 if ((size_t)p
[i
] % AL0
) {
32 printf("Error param: th %d, ptr %p is not %d-byte aligned\n",
37 omp_destroy_allocator(a
);
38 at
[2].key
= omp_atk_alignment
;
40 a
= omp_init_allocator(omp_large_cap_mem_space
, 3, at
);
41 printf("allocator large aligned %d created: %p\n", AL1
, (void *)a
);
42 if (a
!= omp_null_allocator
)
43 #pragma omp parallel num_threads(8)
45 int i
= omp_get_thread_num();
46 p
[i
] = omp_aligned_calloc(AL0
, 1024*128, 8, a
); // allocator's alignment wins
48 printf("th %d, ptr %p\n", i
, p
[i
]);
49 if ((size_t)p
[i
] % AL1
) {
52 printf("Error allocator: th %d, ptr %p is not %d-byte aligned\n",
57 omp_destroy_allocator(a
);
58 at
[2].key
= omp_atk_alignment
;
60 a
= omp_init_allocator(omp_large_cap_mem_space
, 3, at
);
61 printf("allocator large aligned %d created: %p\n", AL0
, (void *)a
);
62 #pragma omp parallel num_threads(8)
64 int i
= omp_get_thread_num();
65 p
[i
] = omp_aligned_calloc(AL1
, 1024*128, 8, a
); // API's alignment wins
67 printf("th %d, ptr %p\n", i
, p
[i
]);
68 if ((size_t)p
[i
] % AL1
) {
71 printf("Error param: th %d, ptr %p is not %d-byte aligned\n",
76 omp_destroy_allocator(a
);