PR c++/86342 - -Wdeprecated-copy and system headers.
[official-gcc.git] / libgomp / testsuite / libgomp.oacc-c-c++-common / loop-v-1.c
blob6010cd2498a6ec1423fcee49a9344e404629fa0c
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 ary[N];
9 int ix;
10 int exit = 0;
11 int ondev = 0;
13 for (ix = 0; ix < N;ix++)
14 ary[ix] = -1;
16 #pragma acc parallel vector_length(32) copy(ary) copy(ondev)
18 #pragma acc loop vector
19 for (unsigned ix = 0; ix < N; 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 ary[ix] = (g << 16) | (w << 8) | v;
29 ondev = 1;
31 else
32 ary[ix] = ix;
36 for (ix = 0; ix < N; ix++)
38 int expected = ix;
39 if(ondev)
41 int g = 0;
42 int w = 0;
43 int v = ix % 32;
45 expected = (g << 16) | (w << 8) | v;
48 if (ary[ix] != expected)
50 exit = 1;
51 printf ("ary[%d]=%x expected %x\n", ix, ary[ix], expected);
55 return exit;