(root)/
gcc-13.2.0/
libgomp/
testsuite/
libgomp.oacc-c-c++-common/
deep-copy-6.c
       1  /* { dg-do run { target { ! openacc_host_selected } } } */
       2  
       3  #include <stdlib.h>
       4  #include <assert.h>
       5  #include <openacc.h>
       6  
       7  struct dc
       8  {
       9    int a;
      10    int **b;
      11  };
      12  
      13  int
      14  main ()
      15  {
      16    int n = 100, i, j, k;
      17    struct dc v = { .a = 3 };
      18  
      19    v.b = (int **) malloc (sizeof (int *) * n);
      20    for (i = 0; i < n; i++)
      21      v.b[i] = (int *) malloc (sizeof (int) * n);
      22  
      23    for (k = 0; k < 16; k++)
      24      {
      25  #pragma acc data copy(v)
      26        {
      27  #pragma acc data copy(v.b[:n])
      28  	{
      29  	  for (i = 0; i < n; i++)
      30  	    {
      31  	      acc_copyin (v.b[i], sizeof (int) * n);
      32  	      acc_attach ((void **) &v.b[i]);
      33  	    }
      34  
      35  #pragma acc parallel loop
      36  	  for (i = 0; i < n; i++)
      37  	    for (j = 0; j < n; j++)
      38  	      v.b[i][j] = v.a + i + j;
      39  
      40  	  for (i = 0; i < n; i++)
      41  	    {
      42  	      acc_detach ((void **) &v.b[i]);
      43  	      acc_copyout (v.b[i], sizeof (int) * n);
      44  	    }
      45  	}
      46        }
      47  
      48        for (i = 0; i < n; i++)
      49  	for (j = 0; j < n; j++)
      50  	  assert (v.b[i][j] == v.a + i + j);
      51  
      52        assert (!acc_is_present (&v, sizeof (v)));
      53        assert (!acc_is_present (v.b, sizeof (int *) * n));
      54        for (i = 0; i < n; i++)
      55  	assert (!acc_is_present (v.b[i], sizeof (int) * n));
      56      }
      57  
      58    return 0;
      59  }