244 lines · plain
1! RUN: %python %S/../test_errors.py %s %flang -fopenacc -pedantic2 3! Check OpenACC clause validity for the following construct and directive:4! 2.6.5 Data5! 2.14.6 Enter Data6! 2.14.7 Exit Data7 8program openacc_data_validity9 10 implicit none11 12 type atype13 real(8), dimension(10) :: arr14 real(8) :: s15 end type atype16 17 integer :: i, j, b, gang_size, vector_size, worker_size18 integer, parameter :: N = 25619 integer, dimension(N) :: c20 logical, dimension(N) :: d, e21 integer :: async122 integer :: wait1, wait223 real :: reduction_r24 logical :: reduction_l25 real(8), dimension(N, N) :: aa, bb, cc26 real(8), dimension(:), allocatable :: dd27 real(8), pointer :: p28 logical :: ifCondition = .TRUE.29 type(atype) :: t30 type(atype), dimension(10) :: ta31 32 real(8), dimension(N) :: a, f, g, h33 34 !ERROR: At least one of ATTACH, COPYIN, CREATE clause must appear on the ENTER DATA directive35 !$acc enter data36 37 !ERROR: Modifier is not allowed for the COPYIN clause on the ENTER DATA directive38 !$acc enter data copyin(zero: i)39 40 !ERROR: Only the ZERO modifier is allowed for the CREATE clause on the ENTER DATA directive41 !$acc enter data create(readonly: i)42 43 !ERROR: COPYOUT clause is not allowed on the ENTER DATA directive44 !$acc enter data copyin(i) copyout(i)45 46 !$acc enter data create(aa) if(.TRUE.)47 48 !$acc enter data create(a(1:10))49 50 !$acc enter data create(t%arr)51 52 !$acc enter data create(t%arr(2:4))53 54 !ERROR: At most one IF clause can appear on the ENTER DATA directive55 !$acc enter data create(aa) if(.TRUE.) if(ifCondition)56 57 !$acc enter data create(aa) if(ifCondition)58 59 !$acc enter data create(aa) async60 61 !ERROR: At most one ASYNC clause can appear on the ENTER DATA directive62 !$acc enter data create(aa) async async63 64 !$acc enter data create(aa) async(async1)65 66 !$acc enter data create(aa) async(1)67 68 !$acc enter data create(aa) wait(1)69 70 !$acc enter data create(aa) wait(wait1)71 72 !$acc enter data create(aa) wait(wait1, wait2)73 74 !$acc enter data create(aa) wait(wait1) wait(wait2)75 76 !ERROR: Argument `bb` on the ATTACH clause must be a variable or array with the POINTER or ALLOCATABLE attribute77 !$acc enter data attach(bb)78 79 !ERROR: At least one of COPYOUT, DELETE, DETACH clause must appear on the EXIT DATA directive80 !$acc exit data81 82 !ERROR: Modifier is not allowed for the COPYOUT clause on the EXIT DATA directive83 !$acc exit data copyout(zero: i)84 85 !$acc exit data delete(aa)86 87 !$acc exit data delete(aa) finalize88 89 ! OK90 !$acc exit data delete(aa) finalize finalize91 92 !ERROR: Argument `cc` on the DETACH clause must be a variable or array with the POINTER or ALLOCATABLE attribute93 !$acc exit data detach(cc)94 95 !ERROR: Argument on the DETACH clause must be a variable or array with the POINTER or ALLOCATABLE attribute96 !$acc exit data detach(/i/)97 98 !$acc exit data copyout(bb)99 100 !$acc exit data delete(aa) if(.TRUE.)101 102 !$acc exit data delete(aa) if(ifCondition)103 104 !ERROR: At most one IF clause can appear on the EXIT DATA directive105 !$acc exit data delete(aa) if(ifCondition) if(.TRUE.)106 107 !$acc exit data delete(aa) async108 109 !ERROR: At most one ASYNC clause can appear on the EXIT DATA directive110 !$acc exit data delete(aa) async async111 112 !$acc exit data delete(aa) async(async1)113 114 !$acc exit data delete(aa) async(1)115 116 !$acc exit data delete(aa) wait(1)117 118 !$acc exit data delete(aa) wait(wait1)119 120 !$acc exit data delete(aa) wait(wait1, wait2)121 122 !$acc exit data delete(aa) wait(wait1) wait(wait2)123 124 !ERROR: Only the ZERO modifier is allowed for the COPYOUT clause on the DATA directive125 !$acc data copyout(readonly: i)126 !$acc end data127 128 !ERROR: At most one IF clause can appear on the DATA directive129 !$acc data copy(i) if(.true.) if(.true.)130 !$acc end data131 132 !ERROR: At least one of COPYOUT, DELETE, DETACH clause must appear on the EXIT DATA directive133 !$acc exit data134 135 !PORTABILITY: At least one of ATTACH, COPY, COPYIN, COPYOUT, CREATE, DEFAULT, DEVICEPTR, NO_CREATE, PRESENT clause should appear on the DATA directive [-Wportability]136 !$acc data137 !$acc end data138 139 !$acc data copy(aa) if(.true.)140 !$acc end data141 142 !$acc data copy(aa) if(ifCondition)143 !$acc end data144 145 !$acc data copy(aa, bb, cc)146 !$acc end data147 148 !$acc data copyin(aa) copyin(readonly: bb) copyout(cc)149 !$acc end data150 151 !$acc data copyin(readonly: aa, bb) copyout(zero: cc)152 !$acc end data153 154 !$acc data create(aa, bb(:,:)) create(zero: cc(:,:))155 !$acc end data156 157 !$acc data no_create(aa) present(bb, cc)158 !$acc end data159 160 !$acc data deviceptr(aa) attach(dd, p)161 !$acc end data162 163 !$acc data copy(aa, bb) default(none)164 !$acc end data165 166 !$acc data copy(aa, bb) default(present)167 !$acc end data168 169 !ERROR: At most one DEFAULT clause can appear on the DATA directive170 !$acc data copy(aa, bb) default(none) default(present)171 !$acc end data172 173 !ERROR: At most one IF clause can appear on the DATA directive174 !$acc data copy(aa) if(.true.) if(ifCondition)175 !$acc end data176 177 !$acc data copyin(i)178 !ERROR: Unmatched PARALLEL directive179 !$acc end parallel180 181 !$acc data copy(aa) async182 !$acc end data183 184 !$acc data copy(aa) wait185 !$acc end data186 187 !$acc data copy(aa) device_type(default) wait188 !$acc end data189 190 !ERROR: At most one ASYNC clause can appear on the DATA directive or in group separated by the DEVICE_TYPE clause191 !$acc data copy(aa) async(async1) async(2)192 !$acc end data193 194 !$acc data copy(aa) async(async1) device_type(multicore) async(2) ! ok195 !$acc end data196 197 !ERROR: At most one ASYNC clause can appear on the DATA directive or in group separated by the DEVICE_TYPE clause198 !$acc data copy(aa) async(async1) device_type(multicore) async(2) async(3)199 !$acc end data200 201 do i = 1, 100202 !$acc data copy(aa)203 !ERROR: CYCLE to construct outside of DATA construct is not allowed204 if (i == 10) cycle205 !$acc end data206 end do207 208 !$acc data copy(aa)209 do i = 1, 100210 if (i == 10) cycle211 end do212 !$acc end data213 214end program openacc_data_validity215 216module mod1217 type :: t1218 integer :: a219 contains220 procedure :: t1_proc221 end type222 223contains224 225 226 subroutine t1_proc(this)227 class(t1) :: this228 end subroutine229 230 subroutine sub4(t)231 type(t1) :: t232 233 !ERROR: Only variables are allowed in data clauses on the DATA directive234 !$acc data copy(t%t1_proc)235 !$acc end data236 end subroutine237 238 subroutine sub5()239 integer, parameter :: iparam = 1024240 !$acc data copyin(iparam)241 !$acc end data242 end subroutine243end module244