C++: simplify output from suggest_alternatives_for
[official-gcc.git] / libgomp / testsuite / libgomp.oacc-c-c++-common / loop-w-1.c
blobfa6fb9164e6365a082672fd45af5608152de511a
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 num_workers(32) vector_length(32) copy(ary) copy(ondev)
18 #pragma acc loop worker
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 = ix % 32;
43 int v = 0;
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;