Improve atomic store implementation on hppa-linux.
[official-gcc.git] / libgomp / testsuite / libgomp.oacc-c-c++-common / deep-copy-6.c
blob391149459c90c05d8c4a52cd8b208770987b9779
1 /* { dg-do run { target { ! openacc_host_selected } } } */
3 #include <stdlib.h>
4 #include <assert.h>
5 #include <openacc.h>
7 struct dc
9 int a;
10 int **b;
13 int
14 main ()
16 int n = 100, i, j, k;
17 struct dc v = { .a = 3 };
19 v.b = (int **) malloc (sizeof (int *) * n);
20 for (i = 0; i < n; i++)
21 v.b[i] = (int *) malloc (sizeof (int) * n);
23 for (k = 0; k < 16; k++)
25 #pragma acc data copy(v)
27 #pragma acc data copy(v.b[:n])
29 for (i = 0; i < n; i++)
31 acc_copyin (v.b[i], sizeof (int) * n);
32 acc_attach ((void **) &v.b[i]);
35 #pragma acc parallel loop
36 for (i = 0; i < n; i++)
37 for (j = 0; j < n; j++)
38 v.b[i][j] = v.a + i + j;
40 for (i = 0; i < n; i++)
42 acc_detach ((void **) &v.b[i]);
43 acc_copyout (v.b[i], sizeof (int) * n);
48 for (i = 0; i < n; i++)
49 for (j = 0; j < n; j++)
50 assert (v.b[i][j] == v.a + i + j);
52 assert (!acc_is_present (&v, sizeof (v)));
53 assert (!acc_is_present (v.b, sizeof (int *) * n));
54 for (i = 0; i < n; i++)
55 assert (!acc_is_present (v.b[i], sizeof (int) * n));
58 return 0;