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   int *c;
12   int *d;
13 };
14 
15 int
main()16 main ()
17 {
18   int n = 100, i, j, k;
19   struct dc v = { .a = 3 };
20 
21   v.b = (int *) malloc (sizeof (int) * n);
22   v.c = (int *) malloc (sizeof (int) * n);
23   v.d = (int *) malloc (sizeof (int) * n);
24 
25 #pragma acc enter data copyin(v)
26 
27   for (k = 0; k < 16; k++)
28     {
29 #pragma acc enter data copyin(v.a, v.b[:n], v.c[:n], v.d[:n])
30 
31 #pragma acc parallel loop
32       for (i = 0; i < n; i++)
33 	v.b[i] = v.a + i;
34 
35 #pragma acc exit data copyout(v.b[:n])
36 #pragma acc exit data copyout(v.c[:n])
37 #pragma acc exit data copyout(v.d[:n])
38 #pragma acc exit data copyout(v.a)
39 
40       for (i = 0; i < n; i++)
41 	assert (v.b[i] == v.a + i);
42 
43       assert (acc_is_present (&v, sizeof (v)));
44       assert (!acc_is_present (v.b, sizeof (int) * n));
45       assert (!acc_is_present (v.c, sizeof (int) * n));
46       assert (!acc_is_present (v.d, sizeof (int) * n));
47     }
48 
49 #pragma acc exit data copyout(v)
50 
51   assert (!acc_is_present (&v, sizeof (v)));
52 
53   return 0;
54 }
55