• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // RUN: %compile-run-and-check
2 
3 #include <omp.h>
4 #include <stdio.h>
5 
main()6 int main() {
7   int res = 0;
8 
9 #pragma omp parallel num_threads(2) reduction(+:res)
10   {
11     int tid = omp_get_thread_num();
12 #pragma omp target teams distribute reduction(+:res)
13     for (int i = tid; i < 2; i++)
14       ++res;
15   }
16   // The first thread makes 2 iterations, the second - 1. Expected result of the
17   // reduction res is 3.
18 
19   // CHECK: res = 3.
20   printf("res = %d.\n", res);
21   return 0;
22 }
23