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 *device_ptr = 11 omp_alloc(N * sizeof(int), llvm_omp_target_device_mem_alloc); 12 13 #pragma omp target teams distribute parallel for is_device_ptr(device_ptr) 14 for (int i = 0; i < N; ++i) { 15 device_ptr[i] = 1; 16 } 17 18 int sum = 0; 19 #pragma omp target reduction(+ : sum) is_device_ptr(device_ptr) 20 for (int i = 0; i < N; ++i) 21 sum += device_ptr[i]; 22 23 // CHECK: PASS 24 if (sum == N) 25 printf("PASS\n"); 26 27 omp_free(device_ptr, llvm_omp_target_device_mem_alloc); 28 } 29