Check CXXFLAGS, instead of CFLAGS, for NO_PIE_CFLAGS
[official-gcc.git] / libgomp / testsuite / libgomp.oacc-c-c++-common / update-1.c
blobdff139f03cc2a08e2f6e91d532e3f895d9a4d88b
1 /* { dg-do run } */
2 /* { dg-skip-if "" { *-*-* } { "*" } { "-DACC_MEM_SHARED=0" } } */
4 #include <openacc.h>
5 #include <string.h>
6 #include <stdio.h>
7 #include <stdlib.h>
8 #include <stdbool.h>
10 int
11 main (int argc, char **argv)
13 int N = 8;
14 float *a, *b, *c;
15 float *d_a, *d_b, *d_c;
16 int i;
18 a = (float *) malloc (N * sizeof (float));
19 b = (float *) malloc (N * sizeof (float));
20 c = (float *) malloc (N * sizeof (float));
22 d_a = (float *) acc_malloc (N * sizeof (float));
23 d_b = (float *) acc_malloc (N * sizeof (float));
24 d_c = (float *) acc_malloc (N * sizeof (float));
26 for (i = 0; i < N; i++)
28 a[i] = 3.0;
29 b[i] = 0.0;
32 acc_map_data (a, d_a, N * sizeof (float));
33 acc_map_data (b, d_b, N * sizeof (float));
34 acc_map_data (c, d_c, N * sizeof (float));
36 #pragma acc update device (a[0:N], b[0:N])
38 #pragma acc parallel present (a[0:N], b[0:N])
40 int ii;
42 for (ii = 0; ii < N; ii++)
43 b[ii] = a[ii];
46 #pragma acc update host (a[0:N], b[0:N])
48 for (i = 0; i < N; i++)
50 if (a[i] != 3.0)
51 abort ();
53 if (b[i] != 3.0)
54 abort ();
57 if (!acc_is_present (&a[0], (N * sizeof (float))))
58 abort ();
60 if (!acc_is_present (&b[0], (N * sizeof (float))))
61 abort ();
63 for (i = 0; i < N; i++)
65 a[i] = 5.0;
66 b[i] = 1.0;
69 #pragma acc update device (a[0:N], b[0:N])
71 #pragma acc parallel present (a[0:N], b[0:N])
73 int ii;
75 for (ii = 0; ii < N; ii++)
76 b[ii] = a[ii];
79 #pragma acc update host (a[0:N], b[0:N])
81 for (i = 0; i < N; i++)
83 if (a[i] != 5.0)
84 abort ();
86 if (b[i] != 5.0)
87 abort ();
90 if (!acc_is_present (&a[0], (N * sizeof (float))))
91 abort ();
93 if (!acc_is_present (&b[0], (N * sizeof (float))))
94 abort ();
96 for (i = 0; i < N; i++)
98 a[i] = 5.0;
99 b[i] = 1.0;
102 #pragma acc update device (a[0:N], b[0:N])
104 #pragma acc parallel present (a[0:N], b[0:N])
106 int ii;
108 for (ii = 0; ii < N; ii++)
109 b[ii] = a[ii];
112 #pragma acc update self (a[0:N], b[0:N])
114 for (i = 0; i < N; i++)
116 if (a[i] != 5.0)
117 abort ();
119 if (b[i] != 5.0)
120 abort ();
123 if (!acc_is_present (&a[0], (N * sizeof (float))))
124 abort ();
126 if (!acc_is_present (&b[0], (N * sizeof (float))))
127 abort ();
129 for (i = 0; i < N; i++)
131 a[i] = 6.0;
132 b[i] = 0.0;
135 #pragma acc update device (a[0:N], b[0:N])
137 for (i = 0; i < N; i++)
139 a[i] = 9.0;
142 #pragma acc parallel present (a[0:N], b[0:N])
144 int ii;
146 for (ii = 0; ii < N; ii++)
147 b[ii] = a[ii];
150 #pragma acc update host (a[0:N], b[0:N])
152 for (i = 0; i < N; i++)
154 if (a[i] != 6.0)
155 abort ();
157 if (b[i] != 6.0)
158 abort ();
161 if (!acc_is_present (&a[0], (N * sizeof (float))))
162 abort ();
164 if (!acc_is_present (&b[0], (N * sizeof (float))))
165 abort ();
167 for (i = 0; i < N; i++)
169 a[i] = 7.0;
170 b[i] = 2.0;
173 #pragma acc update device (a[0:N], b[0:N])
175 for (i = 0; i < N; i++)
177 a[i] = 9.0;
180 #pragma acc parallel present (a[0:N], b[0:N])
182 int ii;
184 for (ii = 0; ii < N; ii++)
185 b[ii] = a[ii];
188 #pragma acc update host (a[0:N], b[0:N])
190 for (i = 0; i < N; i++)
192 if (a[i] != 7.0)
193 abort ();
195 if (b[i] != 7.0)
196 abort ();
199 for (i = 0; i < N; i++)
201 a[i] = 9.0;
204 #pragma acc update device (a[0:N])
206 #pragma acc parallel present (a[0:N], b[0:N])
208 int ii;
210 for (ii = 0; ii < N; ii++)
211 b[ii] = a[ii];
214 #pragma acc update host (a[0:N], b[0:N])
216 for (i = 0; i < N; i++)
218 if (a[i] != 9.0)
219 abort ();
221 if (b[i] != 9.0)
222 abort ();
225 if (!acc_is_present (&a[0], (N * sizeof (float))))
226 abort ();
228 if (!acc_is_present (&b[0], (N * sizeof (float))))
229 abort ();
231 for (i = 0; i < N; i++)
233 a[i] = 5.0;
236 #pragma acc update device (a[0:N])
238 for (i = 0; i < N; i++)
240 a[i] = 6.0;
243 #pragma acc update device (a[0:N >> 1])
245 #pragma acc parallel present (a[0:N], b[0:N])
247 int ii;
249 for (ii = 0; ii < N; ii++)
250 b[ii] = a[ii];
253 #pragma acc update host (a[0:N], b[0:N])
255 for (i = 0; i < (N >> 1); i++)
257 if (a[i] != 6.0)
258 abort ();
260 if (b[i] != 6.0)
261 abort ();
264 for (i = (N >> 1); i < N; i++)
266 if (a[i] != 5.0)
267 abort ();
269 if (b[i] != 5.0)
270 abort ();
273 if (!acc_is_present (&a[0], (N * sizeof (float))))
274 abort ();
276 if (!acc_is_present (&b[0], (N * sizeof (float))))
277 abort ();
279 return 0;