]>
Commit | Line | Data |
---|---|---|
5d6823a2 | 1 | #include <stdio.h> |
1f62d637 TV |
2 | #include <openacc.h> |
3 | #include <gomp-constants.h> | |
5d6823a2 NS |
4 | |
5 | #define N (32*32*32+17) | |
6 | int main () | |
7 | { | |
8 | int ix; | |
9 | int ondev = 0; | |
10 | int t = 0, h = 0; | |
11 | ||
2c71d454 | 12 | #pragma acc parallel num_workers(32) vector_length(32) copy(ondev) |
5d6823a2 NS |
13 | { |
14 | #pragma acc loop worker reduction(+:t) | |
15 | for (unsigned ix = 0; ix < N; ix++) | |
16 | { | |
17 | int val = ix; | |
18 | ||
1f62d637 | 19 | if (acc_on_device (acc_device_not_host)) |
5d6823a2 | 20 | { |
1f62d637 | 21 | int g, w, v; |
5d6823a2 | 22 | |
1f62d637 TV |
23 | g = __builtin_goacc_parlevel_id (GOMP_DIM_GANG); |
24 | w = __builtin_goacc_parlevel_id (GOMP_DIM_WORKER); | |
25 | v = __builtin_goacc_parlevel_id (GOMP_DIM_VECTOR); | |
5d6823a2 NS |
26 | val = (g << 16) | (w << 8) | v; |
27 | ondev = 1; | |
28 | } | |
29 | t += val; | |
30 | } | |
31 | } | |
32 | ||
33 | for (ix = 0; ix < N; ix++) | |
34 | { | |
35 | int val = ix; | |
36 | if(ondev) | |
37 | { | |
38 | int g = 0; | |
39 | int w = ix % 32; | |
40 | int v = 0; | |
41 | ||
42 | val = (g << 16) | (w << 8) | v; | |
43 | } | |
44 | h += val; | |
45 | } | |
46 | if (t != h) | |
47 | { | |
48 | printf ("t=%x expected %x\n", t, h); | |
49 | return 1; | |
50 | } | |
51 | ||
52 | return 0; | |
53 | } |