Projet_SETI_RISC-V/riscv-gnu-toolchain/gcc/libgomp/testsuite/libgomp.oacc-fortran/deep-copy-5.f90

58 lines
979 B
Fortran
Raw Normal View History

2023-03-06 14:48:14 +01:00
! { dg-do run }
! Test of attach/detach, "enter data" inside "data", and subarray.
program dtype
implicit none
integer, parameter :: n = 512
type mytype
integer, allocatable :: a(:)
integer, allocatable :: b(:)
end type mytype
integer i
type(mytype) :: var
allocate(var%a(1:n))
allocate(var%b(1:n))
!$acc data copy(var)
do i = 1, n
var%a(i) = 0
var%b(i) = 0
end do
!$acc enter data copyin(var%a(5:n - 5), var%b(5:n - 5))
!$acc parallel loop
do i = 5,n - 5
var%a(i) = i
var%b(i) = i * 2
end do
!$acc end parallel loop
!$acc exit data copyout(var%a(5:n - 5), var%b(5:n - 5))
!$acc end data
do i = 1,4
if (var%a(i) .ne. 0) stop 1
if (var%b(i) .ne. 0) stop 2
end do
do i = 5,n - 5
if (i .ne. var%a(i)) stop 3
if (i * 2 .ne. var%b(i)) stop 4
end do
do i = n - 4,n
if (var%a(i) .ne. 0) stop 5
if (var%b(i) .ne. 0) stop 6
end do
deallocate(var%a)
deallocate(var%b)
end program dtype