From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1643) id D133938515FC; Fri, 21 May 2021 14:26:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D133938515FC MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Thomas Schwinge To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-976] Add 'libgomp.oacc-fortran/privatized-ref-2.f90' X-Act-Checkin: gcc X-Git-Author: Tobias Burnus X-Git-Refname: refs/heads/master X-Git-Oldrev: 079c23cfe079f203d5df83fea8e92a60c7d7e878 X-Git-Newrev: 61796dc03befa9b7426d5bc7c336cca585944143 Message-Id: <20210521142609.D133938515FC@sourceware.org> Date: Fri, 21 May 2021 14:26:09 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 May 2021 14:26:09 -0000 https://gcc.gnu.org/g:61796dc03befa9b7426d5bc7c336cca585944143 commit r12-976-g61796dc03befa9b7426d5bc7c336cca585944143 Author: Tobias Burnus Date: Wed Jun 3 15:35:12 2020 +0200 Add 'libgomp.oacc-fortran/privatized-ref-2.f90' libgomp/ * testsuite/libgomp.oacc-fortran/privatized-ref-2.f90: New. Diff: --- .../libgomp.oacc-fortran/privatized-ref-2.f90 | 101 +++++++++++++++++++++ 1 file changed, 101 insertions(+) diff --git a/libgomp/testsuite/libgomp.oacc-fortran/privatized-ref-2.f90 b/libgomp/testsuite/libgomp.oacc-fortran/privatized-ref-2.f90 new file mode 100644 index 00000000000..6c3e1dcc211 --- /dev/null +++ b/libgomp/testsuite/libgomp.oacc-fortran/privatized-ref-2.f90 @@ -0,0 +1,101 @@ +! { dg-do run { target { ! openacc_nvidia_accel_selected } } } + +program main + implicit none (type, external) + integer :: j + integer, allocatable :: A(:) + character(len=:), allocatable :: my_str + character(len=15), allocatable :: my_str15 + + A = [(3*j, j=1, 10)] + call foo (A, size(A)) + call bar (A) + my_str = "1234567890" + call foo_str(my_str) + call bar_str(my_str) + my_str15 = "123456789012345" + call foobar (my_str15) + deallocate (A, my_str, my_str15) +contains + subroutine foo (array, nn) + integer :: i, nn + integer :: array(nn) + + !$acc parallel copyout(array) + array = [(-i, i = 1, nn)] + !$acc loop gang private(array) + do i = 1, 10 + array(i) = i + end do + if (any (array /= [(-i, i = 1, nn)])) error stop 1 + !$acc end parallel + end subroutine foo + subroutine bar (array) + integer :: i + integer :: array(:) + + !$acc parallel copyout(array) + array = [(-2*i, i = 1, size(array))] + !$acc loop gang private(array) + do i = 1, 10 + array(i) = 9*i + end do + if (any (array /= [(-2*i, i = 1, 10)])) error stop 2 + !$acc end parallel + end subroutine bar + subroutine foo_str(str) + integer :: i + character(len=*) :: str + + !$acc parallel copyout(str) + str = "abcdefghij" + !$acc loop gang private(str) + do i = 1, 10 + str(i:i) = achar(ichar('A') + i) + end do + if (str /= "abcdefghij") error stop 3 + !$acc end parallel + end + subroutine bar_str(str) + integer :: i + character(len=:), allocatable :: str + +! *************************************** +! FIXME: Fails due to PR middle-end/95499 +! *************************************** + !!$acc parallel copyout(str) + str = "abcdefghij" + !!$acc loop gang private(str) + !do i = 1, 10 + ! str(i:i) = achar(ichar('A') + i) + !end do + if (str /= "abcdefghij") error stop 5 + !!$acc end parallel + end + subroutine foobar (scalar) + integer :: i + character(len=15), optional :: scalar + + !$acc parallel copyout(scalar) + scalar = "abcdefghi-12345" + !$acc loop gang private(scalar) + do i = 1, 15 + scalar(i:i) = achar(ichar('A') + i) + end do + !$acc end parallel + if (scalar /= "abcdefghi-12345") error stop 6 + end subroutine foobar + subroutine foobar15 (scalar) + integer :: i + character(len=15), optional, allocatable :: scalar + + !$acc parallel copyout(scalar) + scalar = "abcdefghi-12345" + !$acc loop gang private(scalar) + do i = 1, 15 + scalar(i:i) = achar(ichar('A') + i) + end do + !$acc end parallel + if (scalar /= "abcdefghi-12345") error stop 1 + end subroutine foobar15 +end