xref: /llvm-project/offload/test/offloading/parallel_target_teams_reduction.cpp (revision 8823448807f3b1a1362d1417e062d763734e02f5)
1 // RUN: %libomptarget-compilexx-run-and-check-generic
2 // RUN: %libomptarget-compileoptxx-run-and-check-generic
3 
4 // FIXME: This is a bug in host offload, this should run fine.
5 // REQUIRES: gpu
6 
7 #include <iostream>
8 #include <vector>
9 
10 #define N 8
11 
main()12 int main() {
13   std::vector<int> avec(N);
14   int *a = avec.data();
15 #pragma omp parallel for
16   for (int i = 0; i < N; i++) {
17     a[i] = 0;
18 #pragma omp target teams distribute parallel for reduction(+ : a[i])
19     for (int j = 0; j < N; j++)
20       a[i] += 1;
21   }
22 
23   // CHECK: 8
24   // CHECK: 8
25   // CHECK: 8
26   // CHECK: 8
27   // CHECK: 8
28   // CHECK: 8
29   // CHECK: 8
30   // CHECK: 8
31   for (int i = 0; i < N; i++)
32     std::cout << a[i] << std::endl;
33 }
34