1 /* { dg-additional-options "-fopt-info-note-omp" }
2 { dg-additional-options "--param=openacc-privatization=noisy" }
3 { dg-additional-options "-foffload=-fopt-info-note-omp" }
4 { dg-additional-options "-foffload=--param=openacc-privatization=noisy" }
5 for testing/documenting aspects of that functionality. */
6
7 /* { dg-additional-options "-Wopenacc-parallelism" } for testing/documenting
8 aspects of that functionality. */
9
10 #include <stdio.h>
11 #include <openacc.h>
12 #include <gomp-constants.h>
13
14 #define N (32*32*32+17)
15 int main ()
16 {
17 int ix;
18 int ondev = 0;
19 int t = 0, h = 0;
20 int workersize;
21
22 #define NW 32
23 #define VL 32
24 #pragma acc parallel num_workers(NW) vector_length(VL) \
25 copy(ondev)
26 /* { dg-note {variable 'ix' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } .-2 } */
27 /* { dg-warning "region is vector partitioned but does not contain vector partitioned code" "" { target *-*-* } .-3 } */
28 {
29 #pragma acc loop worker reduction(+:t)
30 /* { dg-note {variable 'ix' in 'private' clause isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } .-1 } */
31 /* { dg-note {variable 'val' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } .-2 } */
32 /* { dg-note {variable 'g' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } .-3 } */
33 /* { dg-note {variable 'w' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } .-4 } */
34 /* { dg-note {variable 'v' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } .-5 } */
35 for (unsigned ix = 0; ix < N; ix++)
36 {
37 int val = ix;
38
39 if (acc_on_device (acc_device_not_host))
40 {
41 int g, w, v;
42
43 g = __builtin_goacc_parlevel_id (GOMP_DIM_GANG);
44 w = __builtin_goacc_parlevel_id (GOMP_DIM_WORKER);
45 v = __builtin_goacc_parlevel_id (GOMP_DIM_VECTOR);
46 val = (g << 16) | (w << 8) | v;
47 ondev = 1;
48 }
49 t += val;
50 }
51 }
52 workersize = NW;
53 #ifdef ACC_DEVICE_TYPE_radeon
54 /* AMD GCN has an upper limit of 'num_workers(16)'. */
55 if (workersize > 16)
56 workersize = 16;
57 #endif
58
59 for (ix = 0; ix < N; ix++)
60 {
61 int val = ix;
62 if(ondev)
63 {
64 int g = 0;
65 int w = ix % workersize;
66 int v = 0;
67
68 val = (g << 16) | (w << 8) | v;
69 }
70 h += val;
71 }
72 if (t != h)
73 {
74 printf ("t=%x expected %x\n", t, h);
75 return 1;
76 }
77
78 return 0;
79 }