(root)/
gcc-13.2.0/
libgomp/
testsuite/
libgomp.oacc-c-c++-common/
deep-copy-9.c
       1  #include <stdlib.h>
       2  
       3  typedef struct {
       4    int *a;
       5    int *b;
       6  } mystruct;
       7  
       8  int
       9  main (int argc, char* argv[])
      10  {
      11    const int N = 1024;
      12    mystruct *m = (mystruct *) malloc (sizeof (*m));
      13    int i;
      14  
      15    m->a = (int *) malloc (N * sizeof (int));
      16    m->b = (int *) malloc (N * sizeof (int));
      17  
      18    for (i = 0; i < N; i++)
      19      {
      20        m->a[i] = 0;
      21        m->b[i] = 0;
      22      }
      23  
      24  #pragma acc enter data copyin(m[0:1])
      25  
      26    for (int i = 0; i < 99; i++)
      27      {
      28        int j;
      29        int *ptr = m->a;
      30  #pragma acc parallel loop copy(m->a[0:N])
      31        for (j = 0; j < N; j++)
      32  	m->a[j]++;
      33  #pragma acc parallel loop copy(m->b[0:N])
      34        for (j = 0; j < N; j++)
      35  	m->b[j]++;
      36      }
      37  
      38  #pragma acc exit data copyout(m[0:1])
      39  
      40    for (i = 0; i < N; i++)
      41      {
      42        if (m->a[i] != 99)
      43  	abort ();
      44        if (m->b[i] != 99)
      45  	abort ();
      46      }
      47  
      48    free (m->a);
      49    free (m->b);
      50    free (m);
      51  
      52    return 0;
      53  }