PR c++/86342 - -Wdeprecated-copy and system headers.
[official-gcc.git] / libgomp / testsuite / libgomp.oacc-c-c++-common / loop-red-v-1.c
blobda4921d15f98c882d0dcf3725f30e96e19e5a0bb
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 t = 0, h = 0;
13 #pragma acc parallel vector_length(32) copy(ondev)
15 #pragma acc loop vector reduction (+:t)
16 for (unsigned ix = 0; ix < N; ix++)
18 int val = ix;
20 if (acc_on_device (acc_device_not_host))
22 int g, w, v;
24 g = __builtin_goacc_parlevel_id (GOMP_DIM_GANG);
25 w = __builtin_goacc_parlevel_id (GOMP_DIM_WORKER);
26 v = __builtin_goacc_parlevel_id (GOMP_DIM_VECTOR);
27 val = (g << 16) | (w << 8) | v;
28 ondev = 1;
30 t += val;
34 for (ix = 0; ix < N; ix++)
36 int val = ix;
37 if (ondev)
39 int g = 0;
40 int w = 0;
41 int v = ix % 32;
43 val = (g << 16) | (w << 8) | v;
45 h += val;
48 if (t != h)
50 printf ("t=%x expected %x\n", t, h);
51 return 1;
54 return 0;