(root)/
gcc-13.2.0/
libgomp/
testsuite/
libgomp.oacc-c-c++-common/
loop-red-v-2.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  #include <stdio.h>
       8  #include <openacc.h>
       9  #include <gomp-constants.h>
      10  
      11  #define N (32*32*32+17)
      12  
      13  int main ()
      14  {
      15    int ix;
      16    int ondev = 0;
      17    int q = 0,  h = 0;
      18    int vectorsize;
      19  
      20  #define VL 32
      21  #pragma acc parallel vector_length(VL) copy(q) copy(ondev)
      22    /* { dg-note {variable 't' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } .-1 } */
      23    /* { dg-note {variable 'ix' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } .-2 } */
      24    {
      25      int t = q;
      26      
      27  #pragma acc loop vector reduction (+:t)
      28      /* { dg-note {variable 'ix' in 'private' clause isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } .-1 } */
      29      /* { dg-note {variable 'val' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } .-2 } */
      30      /* { dg-note {variable 'g' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } .-3 } */
      31      /* { dg-note {variable 'w' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } .-4 } */
      32      /* { dg-note {variable 'v' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } .-5 } */
      33      for (unsigned ix = 0; ix < N; ix++)
      34        {
      35  	int val = ix;
      36  	
      37  	if (acc_on_device (acc_device_not_host))
      38  	  {
      39  	    int g, w, v;
      40  
      41  	    g = __builtin_goacc_parlevel_id (GOMP_DIM_GANG);
      42  	    w = __builtin_goacc_parlevel_id (GOMP_DIM_WORKER);
      43  	    v = __builtin_goacc_parlevel_id (GOMP_DIM_VECTOR);
      44  	    val = (g << 16) | (w << 8) | v;
      45  	    ondev = 1;
      46  	  }
      47  	t += val;
      48        }
      49      q = t;
      50    }
      51    vectorsize = VL;
      52  #ifdef ACC_DEVICE_TYPE_radeon
      53    /* AMD GCN uses the autovectorizer for the vector dimension: the use
      54       of a function call in vector-partitioned code in this test is not
      55       currently supported.  */
      56    vectorsize = 1;
      57  #endif
      58  
      59    for (ix = 0; ix < N; ix++)
      60      {
      61        int val = ix;
      62        if (ondev)
      63  	{
      64  	  int g = 0;
      65  	  int w = 0;
      66  	  int v = ix % vectorsize;
      67  
      68  	  val = (g << 16) | (w << 8) | v;
      69  	}
      70        h += val;
      71      }
      72  
      73    if (q != h)
      74      {
      75        printf ("t=%x expected %x\n", q, h);
      76        return 1;
      77      }
      78    
      79    return 0;
      80  }