(root)/
gcc-13.2.0/
libgomp/
testsuite/
libgomp.oacc-c-c++-common/
deep-copy-7.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  
      21    for (k = 0; k < 16; k++)
      22      {
      23        /* Here, we do not explicitly copy the enclosing structure, but work
      24  	 with fields directly.  Make sure attachment counters and reference
      25  	 counters work properly in that case.  */
      26  #pragma acc enter data copyin(v.a, v.b[0:n])
      27  #pragma acc enter data pcopyin(v.b[0:n])
      28  #pragma acc enter data pcopyin(v.b[0:n])
      29  
      30  #pragma acc parallel loop present(v.a, v.b)
      31        for (i = 0; i < n; i++)
      32  	v.b[i] = v.a + i;
      33  
      34  #pragma acc exit data copyout(v.b[:n]) finalize
      35  #pragma acc exit data delete(v.a)
      36  
      37        for (i = 0; i < n; i++)
      38  	assert (v.b[i] == v.a + i);
      39  
      40        assert (!acc_is_present (&v, sizeof (v)));
      41        assert (!acc_is_present (v.b, sizeof (int) * n));
      42      }
      43  
      44    return 0;
      45  }