(root)/
gcc-13.2.0/
libgomp/
testsuite/
libgomp.c-c++-common/
target-in-reduction-1.c
       1  void
       2  foo (int x, int *y, int n, int v)
       3  {
       4    int z[3] = { 45, 46, 47 };
       5    int u[n], w[n], i;
       6    for (i = 0; i < n; i++)
       7      w[i] = u[i] = n + i;
       8    #pragma omp taskgroup task_reduction (+: x, y[:2], z[1:2], u, w[1:v])
       9    {
      10      #pragma omp task in_reduction (+: x, y[:2], z[1:2], u, w[1:v])
      11      {
      12        x++;
      13        y[0] += 2;
      14        y[1] += 3;
      15        z[1] += 4;
      16        u[0] += 5;
      17        w[1] += 6;
      18      }
      19      #pragma omp target in_reduction (+: x, y[:2], z[1:2], u, w[1:v])
      20      {
      21        x += 4;
      22        y[0] += 5;
      23        y[1] += 6;
      24        z[2] += 7;
      25        u[1] += 8;
      26        w[2] += 7;
      27      }
      28      #pragma omp target in_reduction (+: x, y[:v], z[1:v], u, w[1:2])
      29      {
      30        x += 9;
      31        y[0] += 10;
      32        y[1] += 11;
      33        z[1] += 12;
      34        u[2] += 13;
      35        w[1] += 14;
      36      }
      37    }
      38    if (x != 56 || y[0] != 60 || y[1] != 64)
      39      __builtin_abort ();
      40    if (z[0] != 45 || z[1] != 62 || z[2] != 54)
      41      __builtin_abort ();
      42    if (u[0] != 8 || u[1] != 12 || u[2] != 18)
      43      __builtin_abort ();
      44    if (w[0] != 3 || w[1] != 24 || w[2] != 12)
      45      __builtin_abort ();
      46  }
      47  
      48  void
      49  bar (int x, int *y, int n, int v)
      50  {
      51    int z[3] = { 45, 46, 47 };
      52    int u[n], w[n], i;
      53    for (i = 0; i < n; i++)
      54      w[i] = u[i] = n + i;
      55    #pragma omp parallel master
      56    #pragma omp taskgroup task_reduction (+: x, y[:2], z[1:2], u, w[1:v])
      57    {
      58      #pragma omp task in_reduction (+: x, y[:2], z[1:2], u, w[1:v])
      59      {
      60        x++;
      61        y[0] += 2;
      62        y[1] += 3;
      63        z[1] += 4;
      64        u[0] += 5;
      65        w[1] += 6;
      66      }
      67      #pragma omp target in_reduction (+: x, y[:2], z[1:2], u, w[1:v])
      68      {
      69        x += 4;
      70        y[0] += 5;
      71        y[1] += 6;
      72        z[2] += 7;
      73        u[1] += 8;
      74        w[2] += 7;
      75      }
      76      #pragma omp target in_reduction (+: x, y[:v], z[1:v], u, w[1:2])
      77      {
      78        x += 9;
      79        y[0] += 10;
      80        y[1] += 11;
      81        z[1] += 12;
      82        u[2] += 13;
      83        w[1] += 14;
      84      }
      85    }
      86    if (x != 56 || y[0] != 77 || y[1] != 84)
      87      __builtin_abort ();
      88    if (z[0] != 45 || z[1] != 62 || z[2] != 54)
      89      __builtin_abort ();
      90    if (u[0] != 8 || u[1] != 12 || u[2] != 18)
      91      __builtin_abort ();
      92    if (w[0] != 3 || w[1] != 24 || w[2] != 12)
      93      __builtin_abort ();
      94  }
      95  
      96  int
      97  main ()
      98  {
      99    int y[2] = { 43, 44 };
     100    #pragma omp parallel master
     101    foo (42, y, 3, 2);
     102    bar (42, y, 3, 2);
     103    return 0;
     104  }