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