1 ! Test OpenACC 'declare create' with allocatable arrays.
5 !TODO-OpenACC-declare-allocate
6 ! Not currently implementing correct '-DACC_MEM_SHARED=0' behavior:
7 ! Missing support for OpenACC "Changes from Version 2.0 to 2.5":
8 ! "The 'declare create' directive with a Fortran 'allocatable' has new behavior".
9 ! { dg-xfail-run-if TODO { *-*-* } { -DACC_MEM_SHARED=0 } }
11 !TODO { dg-additional-options -fno-inline } for stable results regarding OpenACC 'routine'.
13 ! { dg-additional-options -fopt-info-all-omp }
14 ! { dg-additional-options -foffload=-fopt-info-all-omp }
16 ! { dg-additional-options --param=openacc-privatization=noisy }
17 ! { dg-additional-options -foffload=--param=openacc-privatization=noisy }
18 ! Prune a few: uninteresting, and potentially varying depending on GCC configuration (data types):
19 ! { dg-prune-output {note: variable '[Di]\.[0-9]+' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} }
21 ! { dg-additional-options -Wopenacc-parallelism }
23 ! It's only with Tcl 8.5 (released in 2007) that "the variable 'varName'
24 ! passed to 'incr' may be unset, and in that case, it will be set to [...]",
25 ! so to maintain compatibility with earlier Tcl releases, we manually
26 ! initialize counter variables:
27 ! { dg-line l_dummy[variable c 0] }
28 ! { dg-message dummy {} { target iN-VAl-Id } l_dummy } to avoid
29 ! "WARNING: dg-line var l_dummy defined, but not used".
34 integer, parameter :: n
= 100
35 real*8, allocatable
:: b(:)
36 !$acc declare create (b)
54 real*8 function fun1 (ix
)
59 real*8 function fun2 (ix
)
65 if (allocated (b
)) error
stop
67 ! Test local usage of an allocated declared array.
71 if (.not
.allocated (b
)) error
stop
72 if (.not
.acc_is_present (b
)) error
stop
76 !$acc parallel loop ! { dg-line l[incr c] }
77 ! { dg-note {variable 'i' in 'private' clause is candidate for adjusting OpenACC privatization level} {} { target *-*-* } l$c }
78 ! { dg-note {variable 'i' ought to be adjusted for OpenACC privatization level: 'vector'} {} { target *-*-* } l$c }
79 ! { dg-note {variable 'i' adjusted for OpenACC privatization level: 'vector'} {} { target { ! openacc_host_selected } } l$c }
80 ! { dg-note {variable 'i\.[0-9]+' in 'private' clause isn't candidate for adjusting OpenACC privatization level: not addressable} {} { target *-*-* } l$c }
81 ! { dg-optimized {assigned OpenACC gang vector loop parallelism} {} { target *-*-* } l$c }
86 if (.not
.acc_is_present (b
)) error
stop
91 if (b(i
) /= i
*a
) error
stop
96 ! Test the usage of an allocated declared array inside an acc
101 if (.not
.allocated (b
)) error
stop
102 if (.not
.acc_is_present (b
)) error
stop
105 call sub1
! { dg-line l[incr c] }
106 ! { dg-optimized {assigned OpenACC gang worker vector loop parallelism} {} { target *-*-* } l$c }
109 if (.not
.acc_is_present (b
)) error
stop
114 if (b(i
) /= i
*2) error
stop
119 ! Test the usage of an allocated declared array inside a host
124 if (.not
.acc_is_present (b
)) error
stop
129 if (b(i
) /= 1.0) error
stop
134 if (allocated (b
)) error
stop
136 ! Test the usage of an allocated declared array inside an acc
141 if (.not
.allocated (b
)) error
stop
142 if (.not
.acc_is_present (b
)) error
stop
144 !$acc parallel loop ! { dg-line l[incr c] }
145 ! { dg-note {variable 'i' in 'private' clause is candidate for adjusting OpenACC privatization level} {} { target *-*-* } l$c }
146 ! { dg-note {variable 'i' ought to be adjusted for OpenACC privatization level: 'vector'} {} { target *-*-* } l$c }
147 ! { dg-note {variable 'i' adjusted for OpenACC privatization level: 'vector'} {} { target { ! openacc_host_selected } } l$c }
148 ! { dg-note {variable 'i\.[0-9]+' in 'private' clause isn't candidate for adjusting OpenACC privatization level: not addressable} {} { target *-*-* } l$c }
149 ! { dg-optimized {assigned OpenACC gang vector loop parallelism} {} { target *-*-* } l$c }
154 !$acc parallel loop ! { dg-line l[incr c] }
155 ! { dg-note {variable 'i' in 'private' clause is candidate for adjusting OpenACC privatization level} {} { target *-*-* } l$c }
156 ! { dg-note {variable 'i' ought to be adjusted for OpenACC privatization level: 'vector'} {} { target *-*-* } l$c }
157 ! { dg-note {variable 'i' adjusted for OpenACC privatization level: 'vector'} {} { target { ! openacc_host_selected } } l$c }
158 ! { dg-note {variable 'i\.[0-9]+' in 'private' clause isn't candidate for adjusting OpenACC privatization level: not addressable} {} { target *-*-* } l$c }
159 ! { dg-optimized {assigned OpenACC gang vector loop parallelism} {} { target *-*-* } l$c }
161 b(i
) = fun1 (i
) ! { dg-line l[incr c] }
162 ! { dg-optimized {assigned OpenACC seq loop parallelism} {} { target *-*-* } l$c }
165 if (.not
.acc_is_present (b
)) error
stop
170 if (b(i
) /= i
) error
stop
175 ! Test the usage of an allocated declared array inside a host
180 if (.not
.allocated (b
)) error
stop
181 if (.not
.acc_is_present (b
)) error
stop
183 !$acc parallel loop ! { dg-line l[incr c] }
184 ! { dg-note {variable 'i' in 'private' clause is candidate for adjusting OpenACC privatization level} {} { target *-*-* } l$c }
185 ! { dg-note {variable 'i' ought to be adjusted for OpenACC privatization level: 'vector'} {} { target *-*-* } l$c }
186 ! { dg-note {variable 'i' adjusted for OpenACC privatization level: 'vector'} {} { target { ! openacc_host_selected } } l$c }
187 ! { dg-note {variable 'i\.[0-9]+' in 'private' clause isn't candidate for adjusting OpenACC privatization level: not addressable} {} { target *-*-* } l$c }
188 ! { dg-optimized {assigned OpenACC gang vector loop parallelism} {} { target *-*-* } l$c }
199 if (.not
.acc_is_present (b
)) error
stop
202 if (b(i
) /= i
*i
) error
stop
206 end program test
! { dg-line l[incr c] }
207 ! { dg-bogus {note: variable 'overflow\.[0-9]+' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} {TODO n/a} { xfail *-*-* } l$c }
208 ! { dg-bogus {note: variable 'not_prev_allocated\.[0-9]+' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} {TODO n/a} { xfail *-*-* } l$c }
209 ! { dg-bogus {note: variable 'parm\.[0-9]+' declared in block isn't candidate for adjusting OpenACC privatization level: artificial} {TODO n/a} { xfail *-*-* } l$c }
211 ! Set each element in array 'b' at index i to i*2.
213 subroutine sub1
! { dg-line subroutine_sub1 }
218 ! { dg-bogus {[Ww]arning: region is worker partitioned but does not contain worker partitioned code} {TODO default 'gang' 'vector'} { xfail *-*-* } subroutine_sub1 }
220 !$acc loop ! { dg-line l[incr c] }
221 ! { dg-note {variable 'i' in 'private' clause isn't candidate for adjusting OpenACC privatization level: not addressable} {} { target *-*-* } l$c }
222 ! { dg-optimized {assigned OpenACC gang vector loop parallelism} {} { target *-*-* } l$c }
228 ! Allocate array 'b', and set it to all 1.0.
238 if (.not
.allocated (b
)) error
stop
239 if (.not
.acc_is_present (b
)) error
stop
241 !$acc parallel loop ! { dg-line l[incr c] }
242 ! { dg-note {variable 'i' in 'private' clause isn't candidate for adjusting OpenACC privatization level: not addressable} {} { target *-*-* } l$c }
243 ! { dg-optimized {assigned OpenACC gang vector loop parallelism} {} { target *-*-* } l$c }
251 real*8 function fun1 (i
)
260 ! Return b(i) * i * i;
262 real*8 function fun2 (i
)