brintos

brintos / llvm-project-archived public Read only

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