Debian Codegraph @

libgomp/testsuite/libgomp.oacc-fortran/dynamic-pointer-1.f90

raw
1 ! Verify that a 'enter data'ed 'pointer' object creates a persistent, visible device copy
2
3 ! { dg-do run }
4 ! { dg-skip-if "" { *-*-* } { "*" } { "-DACC_MEM_SHARED=0" } }
5
6 module m
7 implicit none
8 contains
9
10 subroutine verify_a (a_ref, a)
11 implicit none
12 integer, dimension (:, :, :), allocatable :: a_ref
13 integer, dimension (:, :, :), pointer :: a
14
15 !$acc routine seq
16
17 if (any (lbound (a) /= lbound (a_ref))) stop 101
18 if (any (ubound (a) /= ubound (a_ref))) stop 102
19 if (size (a) /= size (a_ref)) stop 103
20 end subroutine verify_a
21
22 end module m
23
24 program main
25 use m
26 use openacc
27 implicit none
28 integer, parameter :: n = 30
29 integer, dimension (:, :, :), allocatable, target :: a1, a2
30 integer, dimension (:, :, :), pointer :: p
31
32 allocate (a1(1:n, 0:n-1, 10:n/2))
33 !$acc enter data create(a1)
34 allocate (a2(3:n/3, 10:n, n-10:n+10))
35 !$acc enter data create(a2)
36
37 p => a1
38 call verify_a(a1, p)
39
40 ! 'p' object isn't present on the device.
41 !$acc parallel ! Implicit 'copy(p)'; creates 'p' object...
42 call verify_a(a1, p)
43 !$acc end parallel ! ..., and deletes it again.
44
45 p => a2
46 call verify_a(a2, p)
47
48 ! 'p' object isn't present on the device.
49 !$acc parallel ! Implicit 'copy(p)'; creates 'p' object...
50 call verify_a(a2, p)
51 !$acc end parallel ! ..., and deletes it again.
52
53 p => a1
54
55 !$acc enter data create(p)
56 ! 'p' object is now present on the device (visible device copy).
57 !TODO PR96080 if (.not. acc_is_present (p)) stop 1
58
59 !$acc parallel
60 ! On the device, got created as 'p => a1'.
61 call verify_a(a1, p)
62 !$acc end parallel
63 call verify_a(a1, p)
64
65 !$acc parallel
66 p => a2
67 ! On the device, 'p => a2' is now set.
68 call verify_a(a2, p)
69 !$acc end parallel
70 ! On the host, 'p => a1' persists.
71 call verify_a(a1, p)
72
73 !$acc parallel
74 ! On the device, 'p => a2' persists.
75 call verify_a(a2, p)
76 !$acc end parallel
77 ! On the host, 'p => a1' still persists.
78 call verify_a(a1, p)
79
80 p => a2
81
82 !$acc parallel
83 p => a1
84 ! On the device, 'p => a1' is now set.
85 call verify_a(a1, p)
86 !$acc end parallel
87 ! On the host, 'p => a2' persists.
88 call verify_a(a2, p)
89
90 !$acc parallel
91 ! On the device, 'p => a1' persists.
92 call verify_a(a1, p)
93 !$acc end parallel
94 ! On the host, 'p => a2' still persists.
95 call verify_a(a2, p)
96
97 end program main