111
|
1 #include <stdio.h>
|
131
|
2 #include <openacc.h>
|
|
3 #include <gomp-constants.h>
|
111
|
4
|
|
5 #define N (32*32*32+17)
|
|
6 int main ()
|
|
7 {
|
|
8 int ary[N];
|
|
9 int ix;
|
|
10 int exit = 0;
|
|
11 int ondev = 0;
|
|
12
|
|
13 for (ix = 0; ix < N;ix++)
|
|
14 ary[ix] = -1;
|
|
15
|
|
16 #pragma acc parallel num_workers(32) vector_length(32) copy(ary) copy(ondev)
|
|
17 {
|
|
18 #pragma acc loop worker vector
|
|
19 for (unsigned ix = 0; ix < N; ix++)
|
|
20 {
|
131
|
21 if (acc_on_device (acc_device_not_host))
|
111
|
22 {
|
131
|
23 int g, w, v;
|
111
|
24
|
131
|
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);
|
111
|
28 ary[ix] = (g << 16) | (w << 8) | v;
|
|
29 ondev = 1;
|
|
30 }
|
|
31 else
|
|
32 ary[ix] = ix;
|
|
33 }
|
|
34 }
|
|
35
|
|
36 for (ix = 0; ix < N; ix++)
|
|
37 {
|
|
38 int expected = ix;
|
|
39 if(ondev)
|
|
40 {
|
|
41 int g = 0;
|
|
42 int w = (ix / 32) % 32;
|
|
43 int v = ix % 32;
|
|
44
|
|
45 expected = (g << 16) | (w << 8) | v;
|
|
46 }
|
|
47
|
|
48 if (ary[ix] != expected)
|
|
49 {
|
|
50 exit = 1;
|
|
51 printf ("ary[%d]=%x expected %x\n", ix, ary[ix], expected);
|
|
52 }
|
|
53 }
|
|
54
|
|
55 return exit;
|
|
56 }
|