blob: 9789598e8ec5bd263a16dcd869200dcdc48ffb1a [file]
! Check that offloaded simd loops copy out lastprivate dummy arguments,
! which are privatized by reference, under SIMT: the value of the last
! lane must reach the dummy argument. This used to ICE in
! lower_lastprivate_clauses. N is not a multiple of the warp size.
! { dg-do run }
! { dg-additional-options "-O2" }
! { dg-xfail-if "--param=offload-gpu-mode=simt-directed needs the amdgcn SIMT series" { offload_target_amdgcn } }
! { dg-additional-options "--param=offload-gpu-mode=simt-directed" { target offload_target_amdgcn } }
module lastprivate_ref_1_m
implicit none
integer, parameter :: n = 100
contains
! The DO variable is a dummy argument: it is linear.
subroutine dovar (b, d)
!$omp declare target
integer :: b(n), d
!$omp simd
do d = 1, n
b(d) = d
end do
end subroutine
subroutine lastpriv (b, x)
!$omp declare target
integer :: b(n), x, i
!$omp simd lastprivate(x)
do i = 1, n
x = 3 * i + 1
b(i) = x
end do
end subroutine
end module
program lastprivate_ref_1
use lastprivate_ref_1_m
implicit none
integer :: b(n), x, i
b = -1; x = 0
!$omp target map(tofrom: b, x)
call dovar (b, x)
!$omp end target
do i = 1, n
if (b(i) /= i) stop 1
end do
if (x /= n + 1) stop 2
b = -1; x = 0
!$omp target map(tofrom: b, x)
call lastpriv (b, x)
!$omp end target
do i = 1, n
if (b(i) /= 3 * i + 1) stop 3
end do
if (x /= 3 * n + 1) stop 4
end program