(root)/
gcc-13.2.0/
libgomp/
testsuite/
libgomp.oacc-c-c++-common/
parallel-reduction.c
       1  /* { dg-additional-options "-fopt-info-note-omp" }
       2     { dg-additional-options "--param=openacc-privatization=noisy" }
       3     { dg-additional-options "-foffload=-fopt-info-note-omp" }
       4     { dg-additional-options "-foffload=--param=openacc-privatization=noisy" }
       5     for testing/documenting aspects of that functionality.  */
       6  
       7  /* { dg-additional-options "-Wopenacc-parallelism" } for testing/documenting
       8     aspects of that functionality.  */
       9  
      10  #include <stdlib.h>
      11  #include <openacc.h>
      12  
      13  #define N 10
      14  
      15  int
      16  main ()
      17  {
      18    int s1 = 0, s2 = 0;
      19    int i;
      20    int dummy = 0;
      21  
      22  #pragma acc data copy (dummy)
      23    {
      24  #pragma acc parallel num_gangs (N) reduction (+:s1) copy(s1)
      25      /* { dg-bogus "warning: region is gang partitioned but does not contain gang partitioned code" "TODO 'reduction'" { xfail *-*-* } .-1 } */
      26      {
      27        s1++;
      28      }
      29    }
      30  
      31    if (acc_get_device_type () == acc_device_host)
      32      {
      33        if (s1 != 1)
      34  	abort ();
      35      }
      36    else
      37      {
      38        if (s1 != N)
      39  	abort ();
      40      }
      41  
      42    s1 = 0;
      43    s2 = 0;
      44  
      45  #pragma acc parallel num_gangs (10) reduction (+:s1, s2) copy(s1, s2)
      46    /* { dg-bogus "warning: region is gang partitioned but does not contain gang partitioned code" "TODO 'reduction'" { xfail *-*-* } .-1 } */
      47    {
      48      s1++;
      49      s2 += N;
      50    }
      51  
      52    if (acc_get_device_type () == acc_device_host)
      53      {
      54        if (s1 != 1)
      55  	abort ();
      56        if (s2 != N)
      57  	abort ();
      58      }
      59    else
      60      {
      61        if (s1 != N)
      62  	abort ();
      63        if (s2 != N*N)
      64  	abort ();
      65      }
      66  
      67    s1 = 0;
      68  
      69  #pragma acc parallel num_gangs (10) reduction (+:s1) copy(s1)
      70    {
      71  #pragma acc loop gang reduction (+:s1)
      72      /* { dg-note {variable 'i' in 'private' clause isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } .-1 } */
      73      for (i = 0; i < 10; i++)
      74        s1++;
      75    }
      76  
      77    if (s1 != N)
      78      abort ();
      79  
      80    return 0;
      81  }