286 lines · plain
1! The "thread_limit" clause was added to the "target" construct in OpenMP 5.1.2! RUN: %flang_fc1 -emit-hlfir -fopenmp -fopenmp-version=51 %s -o - | FileCheck %s --check-prefixes=BOTH,HOST3! RUN: %flang_fc1 -emit-hlfir -fopenmp -fopenmp-version=51 -fopenmp-is-target-device %s -o - | FileCheck %s --check-prefixes=BOTH,DEVICE4 5! BOTH-LABEL: func.func @_QPteams6subroutine teams()7 ! BOTH: omp.target8 9 ! HOST-SAME: host_eval(%{{.*}} -> %[[NUM_TEAMS:.*]], %{{.*}} -> %[[THREAD_LIMIT:.*]] : i32, i32)10 11 ! DEVICE-NOT: host_eval({{.*}})12 ! DEVICE-SAME: {13 !$omp target14 15 ! BOTH: omp.teams16 17 ! HOST-SAME: num_teams( to %[[NUM_TEAMS]] : i32) thread_limit(%[[THREAD_LIMIT]] : i32)18 ! DEVICE-SAME: num_teams({{.*}}) thread_limit({{.*}})19 !$omp teams num_teams(1) thread_limit(2)20 call foo()21 !$omp end teams22 23 !$omp end target24 25 ! BOTH: omp.teams26 ! BOTH-SAME: num_teams({{.*}}) thread_limit({{.*}}) {27 !$omp teams num_teams(1) thread_limit(2)28 call foo()29 !$omp end teams30end subroutine teams31 32! BOTH-LABEL: func.func @_QPdistribute_parallel_do33subroutine distribute_parallel_do()34 ! BOTH: omp.target35 36 ! HOST-SAME: host_eval(%{{.*}} -> %[[LB:.*]], %{{.*}} -> %[[UB:.*]], %{{.*}} -> %[[STEP:.*]], %{{.*}} -> %[[NUM_THREADS:.*]] : i32, i32, i32, i32)37 38 ! DEVICE-NOT: host_eval({{.*}})39 ! DEVICE-SAME: {40 41 ! BOTH: omp.teams42 !$omp target teams43 44 ! BOTH: omp.parallel45 46 ! HOST-SAME: num_threads(%[[NUM_THREADS]] : i32)47 ! DEVICE-SAME: num_threads({{.*}})48 49 ! BOTH: omp.distribute50 ! BOTH-NEXT: omp.wsloop51 ! BOTH-NEXT: omp.loop_nest52 53 ! HOST-SAME: (%{{.*}}) : i32 = (%[[LB]]) to (%[[UB]]) inclusive step (%[[STEP]])54 !$omp distribute parallel do num_threads(1)55 do i=1,1056 call foo()57 end do58 !$omp end distribute parallel do59 !$omp end target teams60 61 ! BOTH: omp.target62 ! BOTH-NOT: host_eval({{.*}})63 ! BOTH-SAME: {64 ! BOTH: omp.teams65 !$omp target teams66 call foo() !< Prevents this from being SPMD.67 68 ! BOTH: omp.parallel69 ! BOTH-SAME: num_threads({{.*}})70 ! BOTH: omp.distribute71 ! BOTH-NEXT: omp.wsloop72 !$omp distribute parallel do num_threads(1)73 do i=1,1074 call foo()75 end do76 !$omp end distribute parallel do77 !$omp end target teams78 79 ! BOTH: omp.teams80 !$omp teams81 82 ! BOTH: omp.parallel83 ! BOTH-SAME: num_threads({{.*}})84 ! BOTH: omp.distribute85 ! BOTH-NEXT: omp.wsloop86 !$omp distribute parallel do num_threads(1)87 do i=1,1088 call foo()89 end do90 !$omp end distribute parallel do91 !$omp end teams92end subroutine distribute_parallel_do93 94! BOTH-LABEL: func.func @_QPdistribute_parallel_do_simd95subroutine distribute_parallel_do_simd()96 ! BOTH: omp.target97 98 ! HOST-SAME: host_eval(%{{.*}} -> %[[LB:.*]], %{{.*}} -> %[[UB:.*]], %{{.*}} -> %[[STEP:.*]], %{{.*}} -> %[[NUM_THREADS:.*]] : i32, i32, i32, i32)99 100 ! DEVICE-NOT: host_eval({{.*}})101 ! DEVICE-SAME: {102 103 ! BOTH: omp.teams104 !$omp target teams105 106 ! BOTH: omp.parallel107 108 ! HOST-SAME: num_threads(%[[NUM_THREADS]] : i32)109 ! DEVICE-SAME: num_threads({{.*}})110 111 ! BOTH: omp.distribute112 ! BOTH-NEXT: omp.wsloop113 ! BOTH-NEXT: omp.simd114 ! BOTH-NEXT: omp.loop_nest115 116 ! HOST-SAME: (%{{.*}}) : i32 = (%[[LB]]) to (%[[UB]]) inclusive step (%[[STEP]])117 !$omp distribute parallel do simd num_threads(1)118 do i=1,10119 call foo()120 end do121 !$omp end distribute parallel do simd122 !$omp end target teams123 124 ! BOTH: omp.target125 ! BOTH-NOT: host_eval({{.*}})126 ! BOTH-SAME: {127 ! BOTH: omp.teams128 !$omp target teams129 call foo() !< Prevents this from being SPMD.130 131 ! BOTH: omp.parallel132 ! BOTH-SAME: num_threads({{.*}})133 ! BOTH: omp.distribute134 ! BOTH-NEXT: omp.wsloop135 ! BOTH-NEXT: omp.simd136 !$omp distribute parallel do simd num_threads(1)137 do i=1,10138 call foo()139 end do140 !$omp end distribute parallel do simd141 !$omp end target teams142 143 ! BOTH: omp.teams144 !$omp teams145 146 ! BOTH: omp.parallel147 ! BOTH-SAME: num_threads({{.*}})148 ! BOTH: omp.distribute149 ! BOTH-NEXT: omp.wsloop150 ! BOTH-NEXT: omp.simd151 !$omp distribute parallel do simd num_threads(1)152 do i=1,10153 call foo()154 end do155 !$omp end distribute parallel do simd156 !$omp end teams157end subroutine distribute_parallel_do_simd158 159! BOTH-LABEL: func.func @_QPdistribute160subroutine distribute()161 ! BOTH: omp.target162 163 ! HOST-SAME: host_eval(%{{.*}} -> %[[LB:.*]], %{{.*}} -> %[[UB:.*]], %{{.*}} -> %[[STEP:.*]] : i32, i32, i32)164 165 ! DEVICE-NOT: host_eval({{.*}})166 ! DEVICE-SAME: {167 168 ! BOTH: omp.teams169 !$omp target teams170 171 ! BOTH: omp.distribute172 ! BOTH-NEXT: omp.loop_nest173 174 ! HOST-SAME: (%{{.*}}) : i32 = (%[[LB]]) to (%[[UB]]) inclusive step (%[[STEP]])175 !$omp distribute176 do i=1,10177 call foo()178 end do179 !$omp end distribute180 !$omp end target teams181 182 ! BOTH: omp.target183 ! BOTH-NOT: host_eval({{.*}})184 ! BOTH-SAME: {185 ! BOTH: omp.teams186 !$omp target teams187 call foo() !< Prevents this from being Generic-SPMD.188 189 ! BOTH: omp.distribute190 !$omp distribute191 do i=1,10192 call foo()193 end do194 !$omp end distribute195 !$omp end target teams196 197 ! BOTH: omp.teams198 !$omp teams199 200 ! BOTH: omp.distribute201 !$omp distribute202 do i=1,10203 call foo()204 end do205 !$omp end distribute206 !$omp end teams207end subroutine distribute208 209! BOTH-LABEL: func.func @_QPdistribute_simd210subroutine distribute_simd()211 ! BOTH: omp.target212 213 ! HOST-SAME: host_eval(%{{.*}} -> %[[LB:.*]], %{{.*}} -> %[[UB:.*]], %{{.*}} -> %[[STEP:.*]] : i32, i32, i32)214 215 ! DEVICE-NOT: host_eval({{.*}})216 ! DEVICE-SAME: {217 218 ! BOTH: omp.teams219 !$omp target teams220 221 ! BOTH: omp.distribute222 ! BOTH-NEXT: omp.simd223 ! BOTH-NEXT: omp.loop_nest224 225 ! HOST-SAME: (%{{.*}}) : i32 = (%[[LB]]) to (%[[UB]]) inclusive step (%[[STEP]])226 !$omp distribute simd227 do i=1,10228 call foo()229 end do230 !$omp end distribute simd231 !$omp end target teams232 233 ! BOTH: omp.target234 ! BOTH-NOT: host_eval({{.*}})235 ! BOTH-SAME: {236 ! BOTH: omp.teams237 !$omp target teams238 call foo() !< Prevents this from being Generic-SPMD.239 240 ! BOTH: omp.distribute241 ! BOTH-NEXT: omp.simd242 !$omp distribute simd243 do i=1,10244 call foo()245 end do246 !$omp end distribute simd247 !$omp end target teams248 249 ! BOTH: omp.teams250 !$omp teams251 252 ! BOTH: omp.distribute253 ! BOTH-NEXT: omp.simd254 !$omp distribute simd255 do i=1,10256 call foo()257 end do258 !$omp end distribute simd259 !$omp end teams260end subroutine distribute_simd261 262! BOTH-LABEL: func.func @_QPloop263subroutine loop()264 ! BOTH: omp.target265 266 ! HOST-SAME: host_eval(%{{.*}} -> %[[LB:.*]], %{{.*}} -> %[[UB:.*]], %{{.*}} -> %[[STEP:.*]] : i32, i32, i32)267 268 ! DEVICE-NOT: host_eval({{.*}})269 ! DEVICE-SAME: {270 271 ! BOTH: omp.teams272 !$omp target teams273 274 ! BOTH: omp.parallel275 276 ! BOTH: omp.distribute277 ! BOTH-NEXT: omp.wsloop278 ! BOTH-NEXT: omp.loop_nest279 280 ! HOST-SAME: (%{{.*}}) : i32 = (%[[LB]]) to (%[[UB]]) inclusive step (%[[STEP]])281 !$omp loop282 do i=1,10283 end do284 !$omp end target teams285end subroutine loop286