Reset prologue_location before calling code_end
[official-gcc.git] / libgomp / testsuite / libgomp.oacc-c-c++-common / loop-red-w-1.c
blob2f749e04ae0cf223d29a0fbfbeb986025fa8d948
1 /* { dg-additional-options "-Wopenacc-parallelism" } for testing/documenting
2 aspects of that functionality. */
4 #include <stdio.h>
5 #include <openacc.h>
6 #include <gomp-constants.h>
8 #define N (32*32*32+17)
9 int main ()
11 int ix;
12 int ondev = 0;
13 int t = 0, h = 0;
14 int workersize;
16 #pragma acc parallel num_workers(32) vector_length(32) copy(ondev) \
17 copyout(workersize)
18 /* { dg-warning "region is vector partitioned but does not contain vector partitioned code" "" { target *-*-* } .-2 } */
20 #pragma acc loop worker reduction(+:t)
21 for (unsigned ix = 0; ix < N; ix++)
23 int val = ix;
25 if (acc_on_device (acc_device_not_host))
27 int g, w, v;
29 g = __builtin_goacc_parlevel_id (GOMP_DIM_GANG);
30 w = __builtin_goacc_parlevel_id (GOMP_DIM_WORKER);
31 v = __builtin_goacc_parlevel_id (GOMP_DIM_VECTOR);
32 val = (g << 16) | (w << 8) | v;
33 ondev = 1;
35 t += val;
37 workersize = __builtin_goacc_parlevel_size (GOMP_DIM_WORKER);
40 for (ix = 0; ix < N; ix++)
42 int val = ix;
43 if(ondev)
45 int g = 0;
46 int w = ix % workersize;
47 int v = 0;
49 val = (g << 16) | (w << 8) | v;
51 h += val;
53 if (t != h)
55 printf ("t=%x expected %x\n", t, h);
56 return 1;
59 return 0;