150 lines · plain
1! RUN: %python %S/../test_errors.py %s %flang -fopenacc2 3! Check OpenACC clause validity for the following construct and directive:4! 2.12 Atomic5 6program openacc_atomic_validity7 8 implicit none9 10 integer :: i11 integer, parameter :: N = 25612 integer, dimension(N) :: c13 logical :: l14 15 16 !$acc parallel17 !$acc atomic update18 c(i) = c(i) + 119 20 !$acc atomic update21 c(i) = c(i) + 122 !$acc end atomic23 24 !$acc atomic write25 c(i) = 1026 27 !$acc atomic write if(l)28 c(i) = 1029 30 !$acc atomic write31 c(i) = 1032 !$acc end atomic33 34 !$acc atomic write if(.true.)35 c(i) = 1036 !$acc end atomic37 38 !$acc atomic read39 i = c(i)40 41 !$acc atomic read if(.true.)42 i = c(i)43 44 !$acc atomic read45 i = c(i)46 !$acc end atomic47 48 !$acc atomic read if(l) 49 i = c(i)50 !$acc end atomic51 52 !ERROR: FINALIZE clause is not allowed on the ATOMIC READ FINALIZE IF(L)53 !$acc atomic read finalize if(l) 54 i = c(i)55 !$acc end atomic56 57 !TODO: Should error because c(i) references i which is the atomic update variable.58 !$acc atomic capture59 c(i) = i60 i = i + 161 !$acc end atomic62 63 !ERROR: The variables assigned in this atomic capture construct must be distinct64 !$acc atomic capture65 c(1) = c(2)66 c(1) = c(3)67 !$acc end atomic68 69 !ERROR: The assignments in this atomic capture construct do not update a variable and capture either its initial or final value70 !$acc atomic capture71 c(1) = c(2)72 c(2) = c(2)73 !$acc end atomic74 75 !ERROR: The assignments in this atomic capture construct do not update a variable and capture either its initial or final value76 !$acc atomic capture77 c(1) = c(2)78 c(2) = c(1)79 !$acc end atomic80 81 !ERROR: The assignments in this atomic capture construct do not update a variable and capture either its initial or final value82 !$acc atomic capture83 c(1) = c(2)84 c(3) = c(2)85 !$acc end atomic86 87 88 89 !$acc atomic capture if(l .EQV. .false.)90 c(i) = i91 i = i + 192 !$acc end atomic93 94 !$acc atomic update95 !ERROR: RHS of atomic update statement must be scalar96 !ERROR: LHS of atomic update statement must be scalar97 c = c + 198 99 !$acc atomic update if(i == 0)100 c(i) = c(i) + 1101 102 !ERROR: At most one IF clause can appear on the ATOMIC UPDATE IF(I == 0) IF(.TRUE.)103 !$acc atomic update if(i == 0) if(.true.)104 c(i) = c(i) + 1105 106 !$acc end parallel107 108end program openacc_atomic_validity109 110subroutine capture_with_convert_f64_to_i32()111 integer :: x112 real(8) :: v, w113 x = 1114 v = 0115 w = 2116 117 !$acc atomic capture118 x = x * 2.5_8119 v = x120 !$acc end atomic121 122 !$acc atomic capture123 !TODO: The rhs side of this update statement cannot reference v.124 x = x * v125 v = x126 !$acc end atomic127 128 !$acc atomic capture129 !TODO: The rhs side of this update statement cannot reference v.130 x = v * x131 v = x132 !$acc end atomic133 134 !$acc atomic capture135 !ERROR: The RHS of this atomic update statement must reference the updated variable: x136 x = v * v137 v = x138 !$acc end atomic139 140 !$acc atomic capture141 x = v142 !ERROR: The updated variable, v, cannot appear more than once in the atomic update operation143 v = v * v144 !$acc end atomic145 146 !$acc atomic capture147 v = x148 x = w * w149 !$acc end atomic150end subroutine capture_with_convert_f64_to_i32