1 /* Call 'acc_memcpy_from_device' inside '#pragma acc host_data'. */
2
3 /* { dg-skip-if "" { *-*-* } { "*" } { "-DACC_MEM_SHARED=0" } } */
4
5 #include <assert.h>
6 #include <stdlib.h>
7 #include <string.h>
8 #include <openacc.h>
9
10 int
11 main ()
12 {
13 const int SIZE = 318;
14 const int c0 = 22;
15 const int c1 = 112;
16
17 char *h = (char *) malloc (SIZE);
18
19 memset (h, c0, SIZE);
20
21 #pragma acc data create (h[0:SIZE - 44])
22 {
23 #pragma acc update device (h[0:SIZE - 44])
24
25 memset (h, c1, 67);
26
27 void *d = h;
28 #pragma acc host_data use_device (d)
29 {
30 acc_memcpy_from_device (h, d, 12);
31 }
32 }
33
34 for (int i = 0; i < SIZE; ++i)
35 {
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);
42 }
43
44 free (h);
45
46 return 0;
47 }