Reset prologue_location before calling code_end
[official-gcc.git] / libgomp / testsuite / libgomp.oacc-c-c++-common / loop-red-wv-1.c
blobc360ad11e7cbe025577ce41ba92b98fbae7a9e39
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;
11 int workersize, vectorsize;
13 #pragma acc parallel num_workers(32) vector_length(32) copy(ondev) \
14 copyout(workersize, vectorsize)
16 #pragma acc loop worker vector 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 workersize = __builtin_goacc_parlevel_size (GOMP_DIM_WORKER);
34 vectorsize = __builtin_goacc_parlevel_size (GOMP_DIM_VECTOR);
37 for (ix = 0; ix < N; ix++)
39 int val = ix;
40 if(ondev)
42 int g = 0;
43 int w = (ix / vectorsize) % workersize;
44 int v = ix % vectorsize;
46 val = (g << 16) | (w << 8) | v;
48 h += val;
50 if (t != h)
52 printf ("t=%x expected %x\n", t, h);
53 return 1;
56 return 0;