1// RUN: %libomp-compile
2// RUN: env OMP_ALLOCATOR=omp_high_bw_mem_alloc %libomp-run
3// RUN: env OMP_ALLOCATOR=omp_default_mem_space %libomp-run
4// RUN: env OMP_ALLOCATOR=omp_large_cap_mem_space:alignment=16,pinned=true \
5// RUN: %libomp-run
6// RUN: env \
7// RUN: OMP_ALLOCATOR=omp_high_bw_mem_space:pool_size=1048576,fallback=allocator_fb,fb_data=omp_low_lat_mem_alloc \
8// RUN: %libomp-run
9
10#include <stdio.h>
11#include <omp.h>
12
13int main() {
14 void *p[2];
15#pragma omp parallel num_threads(2)
16 {
17 int i = omp_get_thread_num();
18 p[i] = omp_alloc(1024 * 1024, omp_get_default_allocator());
19#pragma omp barrier
20 printf(format: "th %d, ptr %p\n", i, p[i]);
21 omp_free(p[i], omp_get_default_allocator());
22 }
23 // Both pointers should be non-NULL
24 if (p[0] != NULL && p[1] != NULL) {
25 printf(format: "passed\n");
26 return 0;
27 } else {
28 printf(format: "failed: pointers %p %p\n", p[0], p[1]);
29 return 1;
30 }
31}
32

source code of openmp/runtime/test/env/omp51_alloc_env.c