(root)/
gcc-13.2.0/
libgomp/
testsuite/
libgomp.oacc-c-c++-common/
kernels-private-vars-loop-gang-6.c
       1  /* Test of gang-private aggregate variable declared on loop directive, with
       2     broadcasting to partitioned workers.  */
       3  
       4  /* { dg-additional-options "--param=openacc-kernels=decompose" } */
       5  
       6  /* { dg-additional-options "-fopt-info-omp-all" }
       7     { dg-additional-options "-foffload=-fopt-info-omp-all" } */
       8  
       9  /* { dg-additional-options "--param=openacc-privatization=noisy" }
      10     { dg-additional-options "-foffload=--param=openacc-privatization=noisy" }
      11     Prune a few: uninteresting:
      12     { dg-prune-output {note: variable 'D\.[0-9]+' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} } */
      13  
      14  /* It's only with Tcl 8.5 (released in 2007) that "the variable 'varName'
      15     passed to 'incr' may be unset, and in that case, it will be set to [...]",
      16     so to maintain compatibility with earlier Tcl releases, we manually
      17     initialize counter variables:
      18     { dg-line l_dummy[variable c_compute 0 c_loop_i 0 c_loop_j 0 c_loop_k 0] }
      19     { dg-message "dummy" "" { target iN-VAl-Id } l_dummy } to avoid
      20     "WARNING: dg-line var l_dummy defined, but not used".  */
      21  
      22  #include <assert.h>
      23  
      24  typedef struct {
      25    int x, y, z;
      26    int attr[13];
      27  } vec3;
      28  
      29  int
      30  main (int argc, char* argv[])
      31  {
      32    int i, arr[32 * 32];
      33    vec3 pt;
      34  
      35    for (i = 0; i < 32 * 32; i++)
      36      arr[i] = i;
      37  
      38    #pragma acc kernels copy(arr)
      39    {
      40      /* { dg-note {forwarded loop nest in OpenACC 'kernels' region to 'parloops' for analysis} {} { target *-*-* } .+1 } */
      41      #pragma acc loop gang private(pt) /* { dg-line l_loop_i[incr c_loop_i] } */
      42      /* { dg-note {variable 'pt' in 'private' clause isn't candidate for adjusting OpenACC privatization level: not addressable} {} { target *-*-* } l_loop_i$c_loop_i } */
      43      /* { dg-note {variable 'i' in 'private' clause isn't candidate for adjusting OpenACC privatization level: not addressable} {} { target *-*-* } l_loop_i$c_loop_i } */
      44      /* { dg-note {variable 'j' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} {} { target *-*-* } l_loop_i$c_loop_i } */
      45      for (i = 0; i < 32; i++)
      46        {
      47          pt.x = i;
      48  	pt.y = i * 2;
      49  	pt.z = i * 4;
      50  	pt.attr[5] = i * 6;
      51  
      52  	#pragma acc loop worker /* { dg-line l_loop_j[incr c_loop_j] } */
      53  	/* { dg-note {variable 'j' in 'private' clause isn't candidate for adjusting OpenACC privatization level: not addressable} {} { target *-*-* } l_loop_j$c_loop_j } */
      54  	for (int j = 0; j < 32; j++)
      55  	  arr[i * 32 + j] += pt.x + pt.y + pt.z + pt.attr[5];
      56        }
      57      /* { dg-optimized {assigned OpenACC seq loop parallelism} {} { target *-*-* } l_loop_i$c_loop_i } */
      58    }
      59  
      60    for (i = 0; i < 32 * 32; i++)
      61      assert (arr[i] == i + (i / 32) * 13);
      62  
      63    return 0;
      64  }