(root)/
gcc-13.2.0/
libgomp/
testsuite/
libgomp.oacc-c-c++-common/
deep-copy-15.c
       1  #include <stdlib.h>
       2  
       3  /* Test multiple struct dereferences on one directive, and slices starting at
       4     non-zero.  */
       5  
       6  typedef struct {
       7    int *a;
       8    int *b;
       9    int *c;
      10  } mystruct;
      11  
      12  int main(int argc, char* argv[])
      13  {
      14    const int N = 1024;
      15    mystruct *m = (mystruct *) malloc (sizeof (*m));
      16    int i;
      17  
      18    m->a = (int *) malloc (N * sizeof (int));
      19    m->b = (int *) malloc (N * sizeof (int));
      20    m->c = (int *) malloc (N * sizeof (int));
      21  
      22    for (i = 0; i < N; i++)
      23      {
      24        m->a[i] = 0;
      25        m->b[i] = 0;
      26        m->c[i] = 0;
      27      }
      28  
      29    for (int i = 0; i < 99; i++)
      30      {
      31        int j;
      32  #pragma acc parallel loop copy(m->a[0:N])
      33        for (j = 0; j < N; j++)
      34  	m->a[j]++;
      35  #pragma acc parallel loop copy(m->b[0:N], m->c[5:N-10])
      36        for (j = 0; j < N; j++)
      37  	{
      38  	  m->b[j]++;
      39  	  if (j > 5 && j < N - 5)
      40  	    m->c[j]++;
      41  	}
      42      }
      43  
      44    for (i = 0; i < N; i++)
      45      {
      46        if (m->a[i] != 99)
      47  	abort ();
      48        if (m->b[i] != 99)
      49  	abort ();
      50        if (i > 5 && i < N-5)
      51  	{
      52  	  if (m->c[i] != 99)
      53  	    abort ();
      54  	}
      55        else
      56  	{
      57  	  if (m->c[i] != 0)
      58  	    abort ();
      59  	}
      60      }
      61  
      62    free (m->a);
      63    free (m->b);
      64    free (m->c);
      65    free (m);
      66  
      67    return 0;
      68  }