PR c++/86342 - -Wdeprecated-copy and system headers.
[official-gcc.git] / libgomp / testsuite / libgomp.oacc-c-c++-common / loop-red-wv-1.c
blob71d3969f7b630effc425d5c04689a347d4197a17
1 #include <stdio.h>
2 #include <openacc.h>
3 #include <gomp-constants.h>
5 #define N (32*32*32+17)
6 int main ()
8 int ix;
9 int ondev = 0;
10 int t = 0, h = 0;
12 #pragma acc parallel num_workers(32) vector_length(32) copy(ondev)
14 #pragma acc loop worker vector reduction (+:t)
15 for (unsigned ix = 0; ix < N; ix++)
17 int val = ix;
19 if (acc_on_device (acc_device_not_host))
21 int g, w, v;
23 g = __builtin_goacc_parlevel_id (GOMP_DIM_GANG);
24 w = __builtin_goacc_parlevel_id (GOMP_DIM_WORKER);
25 v = __builtin_goacc_parlevel_id (GOMP_DIM_VECTOR);
26 val = (g << 16) | (w << 8) | v;
27 ondev = 1;
29 t += val;
33 for (ix = 0; ix < N; ix++)
35 int val = ix;
36 if(ondev)
38 int g = 0;
39 int w = (ix / 32) % 32;
40 int v = ix % 32;
42 val = (g << 16) | (w << 8) | v;
44 h += val;
46 if (t != h)
48 printf ("t=%x expected %x\n", t, h);
49 return 1;
52 return 0;