aboutsummaryrefslogtreecommitdiff
path: root/libgomp/testsuite/libgomp.oacc-fortran/deep-copy-5.f90
blob: 6843cf1d0fa1cabedb3f95c2e0d4153928fb3de0 (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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
! { 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