1 // RUN: %libomptarget-compilexx-run-and-check-aarch64-unknown-linux-gnu 2 // RUN: %libomptarget-compilexx-run-and-check-powerpc64-ibm-linux-gnu 3 // RUN: %libomptarget-compilexx-run-and-check-powerpc64le-ibm-linux-gnu 4 // RUN: %libomptarget-compilexx-run-and-check-x86_64-pc-linux-gnu 5 // RUN: %libomptarget-compilexx-run-and-check-nvptx64-nvidia-cuda 6 7 #include <cassert> 8 #include <iostream> 9 main(int argc,char * argv[])10int main(int argc, char *argv[]) { 11 constexpr const int num_threads = 64, N = 128; 12 int array[num_threads] = {0}; 13 14 #pragma omp parallel for 15 for (int i = 0; i < num_threads; ++i) { 16 int tmp[N]; 17 18 for (int j = 0; j < N; ++j) { 19 tmp[j] = i; 20 } 21 22 #pragma omp target teams distribute parallel for map(tofrom : tmp) 23 for (int j = 0; j < N; ++j) { 24 tmp[j] += j; 25 } 26 27 for (int j = 0; j < N; ++j) { 28 array[i] += tmp[j]; 29 } 30 } 31 32 // Verify 33 for (int i = 0; i < num_threads; ++i) { 34 const int ref = (0 + N - 1) * N / 2 + i * N; 35 assert(array[i] == ref); 36 } 37 38 std::cout << "PASS\n"; 39 40 return 0; 41 } 42 43 // CHECK: PASS 44