]> git.ipfire.org Git - thirdparty/gcc.git/blob - libgomp/testsuite/libgomp.oacc-c-c++-common/lib-61.c
Merge current set of OpenACC changes from gomp-4_0-branch.
[thirdparty/gcc.git] / libgomp / testsuite / libgomp.oacc-c-c++-common / lib-61.c
1 /* { dg-do run } */
2 /* { dg-skip-if "" { *-*-* } { "*" } { "-DACC_MEM_SHARED=0" } } */
3
4 #include <string.h>
5 #include <stdlib.h>
6 #include <openacc.h>
7
8 int
9 main (int argc, char **argv)
10 {
11 const int N = 256;
12 int i;
13 unsigned char *h[N];
14 void *d[N];
15
16 for (i = 0; i < N; i++)
17 {
18 int j;
19 unsigned char *p;
20
21 h[i] = (unsigned char *) malloc (N);
22
23 p = h[i];
24
25 for (j = 0; j < N; j++)
26 {
27 p[j] = i;
28 }
29
30 d[i] = acc_malloc (N);
31
32 acc_memcpy_to_device (d[i], h[i], N);
33
34 for (j = 0; j < N; j++)
35 {
36 if (acc_is_present (h[i] + j, 1) != 0)
37 abort ();
38 }
39 }
40
41 for (i = 0; i < N; i++)
42 {
43 int j;
44 unsigned char *p;
45
46 memset (h[i], 0, N);
47
48 acc_memcpy_from_device (h[i], d[i], N);
49
50 p = h[i];
51
52 for (j = 0; j < N; j++)
53 {
54 if (p[j] != i)
55 abort ();
56 }
57
58 for (j = 0; j < N; j++)
59 {
60 if (acc_is_present (h[i] + j, 1) != 0)
61 abort ();
62 }
63
64 acc_free (d[i]);
65
66 free (h[i]);
67 }
68
69 return 0;
70 }