brintos

brintos / llvm-project-archived public Read only

0
0
Text · 601 B · 7cdcae9 Raw
26 lines · c
1// RUN: %libomp-compile && env KMP_TOPOLOGY_METHOD=hwloc %libomp-run2// REQUIRES: hwloc3 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 barrier14    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-NULL18  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}26