brintos

brintos / llvm-project-archived public Read only

0
0
Text · 675 B · d036f95 Raw
39 lines · cpp
1// RUN: %libomptarget-compilexx-generic && \2// RUN:   env LIBOMPTARGET_STACK_SIZE=2048 %libomptarget-run-generic3// RUN: %libomptarget-compileoptxx-generic && \4// RUN:   env LIBOMPTARGET_STACK_SIZE=2048 %libomptarget-run-generic5 6// We need malloc/global_alloc support7// UNSUPPORTED: amdgcn-amd-amdhsa8 9#include <cassert>10#include <iostream>11 12void work(int *C) {13#pragma omp atomic14  ++(*C);15}16 17void use(int *C) {18#pragma omp parallel num_threads(2)19  work(C);20}21 22int main() {23  int C = 0;24#pragma omp target map(C)25  {26    use(&C);27#pragma omp parallel num_threads(2)28    use(&C);29  }30 31  assert(C >= 2 && C <= 6);32 33  std::cout << "PASS\n";34 35  return 0;36}37 38// CHECK: PASS39