PR c++/86342 - -Wdeprecated-copy and system headers.
[official-gcc.git] / libgomp / testsuite / libgomp.oacc-c-c++-common / default-1.c
blob1ac0b9587b9c5f6a1d728157f9cd2f542351595f
1 /* { dg-do run } */
3 #include <openacc.h>
5 int test_parallel ()
7 int ok = 1;
8 int val = 2;
9 int ary[32];
10 int ondev = 0;
12 for (int i = 0; i < 32; i++)
13 ary[i] = ~0;
15 /* val defaults to firstprivate, ary defaults to copy. */
16 #pragma acc parallel num_gangs (32) copy (ok) copy(ondev)
18 ondev = acc_on_device (acc_device_not_host);
19 #pragma acc loop gang(static:1)
20 for (unsigned i = 0; i < 32; i++)
22 if (val != 2)
23 ok = 0;
24 val += i;
25 ary[i] = val;
29 if (ondev)
31 if (!ok)
32 return 1;
33 if (val != 2)
34 return 1;
36 for (int i = 0; i < 32; i++)
37 if (ary[i] != 2 + i)
38 return 1;
41 return 0;
44 int test_kernels ()
46 int val = 2;
47 int ary[32];
48 int ondev = 0;
50 for (int i = 0; i < 32; i++)
51 ary[i] = ~0;
53 /* val defaults to copy, ary defaults to copy. */
54 #pragma acc kernels copy(ondev)
56 ondev = acc_on_device (acc_device_not_host);
57 #pragma acc loop
58 for (unsigned i = 0; i < 32; i++)
60 ary[i] = val;
61 val++;
65 if (ondev)
67 if (val != 2 + 32)
68 return 1;
70 for (int i = 0; i < 32; i++)
71 if (ary[i] != 2 + i)
72 return 1;
75 return 0;
78 int main ()
80 if (test_parallel ())
81 return 1;
83 if (test_kernels ())
84 return 1;
86 return 0;