aboutsummaryrefslogtreecommitdiff
path: root/libgomp/testsuite/libgomp.fortran/target-var.f90
blob: 5e5ccd47c9611b84e4ecae02043e78f7dec24c4b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
! { dg-additional-options "-O3" }
!
! With -O3 the static local variable A.10 generated for
! the array constructor [-2, -4, ..., -20] is optimized
! away - which has to be handled in the offload_vars table.
!
program main
  implicit none (type, external)
  integer :: j
  integer, allocatable :: A(:)

  A = [(3*j, j=1, 10)]
  call bar (A)
  deallocate (A)
contains
  subroutine bar (array)
    integer :: i
    integer :: array(:)

    !$omp target map(from:array)
    !$acc parallel copyout(array)
    array = [(-2*i, i = 1, size(array))]
    !$omp do private(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
    !$omp end target
    !$acc end parallel
  end subroutine bar
end