From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1643) id 468493857402; Wed, 2 Nov 2022 21:07:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 468493857402 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1667423256; bh=O5HJXV+IH0n/QWDzPDtphP6YkYYKSqbZTHyv9uaKkFs=; h=From:To:Subject:Date:From; b=F0KnzByOCYsAA/KOXifJsG0MOyhw4TpQCe/Acy1RagFWpN/V7aizrxbKO6lqONj73 BDbwZLv2LJAnIrsdGT8le0vFdtriwBEhZGZd+GREQ/3JAnApzVeLgdnCvPhGxZImPF rvhVNYyt4S/2gDPK3MKni9i/Et6hs3d0B+5mTKf8= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Thomas Schwinge To: gcc-cvs@gcc.gnu.org Subject: [gcc/devel/omp/gcc-12] Add 'libgomp.oacc-fortran/declare-allocatable-1-runtime.f90' X-Act-Checkin: gcc X-Git-Author: Thomas Schwinge X-Git-Refname: refs/heads/devel/omp/gcc-12 X-Git-Oldrev: 9fd571cbd993fb0c7496ba497775485c4619990d X-Git-Newrev: 63918a81a59349280f2e67324782c186cade0822 Message-Id: <20221102210736.468493857402@sourceware.org> Date: Wed, 2 Nov 2022 21:07:36 +0000 (GMT) List-Id: https://gcc.gnu.org/g:63918a81a59349280f2e67324782c186cade0822 commit 63918a81a59349280f2e67324782c186cade0822 Author: Thomas Schwinge Date: Fri Oct 14 17:36:51 2022 +0200 Add 'libgomp.oacc-fortran/declare-allocatable-1-runtime.f90' ... which is 'libgomp.oacc-fortran/declare-allocatable-1.f90' adjusted for missing support for OpenACC "Changes from Version 2.0 to 2.5": "The 'declare create' directive with a Fortran 'allocatable' has new behavior". Thus, after 'allocate'/before 'deallocate', call 'acc_create'/'acc_delete' manually. libgomp/ * testsuite/libgomp.oacc-fortran/declare-allocatable-1-runtime.f90: New. (cherry picked from commit 59c6c5dbf267cd9d0a8df72b2a5eb5657b64268e) Diff: --- libgomp/ChangeLog.omp | 6 + .../declare-allocatable-1-runtime.f90 | 278 +++++++++++++++++++++ 2 files changed, 284 insertions(+) diff --git a/libgomp/ChangeLog.omp b/libgomp/ChangeLog.omp index 3d28db31ac6..db1f2384925 100644 --- a/libgomp/ChangeLog.omp +++ b/libgomp/ChangeLog.omp @@ -1,5 +1,11 @@ 2022-11-02 Thomas Schwinge + Backported from master: + 2022-11-02 Thomas Schwinge + + * testsuite/libgomp.oacc-fortran/declare-allocatable-1-runtime.f90: + New. + Backported from master: 2022-11-02 Cesar Philippidis Thomas Schwinge diff --git a/libgomp/testsuite/libgomp.oacc-fortran/declare-allocatable-1-runtime.f90 b/libgomp/testsuite/libgomp.oacc-fortran/declare-allocatable-1-runtime.f90 new file mode 100644 index 00000000000..e4cb9c378a3 --- /dev/null +++ b/libgomp/testsuite/libgomp.oacc-fortran/declare-allocatable-1-runtime.f90 @@ -0,0 +1,278 @@ +! Test OpenACC 'declare create' with allocatable arrays. + +! { dg-do run } + +!TODO-OpenACC-declare-allocate +! Missing support for OpenACC "Changes from Version 2.0 to 2.5": +! "The 'declare create' directive with a Fortran 'allocatable' has new behavior". +! Thus, after 'allocate'/before 'deallocate', call 'acc_create'/'acc_delete' +! manually. + +!TODO { dg-additional-options -fno-inline } for stable results regarding OpenACC 'routine'. + +! { dg-additional-options -fopt-info-all-omp } +! { dg-additional-options -foffload=-fopt-info-all-omp } + +! { dg-additional-options --param=openacc-privatization=noisy } +! { dg-additional-options -foffload=--param=openacc-privatization=noisy } +! Prune a few: uninteresting, and potentially varying depending on GCC configuration (data types): +! { dg-prune-output {note: variable '[Di]\.[0-9]+' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} } + +! { dg-additional-options -Wopenacc-parallelism } + +! It's only with Tcl 8.5 (released in 2007) that "the variable 'varName' +! passed to 'incr' may be unset, and in that case, it will be set to [...]", +! so to maintain compatibility with earlier Tcl releases, we manually +! initialize counter variables: +! { dg-line l_dummy[variable c 0] } +! { dg-message dummy {} { target iN-VAl-Id } l_dummy } to avoid +! "WARNING: dg-line var l_dummy defined, but not used". + + +module vars + implicit none + integer, parameter :: n = 100 + real*8, allocatable :: b(:) + !$acc declare create (b) +end module vars + +program test + use vars + use openacc + implicit none + real*8 :: a + integer :: i + + interface + subroutine sub1 + !$acc routine gang + end subroutine sub1 + + subroutine sub2 + end subroutine sub2 + + real*8 function fun1 (ix) + integer ix + !$acc routine seq + end function fun1 + + real*8 function fun2 (ix) + integer ix + !$acc routine seq + end function fun2 + end interface + + if (allocated (b)) error stop + + ! Test local usage of an allocated declared array. + + allocate (b(n)) + call acc_create (b) + + if (.not.allocated (b)) error stop + if (.not.acc_is_present (b)) error stop + + a = 2.0 + + !$acc parallel loop ! { dg-line l[incr c] } + ! { dg-note {variable 'i' in 'private' clause is candidate for adjusting OpenACC privatization level} {} { target *-*-* } l$c } + ! { dg-note {variable 'i' ought to be adjusted for OpenACC privatization level: 'vector'} {} { target *-*-* } l$c } + ! { dg-note {variable 'i' adjusted for OpenACC privatization level: 'vector'} {} { target { ! openacc_host_selected } } l$c } + ! { dg-note {variable 'i\.[0-9]+' in 'private' clause isn't candidate for adjusting OpenACC privatization level: not addressable} {} { target *-*-* } l$c } + ! { dg-optimized {assigned OpenACC gang vector loop parallelism} {} { target *-*-* } l$c } + do i = 1, n + b(i) = i * a + end do + + if (.not.acc_is_present (b)) error stop + + !$acc update host(b) + + do i = 1, n + if (b(i) /= i*a) error stop + end do + + call acc_delete (b) + deallocate (b) + + ! Test the usage of an allocated declared array inside an acc + ! routine subroutine. + + allocate (b(n)) + call acc_create (b) + + if (.not.allocated (b)) error stop + if (.not.acc_is_present (b)) error stop + + !$acc parallel + call sub1 ! { dg-line l[incr c] } + ! { dg-optimized {assigned OpenACC gang worker vector loop parallelism} {} { target *-*-* } l$c } + !$acc end parallel + + if (.not.acc_is_present (b)) error stop + + !$acc update host(b) + + do i = 1, n + if (b(i) /= i*2) error stop + end do + + call acc_delete (b) + deallocate (b) + + ! Test the usage of an allocated declared array inside a host + ! subroutine. + + call sub2 + + if (.not.acc_is_present (b)) error stop + + !$acc update host(b) + + do i = 1, n + if (b(i) /= 1.0) error stop + end do + + call acc_delete (b) + deallocate (b) + + if (allocated (b)) error stop + + ! Test the usage of an allocated declared array inside an acc + ! routine function. + + allocate (b(n)) + call acc_create (b) + + if (.not.allocated (b)) error stop + if (.not.acc_is_present (b)) error stop + + !$acc parallel loop ! { dg-line l[incr c] } + ! { dg-note {variable 'i' in 'private' clause is candidate for adjusting OpenACC privatization level} {} { target *-*-* } l$c } + ! { dg-note {variable 'i' ought to be adjusted for OpenACC privatization level: 'vector'} {} { target *-*-* } l$c } + ! { dg-note {variable 'i' adjusted for OpenACC privatization level: 'vector'} {} { target { ! openacc_host_selected } } l$c } + ! { dg-note {variable 'i\.[0-9]+' in 'private' clause isn't candidate for adjusting OpenACC privatization level: not addressable} {} { target *-*-* } l$c } + ! { dg-optimized {assigned OpenACC gang vector loop parallelism} {} { target *-*-* } l$c } + do i = 1, n + b(i) = 1.0 + end do + + !$acc parallel loop ! { dg-line l[incr c] } + ! { dg-note {variable 'i' in 'private' clause is candidate for adjusting OpenACC privatization level} {} { target *-*-* } l$c } + ! { dg-note {variable 'i' ought to be adjusted for OpenACC privatization level: 'vector'} {} { target *-*-* } l$c } + ! { dg-note {variable 'i' adjusted for OpenACC privatization level: 'vector'} {} { target { ! openacc_host_selected } } l$c } + ! { dg-note {variable 'i\.[0-9]+' in 'private' clause isn't candidate for adjusting OpenACC privatization level: not addressable} {} { target *-*-* } l$c } + ! { dg-optimized {assigned OpenACC gang vector loop parallelism} {} { target *-*-* } l$c } + do i = 1, n + b(i) = fun1 (i) ! { dg-line l[incr c] } + ! { dg-optimized {assigned OpenACC seq loop parallelism} {} { target *-*-* } l$c } + end do + + if (.not.acc_is_present (b)) error stop + + !$acc update host(b) + + do i = 1, n + if (b(i) /= i) error stop + end do + + call acc_delete (b) + deallocate (b) + + ! Test the usage of an allocated declared array inside a host + ! function. + + allocate (b(n)) + call acc_create (b) + + if (.not.allocated (b)) error stop + if (.not.acc_is_present (b)) error stop + + !$acc parallel loop ! { dg-line l[incr c] } + ! { dg-note {variable 'i' in 'private' clause is candidate for adjusting OpenACC privatization level} {} { target *-*-* } l$c } + ! { dg-note {variable 'i' ought to be adjusted for OpenACC privatization level: 'vector'} {} { target *-*-* } l$c } + ! { dg-note {variable 'i' adjusted for OpenACC privatization level: 'vector'} {} { target { ! openacc_host_selected } } l$c } + ! { dg-note {variable 'i\.[0-9]+' in 'private' clause isn't candidate for adjusting OpenACC privatization level: not addressable} {} { target *-*-* } l$c } + ! { dg-optimized {assigned OpenACC gang vector loop parallelism} {} { target *-*-* } l$c } + do i = 1, n + b(i) = 1.0 + end do + + !$acc update host(b) + + do i = 1, n + b(i) = fun2 (i) + end do + + if (.not.acc_is_present (b)) error stop + + do i = 1, n + if (b(i) /= i*i) error stop + end do + + call acc_delete (b) + deallocate (b) +end program test ! { dg-line l[incr c] } +! { 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 } +! { 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 } +! { 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 } + +! Set each element in array 'b' at index i to i*2. + +subroutine sub1 ! { dg-line subroutine_sub1 } + use vars + implicit none + integer i + !$acc routine gang + ! { dg-bogus {[Ww]arning: region is worker partitioned but does not contain worker partitioned code} {TODO default 'gang' 'vector'} { xfail *-*-* } subroutine_sub1 } + + !$acc loop ! { dg-line l[incr c] } + ! { dg-note {variable 'i' in 'private' clause isn't candidate for adjusting OpenACC privatization level: not addressable} {} { target *-*-* } l$c } + ! { dg-optimized {assigned OpenACC gang vector loop parallelism} {} { target *-*-* } l$c } + do i = 1, n + b(i) = i*2 + end do +end subroutine sub1 + +! Allocate array 'b', and set it to all 1.0. + +subroutine sub2 + use vars + use openacc + implicit none + integer i + + allocate (b(n)) + call acc_create (b) + + if (.not.allocated (b)) error stop + if (.not.acc_is_present (b)) error stop + + !$acc parallel loop ! { dg-line l[incr c] } + ! { dg-note {variable 'i' in 'private' clause isn't candidate for adjusting OpenACC privatization level: not addressable} {} { target *-*-* } l$c } + ! { dg-optimized {assigned OpenACC gang vector loop parallelism} {} { target *-*-* } l$c } + do i = 1, n + b(i) = 1.0 + end do +end subroutine sub2 + +! Return b(i) * i; + +real*8 function fun1 (i) + use vars + implicit none + integer i + !$acc routine seq + + fun1 = b(i) * i +end function fun1 + +! Return b(i) * i * i; + +real*8 function fun2 (i) + use vars + implicit none + integer i + + fun2 = b(i) * i * i +end function fun2