PR c++/86342 - -Wdeprecated-copy and system headers.
[official-gcc.git] / libgomp / testsuite / libgomp.oacc-c-c++-common / routine-v-1.c
blobb1e3e3a596af9af115a7a9e184e62fad71ff807b
1 #include <stdio.h>
2 #include <openacc.h>
3 #include <gomp-constants.h>
5 #define N (32*32*32+17)
7 #pragma acc routine vector
8 void __attribute__ ((noinline)) vector (int ary[N])
10 #pragma acc loop vector
11 for (unsigned ix = 0; ix < N; ix++)
13 if (acc_on_device (acc_device_not_host))
15 int g, w, v;
17 g = __builtin_goacc_parlevel_id (GOMP_DIM_GANG);
18 w = __builtin_goacc_parlevel_id (GOMP_DIM_WORKER);
19 v = __builtin_goacc_parlevel_id (GOMP_DIM_VECTOR);
20 ary[ix] = (g << 16) | (w << 8) | v;
22 else
23 ary[ix] = ix;
27 int main ()
29 int ary[N];
30 int ix;
31 int exit = 0;
32 int ondev = 0;
34 for (ix = 0; ix < N;ix++)
35 ary[ix] = -1;
37 #pragma acc parallel vector_length(32) copy(ary) copy(ondev)
39 ondev = acc_on_device (acc_device_not_host);
40 vector (ary);
43 for (ix = 0; ix < N; ix++)
45 int expected = ix;
46 if(ondev)
48 int g = 0;
49 int w = 0;
50 int v = ix % 32;
52 expected = (g << 16) | (w << 8) | v;
55 if (ary[ix] != expected)
57 exit = 1;
58 printf ("ary[%d]=%x expected %x\n", ix, ary[ix], expected);
62 return exit;