brintos

brintos / llvm-project-archived public Read only

0
0
Text · 672 B · c488669 Raw
29 lines · c
1// RUN: %libomptarget-compile-run-and-check-generic2// RUN: %libomptarget-compileopt-run-and-check-generic3 4#include <omp.h>5#include <stdio.h>6 7int main() {8  const int N = 64;9 10  // Allocates device managed memory that is shared between the host and device.11  int *shared_ptr =12      omp_alloc(N * sizeof(int), llvm_omp_target_shared_mem_alloc);13 14#pragma omp target teams distribute parallel for is_device_ptr(shared_ptr)15  for (int i = 0; i < N; ++i) {16    shared_ptr[i] = 1;17  }18 19  int sum = 0;20  for (int i = 0; i < N; ++i)21    sum += shared_ptr[i];22 23  // CHECK: PASS24  if (sum == N)25    printf("PASS\n");26 27  omp_free(shared_ptr, llvm_omp_target_shared_mem_alloc);28}29