Debian Codegraph @

libgomp/testsuite/libgomp.oacc-fortran/deep-copy-6.f90

raw
1 ! { dg-do run }
2
3 ! Test of attachment counters and finalize.
4
5 program dtype
6 use openacc
7 implicit none
8 integer, parameter :: n = 512
9 type mytype
10 integer, allocatable :: a(:)
11 integer, allocatable :: b(:)
12 end type mytype
13 integer i
14
15 type(mytype), target :: var
16 integer, pointer :: hostptr(:)
17
18 allocate(var%a(1:n))
19 allocate(var%b(1:n))
20
21 hostptr => var%a
22
23 !$acc data copy(var)
24
25 do i = 1, n
26 var%a(i) = 0
27 var%b(i) = 0
28 end do
29
30 !$acc enter data copyin(var%a(5:n - 5), var%b(5:n - 5))
31
32 do i = 1,20
33 !$acc enter data attach(var%a)
34 end do
35
36 !$acc parallel loop
37 do i = 5,n - 5
38 var%a(i) = i
39 var%b(i) = i * 2
40 end do
41 !$acc end parallel loop
42
43 if (.not. acc_is_present(var%a(5:n - 5))) stop 11
44 if (.not. acc_is_present(var%b(5:n - 5))) stop 12
45 if (.not. acc_is_present(var)) stop 13
46 !$acc exit data copyout(var%a(5:n - 5), var%b(5:n - 5)) finalize
47 if (acc_get_device_type() .ne. acc_device_host) then
48 if (acc_is_present(var%a(5:n - 5))) stop 21
49 if (acc_is_present(var%b(5:n - 5))) stop 22
50 end if
51 if (.not. acc_is_present(var)) stop 23
52
53 !$acc end data
54
55 ! See 'deep-copy-6-no_finalize.F90'.
56 if (.not. associated(hostptr, var%a)) stop 30
57
58 do i = 1,4
59 if (var%a(i) .ne. 0) stop 1
60 if (var%b(i) .ne. 0) stop 2
61 end do
62
63 do i = 5,n - 5
64 if (i .ne. var%a(i)) stop 3
65 if (i * 2 .ne. var%b(i)) stop 4
66 end do
67
68 do i = n - 4,n
69 if (var%a(i) .ne. 0) stop 5
70 if (var%b(i) .ne. 0) stop 6
71 end do
72
73 deallocate(var%a)
74 deallocate(var%b)
75
76 end program dtype