(root)/
gcc-13.2.0/
libgomp/
testsuite/
libgomp.oacc-c-c++-common/
declare-vla.c
       1  /* Verify OpenACC 'declare' with VLAs.  */
       2  
       3  /* { dg-additional-options "--param=openacc-kernels=decompose" } */
       4  
       5  /* { dg-additional-options "-fopt-info-omp-all" }
       6     { dg-additional-options "-foffload=-fopt-info-all-omp" } */
       7  
       8  /* { dg-additional-options "--param=openacc-privatization=noisy" }
       9     { dg-additional-options "-foffload=--param=openacc-privatization=noisy" }
      10     Prune a few: uninteresting, and potentially varying depending on GCC configuration (data types):
      11     { dg-prune-output {note: variable 'D\.[0-9]+' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} } */
      12  
      13  /* It's only with Tcl 8.5 (released in 2007) that "the variable 'varName'
      14     passed to 'incr' may be unset, and in that case, it will be set to [...]",
      15     so to maintain compatibility with earlier Tcl releases, we manually
      16     initialize counter variables:
      17     { dg-line l_dummy[variable c_compute 0] }
      18     { dg-message "dummy" "" { target iN-VAl-Id } l_dummy } to avoid
      19     "WARNING: dg-line var l_dummy defined, but not used".  */
      20  
      21  
      22  #include <assert.h>
      23  
      24  
      25  void
      26  f (void)
      27  {
      28    int N = 1000;
      29    int i, A[N];
      30  #pragma acc declare copy(A)
      31  
      32    for (i = 0; i < N; i++)
      33      A[i] = -i;
      34  
      35  #pragma acc kernels /* { dg-line l_compute[incr c_compute] } */
      36    /* { dg-note {OpenACC 'kernels' decomposition: variable 'i' in 'copy' clause requested to be made addressable} {} { target *-*-* } l_compute$c_compute }
      37       { dg-note {variable 'i' made addressable} {} { target *-*-* } l_compute$c_compute } */
      38    /* { dg-note {OpenACC 'kernels' decomposition: variable 'N' in 'copy' clause requested to be made addressable} {} { target *-*-* } l_compute$c_compute }
      39       { dg-note {variable 'N' made addressable} {} { target *-*-* } l_compute$c_compute } */
      40    /* { dg-optimized {assigned OpenACC seq loop parallelism} {} { target { ! __OPTIMIZE__ } } l_compute$c_compute }
      41       { dg-optimized {assigned OpenACC gang loop parallelism} {} { target __OPTIMIZE__ } l_compute$c_compute } */
      42    /* { dg-note {beginning 'parloops' part in OpenACC 'kernels' region} {} { target *-*-* } .+1 } */
      43    for (i = 0; i < N; i++)
      44      A[i] = i;
      45  
      46  #pragma acc update host(A)
      47  
      48    for (i = 0; i < N; i++)
      49      assert (A[i] == i);
      50  }
      51  
      52  
      53  /* The same as 'f' but everything contained in an OpenACC 'data' construct.  */
      54  
      55  void
      56  f_data (void)
      57  {
      58  #pragma acc data
      59    /* { dg-bogus {note: variable [^\n\r]+ candidate for adjusting OpenACC privatization level} {TODO 'data'} { xfail *-*-* } .-1 } */
      60    {
      61      int N = 1000;
      62      int i, A[N];
      63  # pragma acc declare copy(A)
      64  
      65      for (i = 0; i < N; i++)
      66        A[i] = -i;
      67  
      68  # pragma acc kernels /* { dg-line l_compute[incr c_compute] } */
      69      /* { dg-note {OpenACC 'kernels' decomposition: variable 'i' in 'copy' clause requested to be made addressable} {} { target *-*-* } l_compute$c_compute }
      70         { dg-note {variable 'i' made addressable} {} { target *-*-* } l_compute$c_compute } */
      71      /* { dg-note {OpenACC 'kernels' decomposition: variable 'N' in 'copy' clause requested to be made addressable} {} { target *-*-* } l_compute$c_compute }
      72         { dg-note {variable 'N' made addressable} {} { target *-*-* } l_compute$c_compute } */
      73      /* { dg-optimized {assigned OpenACC seq loop parallelism} {} { target { ! __OPTIMIZE__ } } l_compute$c_compute }
      74         { dg-optimized {assigned OpenACC gang loop parallelism} {} { target __OPTIMIZE__ } l_compute$c_compute } */
      75      /* { dg-note {beginning 'parloops' part in OpenACC 'kernels' region} {} { target *-*-* } .+1 } */
      76      for (i = 0; i < N; i++)
      77        A[i] = i;
      78  
      79  # pragma acc update host(A)
      80  
      81      for (i = 0; i < N; i++)
      82        assert (A[i] == i);
      83    }
      84  }
      85  
      86  
      87  int
      88  main ()
      89  {
      90    f ();
      91  
      92    f_data ();
      93  
      94    return 0;
      95  }