2 ! { dg-skip-if "" { *-*-* } { "*" } { "-DACC_MEM_SHARED=0" } }
4 subroutine test(variant
)
10 integer, allocatable
:: arr2(:)
14 integer, target
:: tarr(10)
15 integer, pointer :: myptr(:)
17 allocate(myvar
%arr2(10))
25 call acc_copyin(myvar
)
26 call acc_copyin(myvar
%arr2
)
33 .or
. variant
== 5) then
34 !$acc enter data attach(myvar%arr2, myptr)
35 else if (variant
== 1 &
37 .or
. variant
== 4) then
38 !$acc enter data attach(myvar%arr2, myptr)
39 !$acc enter data attach(myvar%arr2, myptr)
45 !$acc serial present(myvar%arr2)
46 ! { dg-warning "using .vector_length \\(32\\)., ignoring 1" "" { target openacc_nvidia_accel_selected } .-1 }
48 myvar
%arr1(i
) = i
+ variant
49 myvar
%arr2(i
) = i
- variant
51 myptr(3) = 99 - variant
54 if (variant
== 0) then
55 !$acc exit data detach(myvar%arr2, myptr)
56 else if (variant
== 1) then
57 !$acc exit data detach(myvar%arr2, myptr)
58 !$acc exit data detach(myvar%arr2, myptr)
59 else if (variant
== 2) then
60 !$acc exit data detach(myvar%arr2, myptr)
61 !$acc exit data detach(myvar%arr2, myptr) finalize
62 else if (variant
== 3 &
63 .or
. variant
== 4) then
64 !$acc exit data detach(myvar%arr2, myptr) finalize
65 else if (variant
== 5) then
72 if (.not
. acc_is_present(myvar
%arr2
)) stop 10
73 if (.not
. acc_is_present(myvar
)) stop 11
74 if (.not
. acc_is_present(tarr
)) stop 12
76 call acc_copyout(myvar
%arr2
)
77 if (acc_is_present(myvar
%arr2
)) stop 20
78 if (.not
. acc_is_present(myvar
)) stop 21
79 if (.not
. acc_is_present(tarr
)) stop 22
80 call acc_copyout(myvar
)
81 if (acc_is_present(myvar
%arr2
)) stop 30
82 if (acc_is_present(myvar
)) stop 31
83 if (.not
. acc_is_present(tarr
)) stop 32
84 call acc_copyout(tarr
)
85 if (acc_is_present(myvar
%arr2
)) stop 40
86 if (acc_is_present(myvar
)) stop 41
87 if (acc_is_present(tarr
)) stop 42
90 if (myvar
%arr1(i
) .ne
. i
+ variant
) stop 50
91 if (variant
== 5) then
92 ! We have not detached, so have copyied out a device pointer, so cannot
93 ! access 'myvar%arr2' on the host.
95 if (myvar
%arr2(i
) .ne
. i
- variant
) stop 51
98 if (tarr(3) .ne
. 99 - variant
) stop 52
100 if (variant
== 5) then
101 ! If not explicitly stopping here, we'd in the following try to deallocate
102 ! the device pointer on the host, SIGSEGV.
121 ! Make sure that 'test(5)' has stopped the program.