Update 'Q' constraint documentation.
[official-gcc.git] / libgomp / testsuite / libgomp.oacc-c-c++-common / loop-red-w-2.c
blobc63a5d4f808b51122e9c4ece51ddc2a828d65f4e
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 q = 0, h = 0;
12 #pragma acc parallel num_workers(32) vector_length(32) copy(q) copy(ondev)
14 int t = q;
16 #pragma acc loop worker reduction(+:t)
17 for (unsigned ix = 0; ix < N; ix++)
19 int val = ix;
21 if (acc_on_device (acc_device_not_host))
23 int g, w, v;
25 g = __builtin_goacc_parlevel_id (GOMP_DIM_GANG);
26 w = __builtin_goacc_parlevel_id (GOMP_DIM_WORKER);
27 v = __builtin_goacc_parlevel_id (GOMP_DIM_VECTOR);
28 val = (g << 16) | (w << 8) | v;
29 ondev = 1;
31 t += val;
33 q = t;
36 for (ix = 0; ix < N; ix++)
38 int val = ix;
39 if(ondev)
41 int g = 0;
42 int w = ix % 32;
43 int v = 0;
45 val = (g << 16) | (w << 8) | v;
47 h += val;
49 if (q != h)
51 printf ("t=%x expected %x\n", q, h);
52 return 1;
55 return 0;