Update 'Q' constraint documentation.
[official-gcc.git] / libgomp / testsuite / libgomp.oacc-c-c++-common / host_data-6.c
blob1cda442b00134fdc1203c4ccb6428d1a5bc3a455
1 /* Call 'acc_memcpy_from_device' inside '#pragma acc host_data'. */
3 /* { dg-skip-if "" { *-*-* } { "*" } { "-DACC_MEM_SHARED=0" } } */
5 #include <assert.h>
6 #include <stdlib.h>
7 #include <string.h>
8 #include <openacc.h>
10 int
11 main ()
13 const int SIZE = 318;
14 const int c0 = 22;
15 const int c1 = 112;
17 char *h = (char *) malloc (SIZE);
19 memset (h, c0, SIZE);
21 #pragma acc data create (h[0:SIZE - 44])
23 #pragma acc update device (h[0:SIZE - 44])
25 memset (h, c1, 67);
27 void *d = h;
28 #pragma acc host_data use_device (d)
30 acc_memcpy_from_device (h, d, 12);
34 for (int i = 0; i < SIZE; ++i)
36 if (i < 12)
37 assert (h[i] == c0);
38 else if (i < 67)
39 assert (h[i] == c1);
40 else
41 assert (h[i] == c0);
44 free (h);
46 return 0;