1 // RUN: %libomptarget-compile-run-and-check-nvptx64-nvidia-cuda 2 // REQUIRES: nvptx64-nvidia-cuda 3 4 #include <omp.h> 5 #include <stdio.h> 6 main()7int main() { 8 const int N = 64; 9 10 int *hst_ptr = omp_alloc(N * sizeof(int), llvm_omp_target_host_mem_alloc); 11 12 for (int i = 0; i < N; ++i) 13 hst_ptr[i] = 2; 14 15 #pragma omp target teams distribute parallel for map(tofrom : hst_ptr [0:N]) 16 for (int i = 0; i < N; ++i) 17 hst_ptr[i] -= 1; 18 19 int sum = 0; 20 for (int i = 0; i < N; ++i) 21 sum += hst_ptr[i]; 22 23 omp_free(hst_ptr, llvm_omp_target_shared_mem_alloc); 24 // CHECK: PASS 25 if (sum == N) 26 printf("PASS\n"); 27 } 28