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