Remove xfail for hppa*-*-hpux* from stdatomic-flag.c and stdatomic-flag-2.c
[official-gcc.git] / libgomp / testsuite / libgomp.oacc-c++ / privatized-ref-2.C
blob18552206c6b2aa74e6c2d377bb1a9522ff59ff3f
1 /* { dg-do run } */
3 /* { dg-additional-options "-fopt-info-note-omp" }
4    { dg-additional-options "-foffload=-fopt-info-note-omp" } */
6 /* { dg-additional-options "--param=openacc-privatization=noisy" }
7    { dg-additional-options "-foffload=--param=openacc-privatization=noisy" } */
9 /* { dg-additional-options "-Wuninitialized" } */
11 /* It's only with Tcl 8.5 (released in 2007) that "the variable 'varName'
12    passed to 'incr' may be unset, and in that case, it will be set to [...]",
13    so to maintain compatibility with earlier Tcl releases, we manually
14    initialize counter variables:
15    { dg-line l_dummy[variable c_compute 0 c_loop 0] }
16    { dg-message "dummy" "" { target iN-VAl-Id } l_dummy } to avoid
17    "WARNING: dg-line var l_dummy defined, but not used".  */
19 #include <stdlib.h>
21 void gangs (void)
23   double res[65536];
24   int i;
26 #pragma acc parallel copyout(res) num_gangs(64) /* { dg-line l_compute[incr c_compute] } */
27   /* { dg-note {variable 'i' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } l_compute$c_compute } */
28   /* { dg-note {variable 'j' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } l_compute$c_compute } */
29   {
30     int i, j;
31 #pragma acc loop collapse(2) gang /* { dg-line l_loop[incr c_loop] } */
32     /* { dg-note {variable 'j' in 'private' clause isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } l_loop$c_loop } */
33     /* { dg-note {variable 'i' in 'private' clause isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } l_loop$c_loop } */
34     /* { dg-note {variable 'tmpvar' declared in block is candidate for adjusting OpenACC privatization level} "" { target *-*-* } l_loop$c_loop }
35        But, with optimizations enabled, per the '*.ssa' dump ('gcc/tree-ssa.c:execute_update_addresses_taken'):
36            No longer having address taken: tmpvar
37            Now a gimple register: tmpvar
38        However, 'tmpvar' remains in the candidate set:
39        { dg-note {variable 'tmpvar' ought to be adjusted for OpenACC privatization level: 'gang'} "" { target *-*-* } l_loop$c_loop }
40        Now, for GCN offloading, 'adjust_private_decl' does the privatization change right away:
41        { dg-note {variable 'tmpvar' adjusted for OpenACC privatization level: 'gang'} "" { target openacc_radeon_accel_selected } l_loop$c_loop }
42        For nvptx offloading however, we first mark up 'tmpvar', and then later apply the privatization change -- or, with optimizations enabled, don't, because we then don't actually call 'expand_var_decl'.
43        { dg-note {variable 'tmpvar' adjusted for OpenACC privatization level: 'gang'} "" { target { openacc_nvidia_accel_selected && { ! __OPTIMIZE__ } } } l_loop$c_loop }
44        { dg-bogus {note: variable 'tmpvar' adjusted for OpenACC privatization level: 'gang'} "" { target { openacc_nvidia_accel_selected && __OPTIMIZE__ } } l_loop$c_loop }
45   */
46     /* { dg-note {variable 'tmpref' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } l_loop$c_loop } */
47     for (i = 0; i < 256; i++)
48       {
49         for (j = 0; j < 256; j++)
50           {
51             int tmpvar;
52             int &tmpref = tmpvar;
53             tmpref = (i * 256 + j) * 97;
54             res[i * 256 + j] = tmpref;
55           }
56       }
57   }
59   for (i = 0; i < 65536; i++)
60     if (res[i] != i * 97)
61       abort ();
64 void workers (void)
66   double res[65536];
67   int i;
69 #pragma acc parallel copyout(res) num_gangs(64) num_workers(64) /* { dg-line l_compute[incr c_compute] } */
70   /* { dg-note {variable 'i' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } l_compute$c_compute } */
71   /* { dg-note {variable 'j' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } l_compute$c_compute } */
72   /* { dg-warning "using .num_workers \\(32\\)., ignoring 64" "" { target openacc_nvidia_accel_selected } l_compute$c_compute } */
73   {
74     int i, j;
75 #pragma acc loop gang /* { dg-line l_loop[incr c_loop] } */
76     /* { dg-note {variable 'i' in 'private' clause isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } l_loop$c_loop } */
77     for (i = 0; i < 256; i++)
78       {
79 #pragma acc loop worker /* { dg-line l_loop[incr c_loop] } */
80         /* { dg-note {variable 'j' in 'private' clause isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } l_loop$c_loop } */
81         /* { dg-note {variable 'tmpvar' declared in block is candidate for adjusting OpenACC privatization level} "" { target *-*-* } l_loop$c_loop }
82            { dg-note {variable 'tmpvar' ought to be adjusted for OpenACC privatization level: 'worker'} "" { target *-*-* } l_loop$c_loop }
83            { dg-note {variable 'tmpvar' adjusted for OpenACC privatization level: 'worker'} "TODO" { target { ! openacc_host_selected } xfail *-*-* } l_loop$c_loop } */
84         /* { dg-note {variable 'tmpref' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } l_loop$c_loop } */
85         for (j = 0; j < 256; j++)
86           {
87             int tmpvar;
88             int &tmpref = tmpvar;
89             tmpref = (i * 256 + j) * 99;
90             res[i * 256 + j] = tmpref;
91           }
92       }
93   }
95   for (i = 0; i < 65536; i++)
96     if (res[i] != i * 99)
97       abort ();
100 void vectors (void)
102   double res[65536];
103   int i;
105 #pragma acc parallel copyout(res) num_gangs(64) num_workers(64) /* { dg-line l_compute[incr c_compute] } */
106   /* { dg-note {variable 'i' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } l_compute$c_compute } */
107   /* { dg-note {variable 'j' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } l_compute$c_compute } */
108   /* { dg-warning "using .num_workers \\(32\\)., ignoring 64" "" { target openacc_nvidia_accel_selected } l_compute$c_compute } */
109   {
110     int i, j;
111 #pragma acc loop gang worker /* { dg-line l_loop[incr c_loop] } */
112     /* { dg-note {variable 'i' in 'private' clause isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } l_loop$c_loop } */
113     for (i = 0; i < 256; i++)
114       {
115 #pragma acc loop vector /* { dg-line l_loop[incr c_loop] } */
116         /* { dg-note {variable 'j' in 'private' clause isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } l_loop$c_loop } */
117         /* { dg-note {variable 'tmpvar' declared in block is candidate for adjusting OpenACC privatization level} "" { target *-*-* } l_loop$c_loop }
118            { dg-note {variable 'tmpvar' ought to be adjusted for OpenACC privatization level: 'vector'} "" { target *-*-* } l_loop$c_loop }
119            { dg-note {variable 'tmpvar' adjusted for OpenACC privatization level: 'vector'} "TODO" { target { ! openacc_host_selected } } l_loop$c_loop } */
120         /* { dg-note {variable 'tmpref' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } l_loop$c_loop } */
121         for (j = 0; j < 256; j++)
122           {
123             int tmpvar;
124             int &tmpref = tmpvar;
125             tmpref = (i * 256 + j) * 101;
126             res[i * 256 + j] = tmpref;
127           }
128       }
129   }
131   for (i = 0; i < 65536; i++)
132     if (res[i] != i * 101)
133       abort ();
136 void gangs_workers_vectors (void)
138   double res[65536];
139   int i;
141 #pragma acc parallel copyout(res) num_gangs(64) num_workers(64) /* { dg-line l_compute[incr c_compute] } */
142   /* { dg-note {variable 'i' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } l_compute$c_compute } */
143   /* { dg-note {variable 'j' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } l_compute$c_compute } */
144   /* { dg-warning "using .num_workers \\(32\\)., ignoring 64" "" { target openacc_nvidia_accel_selected } l_compute$c_compute } */
145   {
146     int i, j;
147 #pragma acc loop collapse(2) gang worker vector /* { dg-line l_loop[incr c_loop] } */
148     /* { dg-note {variable 'j' in 'private' clause isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } l_loop$c_loop } */
149     /* { dg-note {variable 'i' in 'private' clause isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } l_loop$c_loop } */
150     /* { dg-note {variable 'tmpvar' declared in block is candidate for adjusting OpenACC privatization level} "" { target *-*-* } l_loop$c_loop }
151        { dg-note {variable 'tmpvar' ought to be adjusted for OpenACC privatization level: 'vector'} "" { target *-*-* } l_loop$c_loop }
152        { dg-note {variable 'tmpvar' adjusted for OpenACC privatization level: 'vector'} "TODO" { target { ! openacc_host_selected } } l_loop$c_loop } */
153     /* { dg-note {variable 'tmpref' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } l_loop$c_loop } */
154     for (i = 0; i < 256; i++)
155       {
156         for (j = 0; j < 256; j++)
157           {
158             int tmpvar;
159             int &tmpref = tmpvar;
160             tmpref = (i * 256 + j) * 103;
161             res[i * 256 + j] = tmpref;
162           }
163       }
164   }
166   for (i = 0; i < 65536; i++)
167     if (res[i] != i * 103)
168       abort ();
171 int main (int argc, char *argv[])
173   gangs ();
174   workers ();
175   vectors ();
176   gangs_workers_vectors ();
177   return 0;