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