(root)/
gcc-13.2.0/
gcc/
testsuite/
c-c++-common/
goacc/
orphan-reductions-1.c
       1  /* Test orphan reductions.  */
       2  
       3  /* { dg-do compile } */
       4  
       5  #pragma acc routine seq
       6  int
       7  seq_reduction (int n)
       8  {
       9    int i, sum = 0;
      10  #pragma acc loop seq reduction(+:sum)
      11    for (i = 0; i < n; i++)
      12      sum = sum + 1;
      13  
      14    return sum;
      15  }
      16  
      17  #pragma acc routine gang
      18  int
      19  gang_reduction (int n)
      20  {
      21    int i, s1 = 0, s2 = 0;
      22  #pragma acc loop gang reduction(+:s1) /* { dg-error "gang reduction on an orphan loop" } */
      23    for (i = 0; i < n; i++)
      24      s1 = s1 + 2;
      25  
      26  #pragma acc loop gang reduction(+:s2) /* { dg-error "gang reduction on an orphan loop" } */
      27    for (i = 0; i < n; i++)
      28      s2 = s2 + 2;
      29  
      30  
      31    return s1 + s2;
      32  }
      33  
      34  #pragma acc routine worker
      35  int
      36  worker_reduction (int n)
      37  {
      38    int i, sum = 0;
      39  #pragma acc loop worker reduction(+:sum)
      40    for (i = 0; i < n; i++)
      41      sum = sum + 3;
      42  
      43    return sum;
      44  }
      45  
      46  #pragma acc routine vector
      47  int
      48  vector_reduction (int n)
      49  {
      50    int i, sum = 0;
      51  #pragma acc loop vector reduction(+:sum)
      52    for (i = 0; i < n; i++)
      53      sum = sum + 4;
      54  
      55    return sum;
      56  }