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