RISC-V: Implement TARGET_CAN_INLINE_P
[official-gcc.git] / libgomp / testsuite / libgomp.oacc-fortran / host_data-5.F90
blobc3453a579aea14b653b81b84733f8666c2741e07
1 ! { dg-do run }
3 ! Test if, if_present clauses on host_data construct.
5 ! { dg-additional-options "-fopt-info-all-omp" }
6 ! { dg-additional-options "--param=openacc-privatization=noisy" }
7 ! { dg-additional-options "-foffload=-fopt-info-all-omp" }
8 ! { dg-additional-options "-foffload=--param=openacc-privatization=noisy" }
9 ! for testing/documenting aspects of that functionality.
11 ! Fortran variant of 'libgomp.oacc-c-c++-common/host_data-7.c'.
13 program main
14   use iso_c_binding
15   implicit none
16   real, target :: var, arr(100)
17   integer(c_intptr_t) :: host_p, host_parr
18   host_p = transfer(c_loc(var), host_p)
19   host_parr = transfer(c_loc(arr), host_parr)
20   call foo (var, arr, host_p, host_parr, .false.)
21   call foo (var, arr, host_p, host_parr, .true.)
23 contains
25 subroutine foo (p2, parr, host_p, host_parr, cond)
26   use openacc
27   implicit none
28   real, target, intent(in) :: parr(:), p2
29   integer(c_intptr_t), value, intent(in) :: host_p, host_parr
30   logical, value, intent(in) :: cond
31   real, pointer :: p
32   p => p2
34   if (host_p /= transfer(c_loc(p), host_p)) stop 1
35   if (host_parr /= transfer(c_loc(parr), host_parr)) stop 2
36 #if !ACC_MEM_SHARED
37   if (acc_is_present(p, c_sizeof(p))) stop 3
38   if (acc_is_present(parr, 1)) stop 4
39 #endif
40   
41   !$acc data copyin(host_p, host_parr)
42   ! { dg-note {variable 'C\.[0-9]+' declared in block potentially has improper OpenACC privatization level: 'const_decl'} "TODO" { target { ! openacc_host_selected } } .-1 }
43   ! { dg-note {variable 'D\.[0-9]+' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target { ! openacc_host_selected } } .-2 }
44   ! { dg-note {variable 'p\.[0-9]+' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } .-3 }
45   ! { dg-note {variable 'parr\.[0-9]+' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } .-4 }
46   ! { dg-note {variable 'parm\.[0-9]+' declared in block isn't candidate for adjusting OpenACC privatization level: artificial} "" { target { ! openacc_host_selected } } .-5 }
47 #if !ACC_MEM_SHARED
48     if (acc_is_present(p, c_sizeof(p))) stop 5
49     if (acc_is_present(parr, 1)) stop 6
50 #endif
51     !$acc host_data use_device(p, parr) if_present
52     ! { dg-note {variable 'D\.[0-9]+' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } .-1 }
53     ! { dg-note {variable 'transfer\.[0-9]+' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } .-2 }
54     ! { dg-note {variable 'host_p\.[0-9]+' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } .-3 }
55     ! { dg-note {variable 'parr\.[0-9]+' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } .-4 }
56     ! { dg-note {variable 'host_parr\.[0-9]+' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } .-5 }
57     ! { dg-note {variable 'D\.[0-9]+' declared in block isn't candidate for adjusting OpenACC privatization level: artificial} "" { target *-*-* } .-6 }
58     ! { dg-note {variable 'transfer\.[0-9]+' declared in block isn't candidate for adjusting OpenACC privatization level: artificial} "" { target *-*-* } .-7 }
59     ! { dg-note {variable 'parm\.[0-9]+' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } .-8 }
60       ! not mapped yet, so it will be equal to the host pointer.
61       if (transfer(c_loc(p), host_p) /= host_p) stop 7
62       if (transfer(c_loc(parr), host_parr) /= host_parr) stop 8
63     !$acc end host_data
64 #if !ACC_MEM_SHARED
65     if (acc_is_present(p, c_sizeof(p))) stop 9
66     if (acc_is_present(parr, 1)) stop 10
67 #endif
69     !$acc data copy(p, parr)
70     ! { dg-note {variable 'p\.[0-9]+' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } .-1 }
71     ! { dg-note {variable 'D\.[0-9]+' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } .-2 }
72     ! { dg-note {variable 'parr\.[0-9]+' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } .-3 }
73     ! { dg-note {variable 'transfer\.[0-9]+' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } .-4 }
74     ! { dg-note {variable 'host_p\.[0-9]+' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } .-5 }
75     ! { dg-note {variable 'host_parr\.[0-9]+' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } .-6 }
76     ! { dg-note {variable 'C\.[0-9]+' declared in block potentially has improper OpenACC privatization level: 'const_decl'} "TODO" { target *-*-* } .-7 }
77     ! { dg-note {variable 'parm\.[0-9]+' declared in block isn't candidate for adjusting OpenACC privatization level: artificial} "" { target *-*-* } .-8 }
78     ! { dg-note {variable 'D\.[0-9]+' declared in block isn't candidate for adjusting OpenACC privatization level: artificial} "" { target *-*-* } .-9 }
79     ! { dg-note {variable 'transfer\.[0-9]+' declared in block isn't candidate for adjusting OpenACC privatization level: artificial} "" { target *-*-* } .-10 }
80     ! { dg-note {variable 'parm\.[0-9]+' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } .-11 }
81       if (.not. acc_is_present(p, c_sizeof(p))) stop 11
82       if (.not. acc_is_present(parr, 1)) stop 12
83       ! Not inside a host_data construct, so still the host pointer.
84       if (transfer(c_loc(p), host_p) /= host_p) stop 13
85       if (transfer(c_loc(parr), host_parr) /= host_parr) stop 14
86       
87       !$acc host_data use_device(p, parr)
88       ! { dg-note {variable 'D\.[0-9]+' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } .-1 }
89       ! { dg-note {variable 'transfer\.[0-9]+' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } .-2 }
90       ! { dg-note {variable 'host_p\.[0-9]+' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } .-3 }
91       ! { dg-note {variable 'parr\.[0-9]+' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } .-4 }
92       ! { dg-note {variable 'host_parr\.[0-9]+' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } .-5 }
93       ! { dg-note {variable 'D\.[0-9]+' declared in block isn't candidate for adjusting OpenACC privatization level: artificial} "" { target *-*-* } .-6 }
94       ! { dg-note {variable 'transfer\.[0-9]+' declared in block isn't candidate for adjusting OpenACC privatization level: artificial} "" { target *-*-* } .-7 }
95       ! { dg-note {variable 'parm\.[0-9]+' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } .-8 }
96 #if ACC_MEM_SHARED
97         if (transfer(c_loc(p), host_p) /= host_p) stop 15
98         if (transfer(c_loc(parr), host_parr) /= host_parr) stop 16
99 #else
100         ! The device address is different from host address.
101         if (transfer(c_loc(p), host_p) == host_p) stop 17
102         if (transfer(c_loc(parr), host_parr) == host_parr) stop 18
103 #endif
104       !$acc end host_data
106       !$acc host_data use_device(p, parr) if_present
107         ! { dg-note {variable 'D\.[0-9]+' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } .-1 }
108         ! { dg-note {variable 'transfer\.[0-9]+' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } .-2 }
109         ! { dg-note {variable 'host_p\.[0-9]+' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } .-3 }
110         ! { dg-note {variable 'parr\.[0-9]+' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } .-4 }
111         ! { dg-note {variable 'host_parr\.[0-9]+' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } .-5 }
112         ! { dg-note {variable 'parm\.[0-9]+' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } .-6 }
113         ! { dg-note {variable 'D\.[0-9]+' declared in block isn't candidate for adjusting OpenACC privatization level: artificial} "" { target *-*-* } .-7 }
114         ! { dg-note {variable 'transfer\.[0-9]+' declared in block isn't candidate for adjusting OpenACC privatization level: artificial} "" { target *-*-* } .-8 }
115 #if ACC_MEM_SHARED
116         if (transfer(c_loc(p), host_p) /= host_p) stop 19
117         if (transfer(c_loc(parr), host_parr) /= host_parr) stop 20
118 #else
119         ! is present now, so this is the same as above.
120         if (transfer(c_loc(p), host_p) == host_p) stop 21
121         if (transfer(c_loc(parr), host_parr) == host_parr) stop 22
122 #endif
123       !$acc end host_data
125       !$acc host_data use_device(p, parr) if(cond)
126         ! { dg-note {variable 'D\.[0-9]+' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } .-1 }
127         ! { dg-note {variable 'transfer\.[0-9]+' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } .-2 }
128         ! { dg-note {variable 'host_p\.[0-9]+' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } .-3 }
129         ! { dg-note {variable 'parr\.[0-9]+' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } .-4 }
130         ! { dg-note {variable 'host_parr\.[0-9]+' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } .-5 }
131         ! { dg-note {variable 'parm\.[0-9]+' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } .-6 }
132         ! { dg-note {variable 'D\.[0-9]+' declared in block isn't candidate for adjusting OpenACC privatization level: artificial} "" { target *-*-* } .-7 }
133         ! { dg-note {variable 'transfer\.[0-9]+' declared in block isn't candidate for adjusting OpenACC privatization level: artificial} "" { target *-*-* } .-8 }
134 #if ACC_MEM_SHARED
135         if (transfer(c_loc(p), host_p) /= host_p) stop 23
136         if (transfer(c_loc(parr), host_parr) /= host_parr) stop 24
137 #else
138         ! is the device pointer iff cond is true.
139         if ((transfer(c_loc(p), host_p) /= host_p) .neqv. cond) stop 25
140         if ((transfer(c_loc(parr), host_parr) /= host_parr) .neqv. cond) stop 26
141 #endif
142       !$acc end host_data
143     !$acc end data
144   !$acc end data
145 end subroutine foo