LLVM OpenMP 22.0.0git
omp_alloc_hwloc.c
Go to the documentation of this file.
1// RUN: %libomp-compile && env KMP_TOPOLOGY_METHOD=hwloc %libomp-run
2// REQUIRES: hwloc
3
4#include <stdio.h>
5#include <omp.h>
6
7int 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("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("passed\n");
20 return 0;
21 } else {
22 printf("failed: pointers %p %p\n", p[0], p[1]);
23 return 1;
24 }
25}
void const char const char int ITT_FORMAT __itt_group_sync p
void omp_free(void *ptr, omp_allocator_handle_t allocator)
void * omp_alloc(size_t size, omp_allocator_handle_t allocator)
#define i
Definition kmp_stub.cpp:87
int main()