| 1 | // RUN: %libomp-compile && env KMP_TOPOLOGY_METHOD=hwloc %libomp-run |
| 2 | // REQUIRES: hwloc |
| 3 | |
| 4 | #include <stdio.h> |
| 5 | #include <omp.h> |
| 6 | |
| 7 | int main() { |
| 8 | void *p[2]; |
| 9 | #pragma omp parallel num_threads(2) |
| 10 | { |
| 11 | int i = omp_get_thread_num(); |
| 12 | p[i] = omp_alloc(1024 * 1024, omp_get_default_allocator()); |
| 13 | #pragma omp barrier |
| 14 | printf(format: "th %d, ptr %p\n" , i, p[i]); |
| 15 | omp_free(p[i], omp_get_default_allocator()); |
| 16 | } |
| 17 | // Both pointers should be non-NULL |
| 18 | if (p[0] != NULL && p[1] != NULL) { |
| 19 | printf(format: "passed\n" ); |
| 20 | return 0; |
| 21 | } else { |
| 22 | printf(format: "failed: pointers %p %p\n" , p[0], p[1]); |
| 23 | return 1; |
| 24 | } |
| 25 | } |
| 26 | |