PR c++/86342 - -Wdeprecated-copy and system headers.
[official-gcc.git] / libgomp / testsuite / libgomp.oacc-c-c++-common / loop-red-v-2.c
blob15e2bc2f83bf898aafded1f57abd359326850eca
1 #include <stdio.h>
2 #include <openacc.h>
3 #include <gomp-constants.h>
5 #define N (32*32*32+17)
7 int main ()
9 int ix;
10 int ondev = 0;
11 int q = 0, h = 0;
13 #pragma acc parallel vector_length(32) copy(q) copy(ondev)
15 int t = q;
17 #pragma acc loop vector reduction (+:t)
18 for (unsigned ix = 0; ix < N; ix++)
20 int val = ix;
22 if (acc_on_device (acc_device_not_host))
24 int g, w, v;
26 g = __builtin_goacc_parlevel_id (GOMP_DIM_GANG);
27 w = __builtin_goacc_parlevel_id (GOMP_DIM_WORKER);
28 v = __builtin_goacc_parlevel_id (GOMP_DIM_VECTOR);
29 val = (g << 16) | (w << 8) | v;
30 ondev = 1;
32 t += val;
34 q = t;
37 for (ix = 0; ix < N; ix++)
39 int val = ix;
40 if (ondev)
42 int g = 0;
43 int w = 0;
44 int v = ix % 32;
46 val = (g << 16) | (w << 8) | v;
48 h += val;
51 if (q != h)
53 printf ("t=%x expected %x\n", q, h);
54 return 1;
57 return 0;