| 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 |
| 3 |
|
| 4 |
!=============================================================================== |
| 5 |
! Target_Enter Simple |
| 6 |
!=============================================================================== |
| 7 |
|
| 8 |
!CHECK-LABEL: func.func @_QPomp_target_enter_simple() { |
| 9 |
subroutine omp_target_enter_simple |
| 10 |
integer :: a(1024) |
| 11 |
!CHECK: %[[BOUNDS:.*]] = omp.map.bounds lower_bound({{.*}}) upper_bound({{.*}}) extent({{.*}}) stride({{.*}}) start_idx({{.*}}) |
| 12 |
!CHECK: %[[MAP:.*]] = omp.map.info var_ptr({{.*}}) map_clauses(to) capture(ByRef) bounds(%[[BOUNDS]]) -> !fir.ref<!fir.array<1024xi32>> {name = "a"} |
| 13 |
!CHECK: omp.target_enter_data map_entries(%[[MAP]] : !fir.ref<!fir.array<1024xi32>>) |
| 14 |
!$omp target enter data map(to: a) |
| 15 |
return |
| 16 |
end subroutine omp_target_enter_simple |
| 17 |
|
| 18 |
!=============================================================================== |
| 19 |
! Target_Enter `depend` clause |
| 20 |
!=============================================================================== |
| 21 |
|
| 22 |
!CHECK-LABEL: func.func @_QPomp_target_enter_depend() { |
| 23 |
subroutine omp_target_enter_depend |
| 24 |
!CHECK: %[[A:.*]]:2 = hlfir.declare %{{.*}}(%{{.*}}) {uniq_name = "_QFomp_target_enter_dependEa"} : (!fir.ref<!fir.array<1024xi32>>, !fir.shape<1>) -> (!fir.ref<!fir.array<1024xi32>>, !fir.ref<!fir.array<1024xi32>>) |
| 25 |
integer :: a(1024) |
| 26 |
|
| 27 |
!CHECK: omp.task depend(taskdependout -> %[[A]]#1 : !fir.ref<!fir.array<1024xi32>>) { |
| 28 |
!$omp task depend(out: a) |
| 29 |
call foo(a) |
| 30 |
!$omp end task |
| 31 |
!CHECK: %[[BOUNDS:.*]] = omp.map.bounds lower_bound({{.*}}) upper_bound({{.*}}) extent({{.*}}) stride({{.*}}) start_idx({{.*}}) |
| 32 |
!CHECK: %[[MAP:.*]] = omp.map.info var_ptr({{.*}}) map_clauses(to) capture(ByRef) bounds(%[[BOUNDS]]) -> !fir.ref<!fir.array<1024xi32>> {name = "a"} |
| 33 |
!CHECK: omp.target_enter_data depend(taskdependin -> %[[A]]#1 : !fir.ref<!fir.array<1024xi32>>) map_entries(%[[MAP]] : !fir.ref<!fir.array<1024xi32>>) |
| 34 |
!$omp target enter data map(to: a) depend(in: a) |
| 35 |
return |
| 36 |
end subroutine omp_target_enter_depend |
| 37 |
|
| 38 |
!=============================================================================== |
| 39 |
! Target_Enter Map types |
| 40 |
!=============================================================================== |
| 41 |
|
| 42 |
!CHECK-LABEL: func.func @_QPomp_target_enter_mt() { |
| 43 |
subroutine omp_target_enter_mt |
| 44 |
integer :: a(1024) |
| 45 |
integer :: b(1024) |
| 46 |
integer :: c(1024) |
| 47 |
integer :: d(1024) |
| 48 |
!CHECK: %[[BOUNDS_0:.*]] = omp.map.bounds lower_bound({{.*}}) upper_bound({{.*}}) extent({{.*}}) stride({{.*}}) start_idx({{.*}}) |
| 49 |
!CHECK: %[[MAP_0:.*]] = omp.map.info var_ptr({{.*}}) map_clauses(to) capture(ByRef) bounds(%[[BOUNDS_0]]) -> !fir.ref<!fir.array<1024xi32>> {name = "a"} |
| 50 |
!CHECK: %[[BOUNDS_1:.*]] = omp.map.bounds lower_bound({{.*}}) upper_bound({{.*}}) extent({{.*}}) stride({{.*}}) start_idx({{.*}}) |
| 51 |
!CHECK: %[[MAP_1:.*]] = omp.map.info var_ptr(%{{.*}}) map_clauses(to) capture(ByRef) bounds(%[[BOUNDS_1]]) -> !fir.ref<!fir.array<1024xi32>> {name = "b"} |
| 52 |
!CHECK: %[[BOUNDS_2:.*]] = omp.map.bounds lower_bound({{.*}}) upper_bound({{.*}}) extent({{.*}}) stride({{.*}}) start_idx({{.*}}) |
| 53 |
!CHECK: %[[MAP_2:.*]] = omp.map.info var_ptr({{.*}}) map_clauses(always, exit_release_or_enter_alloc) capture(ByRef) bounds(%[[BOUNDS_2]]) -> !fir.ref<!fir.array<1024xi32>> {name = "c"} |
| 54 |
!CHECK: %[[BOUNDS_3:.*]] = omp.map.bounds lower_bound({{.*}}) upper_bound({{.*}}) extent({{.*}}) stride({{.*}}) start_idx({{.*}}) |
| 55 |
!CHECK: %[[MAP_3:.*]] = omp.map.info var_ptr({{.*}}) map_clauses(to) capture(ByRef) bounds(%[[BOUNDS_3]]) -> !fir.ref<!fir.array<1024xi32>> {name = "d"} |
| 56 |
!CHECK: omp.target_enter_data map_entries(%[[MAP_0]], %[[MAP_1]], %[[MAP_2]], %[[MAP_3]] : !fir.ref<!fir.array<1024xi32>>, !fir.ref<!fir.array<1024xi32>>, !fir.ref<!fir.array<1024xi32>>, !fir.ref<!fir.array<1024xi32>>) |
| 57 |
!$omp target enter data map(to: a, b) map(always, alloc: c) map(to: d) |
| 58 |
end subroutine omp_target_enter_mt |
| 59 |
|
| 60 |
!=============================================================================== |
| 61 |
! `Nowait` clause |
| 62 |
!=============================================================================== |
| 63 |
|
| 64 |
!CHECK-LABEL: func.func @_QPomp_target_enter_nowait() { |
| 65 |
subroutine omp_target_enter_nowait |
| 66 |
integer :: a(1024) |
| 67 |
!CHECK: %[[BOUNDS:.*]] = omp.map.bounds lower_bound({{.*}}) upper_bound({{.*}}) extent({{.*}}) stride({{.*}}) start_idx({{.*}}) |
| 68 |
!CHECK: %[[MAP:.*]] = omp.map.info var_ptr({{.*}}) map_clauses(to) capture(ByRef) bounds(%[[BOUNDS]]) -> !fir.ref<!fir.array<1024xi32>> {name = "a"} |
| 69 |
!CHECK: omp.target_enter_data nowait map_entries(%[[MAP]] : !fir.ref<!fir.array<1024xi32>>) |
| 70 |
!$omp target enter data map(to: a) nowait |
| 71 |
end subroutine omp_target_enter_nowait |
| 72 |
|
| 73 |
!=============================================================================== |
| 74 |
! `if` clause |
| 75 |
!=============================================================================== |
| 76 |
|
| 77 |
!CHECK-LABEL: func.func @_QPomp_target_enter_if() { |
| 78 |
subroutine omp_target_enter_if |
| 79 |
integer :: a(1024) |
| 80 |
integer :: i |
| 81 |
i = 5 |
| 82 |
!CHECK: %[[VAL_3:.*]] = fir.load %[[VAL_1:.*]] : !fir.ref<i32> |
| 83 |
!CHECK: %[[VAL_4:.*]] = arith.constant 10 : i32 |
| 84 |
!CHECK: %[[VAL_5:.*]] = arith.cmpi slt, %[[VAL_3]], %[[VAL_4]] : i32 |
| 85 |
!CHECK: %[[BOUNDS:.*]] = omp.map.bounds lower_bound({{.*}}) upper_bound({{.*}}) extent({{.*}}) stride({{.*}}) start_idx({{.*}}) |
| 86 |
!CHECK: %[[MAP:.*]] = omp.map.info var_ptr({{.*}}) map_clauses(to) capture(ByRef) bounds(%[[BOUNDS]]) -> !fir.ref<!fir.array<1024xi32>> {name = "a"} |
| 87 |
!CHECK: omp.target_enter_data if(%[[VAL_5]]) map_entries(%[[MAP]] : !fir.ref<!fir.array<1024xi32>>) |
| 88 |
!$omp target enter data if(i<10) map(to: a) |
| 89 |
end subroutine omp_target_enter_if |
| 90 |
|
| 91 |
!=============================================================================== |
| 92 |
! `device` clause |
| 93 |
!=============================================================================== |
| 94 |
|
| 95 |
!CHECK-LABEL: func.func @_QPomp_target_enter_device() { |
| 96 |
subroutine omp_target_enter_device |
| 97 |
integer :: a(1024) |
| 98 |
!CHECK: %[[VAL_1:.*]] = arith.constant 2 : i32 |
| 99 |
!CHECK: %[[BOUNDS:.*]] = omp.map.bounds lower_bound({{.*}}) upper_bound({{.*}}) extent({{.*}}) stride({{.*}}) start_idx({{.*}}) |
| 100 |
!CHECK: %[[MAP:.*]] = omp.map.info var_ptr({{.*}}) map_clauses(to) capture(ByRef) bounds(%[[BOUNDS]]) -> !fir.ref<!fir.array<1024xi32>> {name = "a"} |
| 101 |
!CHECK: omp.target_enter_data device(%[[VAL_1]] : i32) map_entries(%[[MAP]] : !fir.ref<!fir.array<1024xi32>>) |
| 102 |
!$omp target enter data map(to: a) device(2) |
| 103 |
end subroutine omp_target_enter_device |
| 104 |
|
| 105 |
!=============================================================================== |
| 106 |
! Target_Exit Simple |
| 107 |
!=============================================================================== |
| 108 |
|
| 109 |
!CHECK-LABEL: func.func @_QPomp_target_exit_simple() { |
| 110 |
subroutine omp_target_exit_simple |
| 111 |
integer :: a(1024) |
| 112 |
!CHECK: %[[BOUNDS:.*]] = omp.map.bounds lower_bound({{.*}}) upper_bound({{.*}}) extent({{.*}}) stride({{.*}}) start_idx({{.*}}) |
| 113 |
!CHECK: %[[MAP:.*]] = omp.map.info var_ptr({{.*}}) map_clauses(from) capture(ByRef) bounds(%[[BOUNDS]]) -> !fir.ref<!fir.array<1024xi32>> {name = "a"} |
| 114 |
!CHECK: omp.target_exit_data map_entries(%[[MAP]] : !fir.ref<!fir.array<1024xi32>>) |
| 115 |
!$omp target exit data map(from: a) |
| 116 |
end subroutine omp_target_exit_simple |
| 117 |
|
| 118 |
!=============================================================================== |
| 119 |
! Target_Exit Map types |
| 120 |
!=============================================================================== |
| 121 |
|
| 122 |
!CHECK-LABEL: func.func @_QPomp_target_exit_mt() { |
| 123 |
subroutine omp_target_exit_mt |
| 124 |
integer :: a(1024) |
| 125 |
integer :: b(1024) |
| 126 |
integer :: c(1024) |
| 127 |
integer :: d(1024) |
| 128 |
integer :: e(1024) |
| 129 |
!CHECK: %[[BOUNDS_0:.*]] = omp.map.bounds lower_bound({{.*}}) upper_bound({{.*}}) extent({{.*}}) stride({{.*}}) start_idx({{.*}}) |
| 130 |
!CHECK: %[[MAP_0:.*]] = omp.map.info var_ptr({{.*}}) map_clauses(from) capture(ByRef) bounds(%[[BOUNDS_0]]) -> !fir.ref<!fir.array<1024xi32>> {name = "a"} |
| 131 |
!CHECK: %[[BOUNDS_1:.*]] = omp.map.bounds lower_bound({{.*}}) upper_bound({{.*}}) extent({{.*}}) stride({{.*}}) start_idx({{.*}}) |
| 132 |
!CHECK: %[[MAP_1:.*]] = omp.map.info var_ptr({{.*}}) map_clauses(from) capture(ByRef) bounds(%[[BOUNDS_1]]) -> !fir.ref<!fir.array<1024xi32>> {name = "b"} |
| 133 |
!CHECK: %[[BOUNDS_2:.*]] = omp.map.bounds lower_bound({{.*}}) upper_bound({{.*}}) extent({{.*}}) stride({{.*}}) start_idx({{.*}}) |
| 134 |
!CHECK: %[[MAP_2:.*]] = omp.map.info var_ptr({{.*}}) map_clauses(exit_release_or_enter_alloc) capture(ByRef) bounds(%[[BOUNDS_2]]) -> !fir.ref<!fir.array<1024xi32>> {name = "c"} |
| 135 |
!CHECK: %[[BOUNDS_3:.*]] = omp.map.bounds lower_bound({{.*}}) upper_bound({{.*}}) extent({{.*}}) stride({{.*}}) start_idx({{.*}}) |
| 136 |
!CHECK: %[[MAP_3:.*]] = omp.map.info var_ptr({{.*}}) map_clauses(always, delete) capture(ByRef) bounds(%[[BOUNDS_3]]) -> !fir.ref<!fir.array<1024xi32>> {name = "d"} |
| 137 |
!CHECK: %[[BOUNDS_4:.*]] = omp.map.bounds lower_bound({{.*}}) upper_bound({{.*}}) extent({{.*}}) stride({{.*}}) start_idx({{.*}}) |
| 138 |
!CHECK: %[[MAP_4:.*]] = omp.map.info var_ptr({{.*}}) map_clauses(from) capture(ByRef) bounds(%[[BOUNDS_4]]) -> !fir.ref<!fir.array<1024xi32>> {name = "e"} |
| 139 |
!CHECK: omp.target_exit_data map_entries(%[[MAP_0]], %[[MAP_1]], %[[MAP_2]], %[[MAP_3]], %[[MAP_4]] : !fir.ref<!fir.array<1024xi32>>, !fir.ref<!fir.array<1024xi32>>, !fir.ref<!fir.array<1024xi32>>, !fir.ref<!fir.array<1024xi32>>, !fir.ref<!fir.array<1024xi32>>) |
| 140 |
!$omp target exit data map(from: a,b) map(release: c) map(always, delete: d) map(from: e) |
| 141 |
end subroutine omp_target_exit_mt |
| 142 |
|
| 143 |
!=============================================================================== |
| 144 |
! `device` clause |
| 145 |
!=============================================================================== |
| 146 |
|
| 147 |
!CHECK-LABEL: func.func @_QPomp_target_exit_device() { |
| 148 |
subroutine omp_target_exit_device |
| 149 |
integer :: a(1024) |
| 150 |
integer :: d |
| 151 |
!CHECK: %[[VAL_2:.*]] = fir.load %[[VAL_1:.*]] : !fir.ref<i32> |
| 152 |
!CHECK: %[[BOUNDS:.*]] = omp.map.bounds lower_bound({{.*}}) upper_bound({{.*}}) extent({{.*}}) stride({{.*}}) start_idx({{.*}}) |
| 153 |
!CHECK: %[[MAP:.*]] = omp.map.info var_ptr({{.*}}) map_clauses(from) capture(ByRef) bounds(%[[BOUNDS]]) -> !fir.ref<!fir.array<1024xi32>> {name = "a"} |
| 154 |
!CHECK: omp.target_exit_data device(%[[VAL_2]] : i32) map_entries(%[[MAP]] : !fir.ref<!fir.array<1024xi32>>) |
| 155 |
!$omp target exit data map(from: a) device(d) |
| 156 |
end subroutine omp_target_exit_device |
| 157 |
|
| 158 |
!=============================================================================== |
| 159 |
! Target_Exit `depend` clause |
| 160 |
!=============================================================================== |
| 161 |
|
| 162 |
!CHECK-LABEL: func.func @_QPomp_target_exit_depend() { |
| 163 |
subroutine omp_target_exit_depend |
| 164 |
!CHECK: %[[A:.*]]:2 = hlfir.declare %{{.*}}(%{{.*}}) {uniq_name = "_QFomp_target_exit_dependEa"} : (!fir.ref<!fir.array<1024xi32>>, !fir.shape<1>) -> (!fir.ref<!fir.array<1024xi32>>, !fir.ref<!fir.array<1024xi32>>) |
| 165 |
integer :: a(1024) |
| 166 |
!CHECK: omp.task depend(taskdependout -> %[[A]]#1 : !fir.ref<!fir.array<1024xi32>>) { |
| 167 |
!$omp task depend(out: a) |
| 168 |
call foo(a) |
| 169 |
!$omp end task |
| 170 |
!CHECK: %[[BOUNDS:.*]] = omp.map.bounds lower_bound({{.*}}) upper_bound({{.*}}) extent({{.*}}) stride({{.*}}) start_idx({{.*}}) |
| 171 |
!CHECK: %[[MAP:.*]] = omp.map.info var_ptr({{.*}}) map_clauses(from) capture(ByRef) bounds(%[[BOUNDS]]) -> !fir.ref<!fir.array<1024xi32>> {name = "a"} |
| 172 |
!CHECK: omp.target_exit_data depend(taskdependout -> %[[A]]#1 : !fir.ref<!fir.array<1024xi32>>) map_entries(%[[MAP]] : !fir.ref<!fir.array<1024xi32>>) |
| 173 |
!$omp target exit data map(from: a) depend(out: a) |
| 174 |
end subroutine omp_target_exit_depend |
| 175 |
|
| 176 |
|
| 177 |
!=============================================================================== |
| 178 |
! Target_Update `depend` clause |
| 179 |
!=============================================================================== |
| 180 |
|
| 181 |
!CHECK-LABEL: func.func @_QPomp_target_update_depend() { |
| 182 |
subroutine omp_target_update_depend |
| 183 |
!CHECK: %[[A:.*]]:2 = hlfir.declare %{{.*}}(%{{.*}}) {uniq_name = "_QFomp_target_update_dependEa"} : (!fir.ref<!fir.array<1024xi32>>, !fir.shape<1>) -> (!fir.ref<!fir.array<1024xi32>>, !fir.ref<!fir.array<1024xi32>>) |
| 184 |
integer :: a(1024) |
| 185 |
|
| 186 |
!CHECK: omp.task depend(taskdependout -> %[[A]]#1 : !fir.ref<!fir.array<1024xi32>>) { |
| 187 |
!$omp task depend(out: a) |
| 188 |
call foo(a) |
| 189 |
!$omp end task |
| 190 |
|
| 191 |
!CHECK: %[[BOUNDS:.*]] = omp.map.bounds |
| 192 |
!CHECK: %[[MAP:.*]] = omp.map.info var_ptr(%[[A]]#0 : !fir.ref<!fir.array<1024xi32>>, !fir.array<1024xi32>) map_clauses(to) capture(ByRef) bounds(%[[BOUNDS]]) -> !fir.ref<!fir.array<1024xi32>> {name = "a"} |
| 193 |
!CHECK: omp.target_update depend(taskdependin -> %[[A]]#1 : !fir.ref<!fir.array<1024xi32>>) map_entries(%[[MAP]] : !fir.ref<!fir.array<1024xi32>>) |
| 194 |
!$omp target update to(a) depend(in:a) |
| 195 |
end subroutine omp_target_update_depend |
| 196 |
|
| 197 |
!=============================================================================== |
| 198 |
! Target_Update `to` clause |
| 199 |
!=============================================================================== |
| 200 |
|
| 201 |
!CHECK-LABEL: func.func @_QPomp_target_update_to() { |
| 202 |
subroutine omp_target_update_to |
| 203 |
integer :: a(1024) |
| 204 |
|
| 205 |
!CHECK-DAG: %[[A_DECL:.*]]:2 = hlfir.declare %{{.*}}(%{{.*}}) |
| 206 |
!CHECK-DAG: %[[BOUNDS:.*]] = omp.map.bounds |
| 207 |
|
| 208 |
!CHECK: %[[TO_MAP:.*]] = omp.map.info var_ptr(%[[A_DECL]]#0 : !fir.ref<!fir.array<1024xi32>>, !fir.array<1024xi32>) |
| 209 |
!CHECK-SAME: map_clauses(to) capture(ByRef) |
| 210 |
!CHECK-SAME: bounds(%[[BOUNDS]]) -> !fir.ref<!fir.array<1024xi32>> {name = "a"} |
| 211 |
|
| 212 |
!CHECK: omp.target_update map_entries(%[[TO_MAP]] : !fir.ref<!fir.array<1024xi32>>) |
| 213 |
!$omp target update to(a) |
| 214 |
end subroutine omp_target_update_to |
| 215 |
|
| 216 |
!=============================================================================== |
| 217 |
! Target_Update `from` clause |
| 218 |
!=============================================================================== |
| 219 |
|
| 220 |
!CHECK-LABEL: func.func @_QPomp_target_update_from() { |
| 221 |
subroutine omp_target_update_from |
| 222 |
integer :: a(1024) |
| 223 |
|
| 224 |
!CHECK-DAG: %[[A_DECL:.*]]:2 = hlfir.declare %{{.*}}(%{{.*}}) |
| 225 |
!CHECK-DAG: %[[BOUNDS:.*]] = omp.map.bounds |
| 226 |
|
| 227 |
!CHECK: %[[FROM_MAP:.*]] = omp.map.info var_ptr(%[[A_DECL]]#0 : !fir.ref<!fir.array<1024xi32>>, !fir.array<1024xi32>) |
| 228 |
!CHECK-SAME: map_clauses(from) capture(ByRef) |
| 229 |
!CHECK-SAME: bounds(%[[BOUNDS]]) -> !fir.ref<!fir.array<1024xi32>> {name = "a"} |
| 230 |
|
| 231 |
!CHECK: omp.target_update map_entries(%[[FROM_MAP]] : !fir.ref<!fir.array<1024xi32>>) |
| 232 |
!$omp target update from(a) |
| 233 |
end subroutine omp_target_update_from |
| 234 |
|
| 235 |
!=============================================================================== |
| 236 |
! Target_Update `if` clause |
| 237 |
!=============================================================================== |
| 238 |
|
| 239 |
!CHECK-LABEL: func.func @_QPomp_target_update_if() { |
| 240 |
subroutine omp_target_update_if |
| 241 |
integer :: a(1024) |
| 242 |
logical :: i |
| 243 |
|
| 244 |
!CHECK-DAG: %[[A_DECL:.*]]:2 = hlfir.declare %{{.*}}(%{{.*}}) |
| 245 |
!CHECK-DAG: %[[BOUNDS:.*]] = omp.map.bounds |
| 246 |
!CHECK-DAG: %[[COND:.*]] = fir.convert %{{.*}} : (!fir.logical<4>) -> i1 |
| 247 |
|
| 248 |
!CHECK: omp.target_update if(%[[COND]]) map_entries |
| 249 |
!$omp target update from(a) if(i) |
| 250 |
end subroutine omp_target_update_if |
| 251 |
|
| 252 |
!=============================================================================== |
| 253 |
! Target_Update `device` clause |
| 254 |
!=============================================================================== |
| 255 |
|
| 256 |
!CHECK-LABEL: func.func @_QPomp_target_update_device() { |
| 257 |
subroutine omp_target_update_device |
| 258 |
integer :: a(1024) |
| 259 |
logical :: i |
| 260 |
|
| 261 |
!CHECK-DAG: %[[A_DECL:.*]]:2 = hlfir.declare %{{.*}}(%{{.*}}) |
| 262 |
!CHECK-DAG: %[[BOUNDS:.*]] = omp.map.bounds |
| 263 |
!CHECK-DAG: %[[DEVICE:.*]] = arith.constant 1 : i32 |
| 264 |
|
| 265 |
!CHECK: omp.target_update device(%[[DEVICE]] : i32) map_entries |
| 266 |
!$omp target update from(a) device(1) |
| 267 |
end subroutine omp_target_update_device |
| 268 |
|
| 269 |
!=============================================================================== |
| 270 |
! Target_Update `nowait` clause |
| 271 |
!=============================================================================== |
| 272 |
|
| 273 |
!CHECK-LABEL: func.func @_QPomp_target_update_nowait() { |
| 274 |
subroutine omp_target_update_nowait |
| 275 |
integer :: a(1024) |
| 276 |
logical :: i |
| 277 |
|
| 278 |
!CHECK-DAG: %[[A_DECL:.*]]:2 = hlfir.declare %{{.*}}(%{{.*}}) |
| 279 |
!CHECK-DAG: %[[BOUNDS:.*]] = omp.map.bounds |
| 280 |
|
| 281 |
!CHECK: omp.target_update nowait map_entries |
| 282 |
!$omp target update from(a) nowait |
| 283 |
end subroutine omp_target_update_nowait |
| 284 |
|
| 285 |
!=============================================================================== |
| 286 |
! Target_Data with region |
| 287 |
!=============================================================================== |
| 288 |
|
| 289 |
!CHECK-LABEL: func.func @_QPomp_target_data() { |
| 290 |
subroutine omp_target_data |
| 291 |
!CHECK: %[[VAL_0:.*]] = fir.alloca !fir.array<1024xi32> {bindc_name = "a", uniq_name = "_QFomp_target_dataEa"} |
| 292 |
!CHECK: %[[A_DECL:.*]]:2 = hlfir.declare %[[VAL_0]](%{{.*}}) {uniq_name = "_QFomp_target_dataEa"} : (!fir.ref<!fir.array<1024xi32>>, !fir.shape<1>) -> (!fir.ref<!fir.array<1024xi32>>, !fir.ref<!fir.array<1024xi32>>) |
| 293 |
integer :: a(1024) |
| 294 |
!CHECK: %[[BOUNDS:.*]] = omp.map.bounds lower_bound({{.*}}) upper_bound({{.*}}) extent({{.*}}) stride({{.*}}) start_idx({{.*}}) |
| 295 |
!CHECK: %[[MAP:.*]] = omp.map.info var_ptr(%[[A_DECL]]#0 : !fir.ref<!fir.array<1024xi32>>, !fir.array<1024xi32>) map_clauses(tofrom) capture(ByRef) bounds(%[[BOUNDS]]) -> !fir.ref<!fir.array<1024xi32>> {name = "a"} |
| 296 |
!CHECK: omp.target_data map_entries(%[[MAP]] : !fir.ref<!fir.array<1024xi32>>) { |
| 297 |
!$omp target data map(tofrom: a) |
| 298 |
!CHECK: %[[C10:.*]] = arith.constant 10 : i32 |
| 299 |
!CHECK: %[[C1:.*]] = arith.constant 1 : index |
| 300 |
!CHECK: %[[A_1:.*]] = hlfir.designate %[[A_DECL]]#0 (%[[C1]]) : (!fir.ref<!fir.array<1024xi32>>, index) -> !fir.ref<i32> |
| 301 |
!CHECK: hlfir.assign %[[C10]] to %[[A_1]] : i32, !fir.ref<i32 |
| 302 |
a(1) = 10 |
| 303 |
!CHECK: omp.terminator |
| 304 |
!$omp end target data |
| 305 |
!CHECK: } |
| 306 |
end subroutine omp_target_data |
| 307 |
|
| 308 |
!CHECK-LABEL: func.func @_QPomp_target_data_mt |
| 309 |
subroutine omp_target_data_mt |
| 310 |
integer :: a(1024) |
| 311 |
integer :: b(1024) |
| 312 |
!CHECK: %[[VAR_A:.*]] = fir.alloca !fir.array<1024xi32> {bindc_name = "a", uniq_name = "_QFomp_target_data_mtEa"} |
| 313 |
!CHECK: %[[VAR_A_DECL:.*]]:2 = hlfir.declare %[[VAR_A]](%{{.*}}) {uniq_name = "_QFomp_target_data_mtEa"} : (!fir.ref<!fir.array<1024xi32>>, !fir.shape<1>) -> (!fir.ref<!fir.array<1024xi32>>, !fir.ref<!fir.array<1024xi32>>) |
| 314 |
!CHECK: %[[VAR_B:.*]] = fir.alloca !fir.array<1024xi32> {bindc_name = "b", uniq_name = "_QFomp_target_data_mtEb"} |
| 315 |
!CHECK: %[[VAR_B_DECL:.*]]:2 = hlfir.declare %[[VAR_B]](%{{.*}}) {uniq_name = "_QFomp_target_data_mtEb"} : (!fir.ref<!fir.array<1024xi32>>, !fir.shape<1>) -> (!fir.ref<!fir.array<1024xi32>>, !fir.ref<!fir.array<1024xi32>>) |
| 316 |
!CHECK: %[[BOUNDS_A:.*]] = omp.map.bounds lower_bound({{.*}}) upper_bound({{.*}}) extent({{.*}}) stride({{.*}}) start_idx({{.*}}) |
| 317 |
!CHECK: %[[MAP_A:.*]] = omp.map.info var_ptr(%[[VAR_A_DECL]]#0 : !fir.ref<!fir.array<1024xi32>>, !fir.array<1024xi32>) map_clauses(tofrom) capture(ByRef) bounds(%[[BOUNDS_A]]) -> !fir.ref<!fir.array<1024xi32>> {name = "a"} |
| 318 |
!CHECK: omp.target_data map_entries(%[[MAP_A]] : !fir.ref<!fir.array<1024xi32>>) { |
| 319 |
!$omp target data map(a) |
| 320 |
!CHECK: omp.terminator |
| 321 |
!$omp end target data |
| 322 |
!CHECK: } |
| 323 |
!CHECK: %[[BOUNDS_B:.*]] = omp.map.bounds lower_bound({{.*}}) upper_bound({{.*}}) extent({{.*}}) stride({{.*}}) start_idx({{.*}}) |
| 324 |
!CHECK: %[[MAP_B:.*]] = omp.map.info var_ptr(%[[VAR_B_DECL]]#0 : !fir.ref<!fir.array<1024xi32>>, !fir.array<1024xi32>) map_clauses(always, from) capture(ByRef) bounds(%[[BOUNDS_B]]) -> !fir.ref<!fir.array<1024xi32>> {name = "b"} |
| 325 |
!CHECK: omp.target_data map_entries(%[[MAP_B]] : !fir.ref<!fir.array<1024xi32>>) { |
| 326 |
!$omp target data map(always, from : b) |
| 327 |
!CHECK: omp.terminator |
| 328 |
!$omp end target data |
| 329 |
!CHECK: } |
| 330 |
end subroutine omp_target_data_mt |
| 331 |
|
| 332 |
!=============================================================================== |
| 333 |
! Target with region |
| 334 |
!=============================================================================== |
| 335 |
|
| 336 |
!CHECK-LABEL: func.func @_QPomp_target() { |
| 337 |
subroutine omp_target |
| 338 |
!CHECK: %[[VAL_1:.*]]:2 = hlfir.declare %{{.*}}(%{{.*}}) {uniq_name = "_QFomp_targetEa"} : (!fir.ref<!fir.array<1024xi32>>, !fir.shape<1>) -> (!fir.ref<!fir.array<1024xi32>>, !fir.ref<!fir.array<1024xi32>>) |
| 339 |
integer :: a(1024) |
| 340 |
!CHECK: %[[BOUNDS:.*]] = omp.map.bounds lower_bound({{.*}}) upper_bound({{.*}}) extent({{.*}}) stride({{.*}}) start_idx({{.*}}) |
| 341 |
!CHECK: %[[MAP:.*]] = omp.map.info var_ptr(%[[VAL_1]]#0 : !fir.ref<!fir.array<1024xi32>>, !fir.array<1024xi32>) map_clauses(tofrom) capture(ByRef) bounds(%[[BOUNDS]]) -> !fir.ref<!fir.array<1024xi32>> {name = "a"} |
| 342 |
!CHECK: omp.target map_entries(%[[MAP]] -> %[[ARG_0:.*]] : !fir.ref<!fir.array<1024xi32>>) { |
| 343 |
!CHECK: ^bb0(%[[ARG_0]]: !fir.ref<!fir.array<1024xi32>>): |
| 344 |
!$omp target map(tofrom: a) |
| 345 |
!CHECK: %[[VAL_7:.*]] = arith.constant 1024 : index |
| 346 |
!CHECK: %[[VAL_2:.*]] = fir.shape %[[VAL_7]] : (index) -> !fir.shape<1> |
| 347 |
!CHECK: %[[VAL_3:.*]]:2 = hlfir.declare %[[ARG_0]](%[[VAL_2]]) {uniq_name = "_QFomp_targetEa"} : (!fir.ref<!fir.array<1024xi32>>, !fir.shape<1>) -> (!fir.ref<!fir.array<1024xi32>>, !fir.ref<!fir.array<1024xi32>>) |
| 348 |
!CHECK: %[[VAL_4:.*]] = arith.constant 10 : i32 |
| 349 |
!CHECK: %[[VAL_5:.*]] = arith.constant 1 : index |
| 350 |
!CHECK: %[[VAL_6:.*]] = hlfir.designate %[[VAL_3]]#0 (%[[VAL_5]]) : (!fir.ref<!fir.array<1024xi32>>, index) -> !fir.ref<i32> |
| 351 |
!CHECK: hlfir.assign %[[VAL_4]] to %[[VAL_6]] : i32, !fir.ref<i32> |
| 352 |
a(1) = 10 |
| 353 |
!CHECK: omp.terminator |
| 354 |
!$omp end target |
| 355 |
!CHECK: } |
| 356 |
end subroutine omp_target |
| 357 |
|
| 358 |
!=============================================================================== |
| 359 |
! Target with region `depend` clause |
| 360 |
!=============================================================================== |
| 361 |
|
| 362 |
!CHECK-LABEL: func.func @_QPomp_target_depend() { |
| 363 |
subroutine omp_target_depend |
| 364 |
!CHECK: %[[EXTENT_A:.*]] = arith.constant 1024 : index |
| 365 |
!CHECK: %[[A:.*]]:2 = hlfir.declare %{{.*}}(%{{.*}}) {uniq_name = "_QFomp_target_dependEa"} : (!fir.ref<!fir.array<1024xi32>>, !fir.shape<1>) -> (!fir.ref<!fir.array<1024xi32>>, !fir.ref<!fir.array<1024xi32>>) |
| 366 |
integer :: a(1024) |
| 367 |
!CHECK: omp.task depend(taskdependout -> %[[A]]#1 : !fir.ref<!fir.array<1024xi32>>) { |
| 368 |
!$omp task depend(out: a) |
| 369 |
call foo(a) |
| 370 |
!$omp end task |
| 371 |
!CHECK: %[[STRIDE_A:.*]] = arith.constant 1 : index |
| 372 |
!CHECK: %[[LBOUND_A:.*]] = arith.constant 0 : index |
| 373 |
!CHECK: %[[UBOUND_A:.*]] = arith.subi %c1024, %c1 : index |
| 374 |
!CHECK: %[[BOUNDS_A:.*]] = omp.map.bounds lower_bound(%[[LBOUND_A]] : index) upper_bound(%[[UBOUND_A]] : index) extent(%[[EXTENT_A]] : index) stride(%[[STRIDE_A]] : index) start_idx(%[[STRIDE_A]] : index) |
| 375 |
!CHECK: %[[MAP_A:.*]] = omp.map.info var_ptr(%[[A]]#0 : !fir.ref<!fir.array<1024xi32>>, !fir.array<1024xi32>) map_clauses(tofrom) capture(ByRef) bounds(%[[BOUNDS_A]]) -> !fir.ref<!fir.array<1024xi32>> {name = "a"} |
| 376 |
!CHECK: omp.target depend(taskdependin -> %[[A]]#1 : !fir.ref<!fir.array<1024xi32>>) map_entries(%[[MAP_A]] -> %[[BB0_ARG:.*]] : !fir.ref<!fir.array<1024xi32>>) { |
| 377 |
!$omp target map(tofrom: a) depend(in: a) |
| 378 |
a(1) = 10 |
| 379 |
!CHECK: omp.terminator |
| 380 |
!$omp end target |
| 381 |
!CHECK: } |
| 382 |
end subroutine omp_target_depend |
| 383 |
|
| 384 |
!=============================================================================== |
| 385 |
! Target implicit capture |
| 386 |
!=============================================================================== |
| 387 |
|
| 388 |
!CHECK-LABEL: func.func @_QPomp_target_implicit() { |
| 389 |
subroutine omp_target_implicit |
| 390 |
!CHECK: %[[VAL_0:.*]] = arith.constant 1024 : index |
| 391 |
!CHECK: %[[VAL_1:.*]] = fir.alloca !fir.array<1024xi32> {bindc_name = "a", uniq_name = "_QFomp_target_implicitEa"} |
| 392 |
!CHECK: %[[VAL_2:.*]] = fir.shape %[[VAL_0]] : (index) -> !fir.shape<1> |
| 393 |
!CHECK: %[[VAL_3:.*]]:2 = hlfir.declare %[[VAL_1]](%[[VAL_2]]) {uniq_name = "_QFomp_target_implicitEa"} : (!fir.ref<!fir.array<1024xi32>>, !fir.shape<1>) -> (!fir.ref<!fir.array<1024xi32>>, !fir.ref<!fir.array<1024xi32>>) |
| 394 |
integer :: a(1024) |
| 395 |
!CHECK: %[[VAL_4:.*]] = omp.map.info var_ptr(%[[VAL_3]]#1 : !fir.ref<!fir.array<1024xi32>>, !fir.array<1024xi32>) map_clauses(implicit, tofrom) capture(ByRef) bounds(%{{.*}}) -> !fir.ref<!fir.array<1024xi32>> {name = "a"} |
| 396 |
!CHECK: omp.target map_entries(%[[VAL_4]] -> %[[VAL_6:.*]] : !fir.ref<!fir.array<1024xi32>>) { |
| 397 |
!CHECK: ^bb0(%[[VAL_6]]: !fir.ref<!fir.array<1024xi32>>): |
| 398 |
!$omp target |
| 399 |
!CHECK: %[[VAL_7:.*]] = arith.constant 1024 : index |
| 400 |
!CHECK: %[[VAL_8:.*]] = fir.shape %[[VAL_7]] : (index) -> !fir.shape<1> |
| 401 |
!CHECK: %[[VAL_9:.*]]:2 = hlfir.declare %[[VAL_6]](%[[VAL_8]]) {uniq_name = "_QFomp_target_implicitEa"} : (!fir.ref<!fir.array<1024xi32>>, !fir.shape<1>) -> (!fir.ref<!fir.array<1024xi32>>, !fir.ref<!fir.array<1024xi32>>) |
| 402 |
!CHECK: %[[VAL_10:.*]] = arith.constant 10 : i32 |
| 403 |
!CHECK: %[[VAL_11:.*]] = arith.constant 1 : index |
| 404 |
!CHECK: %[[VAL_12:.*]] = hlfir.designate %[[VAL_9]]#0 (%[[VAL_11]]) : (!fir.ref<!fir.array<1024xi32>>, index) -> !fir.ref<i32> |
| 405 |
!CHECK: hlfir.assign %[[VAL_10]] to %[[VAL_12]] : i32, !fir.ref<i32> |
| 406 |
a(1) = 10 |
| 407 |
!CHECK: omp.terminator |
| 408 |
!$omp end target |
| 409 |
!CHECK: } |
| 410 |
end subroutine omp_target_implicit |
| 411 |
|
| 412 |
!=============================================================================== |
| 413 |
! Target implicit capture nested |
| 414 |
!=============================================================================== |
| 415 |
|
| 416 |
!CHECK-LABEL: func.func @_QPomp_target_implicit_nested() { |
| 417 |
subroutine omp_target_implicit_nested |
| 418 |
integer::a, b |
| 419 |
!CHECK: omp.target map_entries(%{{.*}} -> %[[ARG0:.*]], %{{.*}} -> %[[ARG1:.*]] : !fir.ref<i32>, !fir.ref<i32>) { |
| 420 |
!CHECK: ^bb0(%[[ARG0]]: !fir.ref<i32>, %[[ARG1]]: !fir.ref<i32>): |
| 421 |
!$omp target |
| 422 |
!CHECK: %[[VAL_8:.*]]:2 = hlfir.declare %[[ARG0]] {uniq_name = "_QFomp_target_implicit_nestedEa"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>) |
| 423 |
!CHECK: %[[VAL_9:.*]]:2 = hlfir.declare %[[ARG1]] {uniq_name = "_QFomp_target_implicit_nestedEb"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>) |
| 424 |
!CHECK: %[[VAL_10:.*]] = arith.constant 10 : i32 |
| 425 |
!CHECK: hlfir.assign %[[VAL_10]] to %[[VAL_8]]#0 : i32, !fir.ref<i32> |
| 426 |
a = 10 |
| 427 |
!CHECK: omp.parallel |
| 428 |
!$omp parallel |
| 429 |
!CHECK: %[[VAL_11:.*]] = arith.constant 20 : i32 |
| 430 |
!CHECK: hlfir.assign %[[VAL_11]] to %[[VAL_9]]#0 : i32, !fir.ref<i32> |
| 431 |
b = 20 |
| 432 |
!CHECK: omp.terminator |
| 433 |
!$omp end parallel |
| 434 |
!CHECK: omp.terminator |
| 435 |
!$omp end target |
| 436 |
!CHECK: } |
| 437 |
end subroutine omp_target_implicit_nested |
| 438 |
|
| 439 |
!=============================================================================== |
| 440 |
! Target implicit capture with bounds |
| 441 |
!=============================================================================== |
| 442 |
|
| 443 |
!CHECK-LABEL: func.func @_QPomp_target_implicit_bounds( |
| 444 |
!CHECK: %[[VAL_0:.*]]: !fir.ref<i32> {fir.bindc_name = "n"}) { |
| 445 |
subroutine omp_target_implicit_bounds(n) |
| 446 |
!CHECK: %[[VAL_COPY:.*]] = fir.alloca i32 |
| 447 |
!CHECK: %[[VAL_1:.*]]:2 = hlfir.declare %[[VAL_0]] dummy_scope %{{[0-9]+}} {uniq_name = "_QFomp_target_implicit_boundsEn"} : (!fir.ref<i32>, !fir.dscope) -> (!fir.ref<i32>, !fir.ref<i32>) |
| 448 |
!CHECK: %[[VAL_2:.*]] = fir.load %[[VAL_1]]#0 : !fir.ref<i32> |
| 449 |
!CHECK: fir.store %[[VAL_2]] to %[[VAL_COPY]] : !fir.ref<i32> |
| 450 |
!CHECK: %[[VAL_3:.*]] = fir.convert %[[VAL_2]] : (i32) -> i64 |
| 451 |
!CHECK: %[[VAL_4:.*]] = fir.convert %[[VAL_3]] : (i64) -> index |
| 452 |
!CHECK: %[[VAL_5:.*]] = arith.constant 0 : index |
| 453 |
!CHECK: %[[VAL_6:.*]] = arith.cmpi sgt, %[[VAL_4]], %[[VAL_5]] : index |
| 454 |
!CHECK: %[[VAL_7:.*]] = arith.select %[[VAL_6]], %[[VAL_4]], %[[VAL_5]] : index |
| 455 |
!CHECK: %[[VAL_8:.*]] = fir.alloca !fir.array<?xi32>, %[[VAL_7]] {bindc_name = "a", uniq_name = "_QFomp_target_implicit_boundsEa"} |
| 456 |
!CHECK: %[[VAL_9:.*]] = fir.shape %[[VAL_7]] : (index) -> !fir.shape<1> |
| 457 |
!CHECK: %[[VAL_10:.*]]:2 = hlfir.declare %[[VAL_8]](%[[VAL_9]]) {uniq_name = "_QFomp_target_implicit_boundsEa"} : (!fir.ref<!fir.array<?xi32>>, !fir.shape<1>) -> (!fir.box<!fir.array<?xi32>>, !fir.ref<!fir.array<?xi32>>) |
| 458 |
!CHECK: %[[DIMS0:.*]]:3 = fir.box_dims %{{[0-9]+}}#0, %c0{{.*}} : (!fir.box<!fir.array<?xi32>>, index) -> (index, index, index) |
| 459 |
!CHECK: %[[UB:.*]] = arith.subi %[[DIMS0]]#1, %c1{{.*}} : index |
| 460 |
|
| 461 |
integer :: n |
| 462 |
integer :: a(n) |
| 463 |
!CHECK: %[[VAL_14:.*]] = omp.map.bounds lower_bound(%c0{{.*}} : index) upper_bound(%[[UB]] : index) extent(%[[DIMS0]]#1 : index) stride(%[[DIMS0]]#2 : index) start_idx(%c1{{.*}} : index) {stride_in_bytes = true} |
| 464 |
!CHECK: %[[VAL_15:.*]] = omp.map.info var_ptr(%[[VAL_10]]#1 : !fir.ref<!fir.array<?xi32>>, !fir.array<?xi32>) map_clauses(implicit, tofrom) capture(ByRef) bounds(%[[VAL_14]]) -> !fir.ref<!fir.array<?xi32>> {name = "a"} |
| 465 |
!CHECK: %[[VAL_16:.*]] = omp.map.info var_ptr(%[[VAL_COPY]] : !fir.ref<i32>, i32) map_clauses(implicit, exit_release_or_enter_alloc) capture(ByCopy) -> !fir.ref<i32> {name = ""} |
| 466 |
!CHECK: omp.target map_entries(%[[VAL_15]] -> %[[VAL_17:.*]], %[[VAL_16]] -> %[[VAL_18:.*]] : !fir.ref<!fir.array<?xi32>>, !fir.ref<i32>) { |
| 467 |
!CHECK: ^bb0(%[[VAL_17]]: !fir.ref<!fir.array<?xi32>>, %[[VAL_18]]: !fir.ref<i32>): |
| 468 |
!$omp target |
| 469 |
!CHECK: %[[VAL_19:.*]] = fir.load %[[VAL_18]] : !fir.ref<i32> |
| 470 |
!CHECK: %[[VAL_20:.*]] = fir.convert %[[VAL_19]] : (i32) -> i64 |
| 471 |
!CHECK: %[[VAL_21:.*]] = arith.constant 0 : index |
| 472 |
!CHECK: %[[VAL_22:.*]] = fir.convert %[[VAL_20]] : (i64) -> index |
| 473 |
!CHECK: %[[VAL_23:.*]] = arith.cmpi sgt, %[[VAL_22]], %[[VAL_21]] : index |
| 474 |
!CHECK: %[[VAL_24:.*]] = arith.select %[[VAL_23]], %[[VAL_22]], %[[VAL_21]] : index |
| 475 |
!CHECK: %[[VAL_25:.*]] = fir.shape %[[VAL_24]] : (index) -> !fir.shape<1> |
| 476 |
!CHECK: %[[VAL_26:.*]]:2 = hlfir.declare %[[VAL_17]](%[[VAL_25]]) {uniq_name = "_QFomp_target_implicit_boundsEa"} : (!fir.ref<!fir.array<?xi32>>, !fir.shape<1>) -> (!fir.box<!fir.array<?xi32>>, !fir.ref<!fir.array<?xi32>>) |
| 477 |
!CHECK: %[[VAL_27:.*]] = arith.constant 22 : i32 |
| 478 |
!CHECK: %[[VAL_28:.*]] = arith.constant 11 : index |
| 479 |
!CHECK: %[[VAL_29:.*]] = hlfir.designate %[[VAL_26]]#0 (%[[VAL_28]]) : (!fir.box<!fir.array<?xi32>>, index) -> !fir.ref<i32> |
| 480 |
!CHECK: hlfir.assign %[[VAL_27]] to %[[VAL_29]] : i32, !fir.ref<i32> |
| 481 |
a(11) = 22 |
| 482 |
!CHECK: omp.terminator |
| 483 |
!$omp end target |
| 484 |
!CHECK: } |
| 485 |
end subroutine omp_target_implicit_bounds |
| 486 |
|
| 487 |
!=============================================================================== |
| 488 |
! Target `thread_limit` clause |
| 489 |
!=============================================================================== |
| 490 |
|
| 491 |
!CHECK-LABEL: func.func @_QPomp_target_thread_limit() { |
| 492 |
subroutine omp_target_thread_limit |
| 493 |
integer :: a |
| 494 |
!CHECK: %[[MAP:.*]] = omp.map.info var_ptr({{.*}}) map_clauses(tofrom) capture(ByRef) -> !fir.ref<i32> {name = "a"} |
| 495 |
!CHECK: %[[VAL_1:.*]] = arith.constant 64 : i32 |
| 496 |
!CHECK: omp.target thread_limit(%[[VAL_1]] : i32) map_entries(%[[MAP]] -> %{{.*}} : !fir.ref<i32>) { |
| 497 |
!CHECK: ^bb0(%{{.*}}: !fir.ref<i32>): |
| 498 |
!$omp target map(tofrom: a) thread_limit(64) |
| 499 |
a = 10 |
| 500 |
!CHECK: omp.terminator |
| 501 |
!$omp end target |
| 502 |
!CHECK: } |
| 503 |
end subroutine omp_target_thread_limit |
| 504 |
|
| 505 |
!=============================================================================== |
| 506 |
! Target `use_device_ptr` clause |
| 507 |
!=============================================================================== |
| 508 |
|
| 509 |
!CHECK-LABEL: func.func @_QPomp_target_device_ptr() { |
| 510 |
subroutine omp_target_device_ptr |
| 511 |
use iso_c_binding, only : c_ptr, c_loc |
| 512 |
type(c_ptr) :: a |
| 513 |
integer, target :: b |
| 514 |
!CHECK: %[[MAP:.*]] = omp.map.info var_ptr({{.*}}) map_clauses(tofrom) capture(ByRef) -> {{.*}} {name = "a"} |
| 515 |
!CHECK: omp.target_data use_device_ptr({{.*}}) map_entries(%[[MAP]]{{.*}} |
| 516 |
!$omp target data map(tofrom: a) use_device_ptr(a) |
| 517 |
!CHECK: ^bb0(%[[VAL_1:.*]]: !fir.ref<!fir.type<_QM__fortran_builtinsT__builtin_c_ptr{__address:i64}>>): |
| 518 |
!CHECK: {{.*}} = fir.coordinate_of %[[VAL_1:.*]], {{.*}} : (!fir.ref<!fir.type<_QM__fortran_builtinsT__builtin_c_ptr{__address:i64}>>, !fir.field) -> !fir.ref<i64> |
| 519 |
a = c_loc(b) |
| 520 |
!CHECK: omp.terminator |
| 521 |
!$omp end target data |
| 522 |
!CHECK: } |
| 523 |
end subroutine omp_target_device_ptr |
| 524 |
|
| 525 |
!=============================================================================== |
| 526 |
! Target `use_device_addr` clause |
| 527 |
!=============================================================================== |
| 528 |
|
| 529 |
!CHECK-LABEL: func.func @_QPomp_target_device_addr() { |
| 530 |
subroutine omp_target_device_addr |
| 531 |
integer, pointer :: a |
| 532 |
!CHECK: %[[VAL_0:.*]] = fir.alloca !fir.box<!fir.ptr<i32>> {bindc_name = "a", uniq_name = "_QFomp_target_device_addrEa"} |
| 533 |
!CHECK: %[[VAL_0_DECL:.*]]:2 = hlfir.declare %0 {fortran_attrs = #fir.var_attrs<pointer>, uniq_name = "_QFomp_target_device_addrEa"} : (!fir.ref<!fir.box<!fir.ptr<i32>>>) -> (!fir.ref<!fir.box<!fir.ptr<i32>>>, !fir.ref<!fir.box<!fir.ptr<i32>>>) |
| 534 |
!CHECK: %[[MAP_MEMBERS:.*]] = omp.map.info var_ptr({{.*}} : !fir.ref<!fir.box<!fir.ptr<i32>>>, i32) var_ptr_ptr({{.*}} : !fir.llvm_ptr<!fir.ref<i32>>) map_clauses(tofrom) capture(ByRef) -> !fir.llvm_ptr<!fir.ref<i32>> {name = ""} |
| 535 |
!CHECK: %[[MAP:.*]] = omp.map.info var_ptr({{.*}} : !fir.ref<!fir.box<!fir.ptr<i32>>>, !fir.box<!fir.ptr<i32>>) map_clauses(tofrom) capture(ByRef) members(%[[MAP_MEMBERS]] : [0] : !fir.llvm_ptr<!fir.ref<i32>>) -> !fir.ref<!fir.box<!fir.ptr<i32>>> {name = "a"} |
| 536 |
!CHECK: omp.target_data use_device_addr(%[[VAL_0_DECL]]#1 : !fir.ref<!fir.box<!fir.ptr<i32>>>) map_entries(%[[MAP_MEMBERS]], %[[MAP]] : {{.*}}) { |
| 537 |
!$omp target data map(tofrom: a) use_device_addr(a) |
| 538 |
!CHECK: ^bb0(%[[VAL_1:.*]]: !fir.ref<!fir.box<!fir.ptr<i32>>>): |
| 539 |
!CHECK: %[[VAL_1_DECL:.*]]:2 = hlfir.declare %[[VAL_1]] {fortran_attrs = #fir.var_attrs<pointer>, uniq_name = "_QFomp_target_device_addrEa"} : (!fir.ref<!fir.box<!fir.ptr<i32>>>) -> (!fir.ref<!fir.box<!fir.ptr<i32>>>, !fir.ref<!fir.box<!fir.ptr<i32>>>) |
| 540 |
!CHECK: %[[C10:.*]] = arith.constant 10 : i32 |
| 541 |
!CHECK: %[[A_BOX:.*]] = fir.load %[[VAL_1_DECL]]#0 : !fir.ref<!fir.box<!fir.ptr<i32>>> |
| 542 |
!CHECK: %[[A_ADDR:.*]] = fir.box_addr %[[A_BOX]] : (!fir.box<!fir.ptr<i32>>) -> !fir.ptr<i32> |
| 543 |
!CHECK: hlfir.assign %[[C10]] to %[[A_ADDR]] : i32, !fir.ptr<i32> |
| 544 |
a = 10 |
| 545 |
!CHECK: omp.terminator |
| 546 |
!$omp end target data |
| 547 |
!CHECK: } |
| 548 |
end subroutine omp_target_device_addr |
| 549 |
|
| 550 |
|
| 551 |
!=============================================================================== |
| 552 |
! Target Data with unstructured code |
| 553 |
!=============================================================================== |
| 554 |
!CHECK-LABEL: func.func @_QPsb |
| 555 |
subroutine sb |
| 556 |
integer :: i = 1 |
| 557 |
integer :: j = 11 |
| 558 |
!CHECK: omp.target_data map_entries(%{{.*}}, %{{.*}} : !fir.ref<i32>, !fir.ref<i32>) |
| 559 |
!$omp target data map(tofrom: i, j) |
| 560 |
j = j - 1 |
| 561 |
!CHECK: %[[J_VAL:.*]] = arith.subi |
| 562 |
!CHECK: hlfir.assign %[[J_VAL]] |
| 563 |
!CHECK: cf.br ^[[BB:.*]] |
| 564 |
!CHECK: ^[[BB]]: |
| 565 |
goto 20 |
| 566 |
20 i = i + 1 |
| 567 |
!CHECK: %[[I_VAL:.*]] = arith.addi |
| 568 |
!CHECK: hlfir.assign %[[I_VAL]] |
| 569 |
!CHECK: omp.terminator |
| 570 |
!$omp end target data |
| 571 |
end subroutine |
| 572 |
|
| 573 |
!=============================================================================== |
| 574 |
! Target with parallel loop |
| 575 |
!=============================================================================== |
| 576 |
|
| 577 |
!CHECK-LABEL: func.func @_QPomp_target_parallel_do() { |
| 578 |
subroutine omp_target_parallel_do |
| 579 |
!CHECK: %[[C1024:.*]] = arith.constant 1024 : index |
| 580 |
!CHECK: %[[VAL_0:.*]] = fir.alloca !fir.array<1024xi32> {bindc_name = "a", uniq_name = "_QFomp_target_parallel_doEa"} |
| 581 |
!CHECK: %[[VAL_0_DECL:.*]]:2 = hlfir.declare %[[VAL_0]](%{{.*}}) {uniq_name = "_QFomp_target_parallel_doEa"} : (!fir.ref<!fir.array<1024xi32>>, !fir.shape<1>) -> (!fir.ref<!fir.array<1024xi32>>, !fir.ref<!fir.array<1024xi32>>) |
| 582 |
integer :: a(1024) |
| 583 |
!CHECK: %[[VAL_1:.*]] = fir.alloca i32 {bindc_name = "i", uniq_name = "_QFomp_target_parallel_doEi"} |
| 584 |
!CHECK: %[[VAL_1_DECL:.*]]:2 = hlfir.declare %[[VAL_1]] {uniq_name = "_QFomp_target_parallel_doEi"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>) |
| 585 |
integer :: i |
| 586 |
!CHECK: %[[C1:.*]] = arith.constant 1 : index |
| 587 |
!CHECK: %[[C0:.*]] = arith.constant 0 : index |
| 588 |
!CHECK: %[[SUB:.*]] = arith.subi %[[C1024]], %[[C1]] : index |
| 589 |
!CHECK: %[[BOUNDS:.*]] = omp.map.bounds lower_bound(%[[C0]] : index) upper_bound(%[[SUB]] : index) extent(%[[C1024]] : index) stride(%[[C1]] : index) start_idx(%[[C1]] : index) |
| 590 |
!CHECK: %[[MAP:.*]] = omp.map.info var_ptr(%[[VAL_0_DECL]]#0 : !fir.ref<!fir.array<1024xi32>>, !fir.array<1024xi32>) map_clauses(tofrom) capture(ByRef) bounds(%[[BOUNDS]]) -> !fir.ref<!fir.array<1024xi32>> {name = "a"} |
| 591 |
!CHECK: omp.target map_entries(%[[MAP]] -> %[[ARG_0:.*]], %{{.*}} -> %{{.*}} : !fir.ref<!fir.array<1024xi32>>, !fir.ref<i32>) { |
| 592 |
!CHECK: ^bb0(%[[ARG_0]]: !fir.ref<!fir.array<1024xi32>>, %{{.*}}: !fir.ref<i32>): |
| 593 |
!CHECK: %[[VAL_0_DECL:.*]]:2 = hlfir.declare %[[ARG_0]](%{{.*}}) {uniq_name = "_QFomp_target_parallel_doEa"} : (!fir.ref<!fir.array<1024xi32>>, !fir.shape<1>) -> (!fir.ref<!fir.array<1024xi32>>, !fir.ref<!fir.array<1024xi32>>) |
| 594 |
!CHECK: omp.parallel |
| 595 |
!$omp target parallel do map(tofrom: a) |
| 596 |
!CHECK: %[[I_PVT_ALLOCA:.*]] = fir.alloca i32 {bindc_name = "i", pinned, {{.*}}} |
| 597 |
!CHECK: %[[I_PVT_DECL:.*]]:2 = hlfir.declare %[[I_PVT_ALLOCA]] {uniq_name = "_QFomp_target_parallel_doEi"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>) |
| 598 |
!CHECK: omp.wsloop { |
| 599 |
!CHECK-NEXT: omp.loop_nest (%[[I_VAL:.*]]) : i32 |
| 600 |
do i = 1, 1024 |
| 601 |
!CHECK: fir.store %[[I_VAL]] to %[[I_PVT_DECL]]#1 : !fir.ref<i32> |
| 602 |
!CHECK: %[[C10:.*]] = arith.constant 10 : i32 |
| 603 |
!CHECK: %[[I_PVT_VAL:.*]] = fir.load %[[I_PVT_DECL]]#0 : !fir.ref<i32> |
| 604 |
!CHECK: %[[I_VAL:.*]] = fir.convert %[[I_PVT_VAL]] : (i32) -> i64 |
| 605 |
!CHECK: %[[A_I:.*]] = hlfir.designate %[[VAL_0_DECL]]#0 (%[[I_VAL]]) : (!fir.ref<!fir.array<1024xi32>>, i64) -> !fir.ref<i32> |
| 606 |
!CHECK: hlfir.assign %[[C10]] to %[[A_I]] : i32, !fir.ref<i32> |
| 607 |
a(i) = 10 |
| 608 |
end do |
| 609 |
!CHECK: omp.yield |
| 610 |
!CHECK: } |
| 611 |
!CHECK: omp.terminator |
| 612 |
!CHECK: } |
| 613 |
!CHECK: omp.terminator |
| 614 |
!CHECK: } |
| 615 |
!CHECK: omp.terminator |
| 616 |
!CHECK: } |
| 617 |
!$omp end target parallel do |
| 618 |
end subroutine omp_target_parallel_do |
| 619 |
|
| 620 |
!=============================================================================== |
| 621 |
! Target with unstructured code |
| 622 |
!=============================================================================== |
| 623 |
|
| 624 |
!CHECK-LABEL: func.func @_QPtarget_unstructured() { |
| 625 |
subroutine target_unstructured |
| 626 |
!CHECK: %[[VAL_1:.*]]:2 = hlfir.declare %{{.*}} {uniq_name = "_QFtarget_unstructuredEi"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>) |
| 627 |
integer :: i = 1 |
| 628 |
!CHECK: %[[VAL_3:.*]]:2 = hlfir.declare %{{.*}} {uniq_name = "_QFtarget_unstructuredEj"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>) |
| 629 |
integer :: j = 11 |
| 630 |
!CHECK: %[[VAL_4:.*]] = omp.map.info var_ptr(%[[VAL_1]]#1 : !fir.ref<i32>, i32) map_clauses(implicit, exit_release_or_enter_alloc) capture(ByCopy) -> !fir.ref<i32> {name = "i"} |
| 631 |
!CHECK: %[[VAL_5:.*]] = omp.map.info var_ptr(%[[VAL_3]]#1 : !fir.ref<i32>, i32) map_clauses(implicit, exit_release_or_enter_alloc) capture(ByCopy) -> !fir.ref<i32> {name = "j"} |
| 632 |
!CHECK: omp.target map_entries(%[[VAL_4]] -> %[[VAL_6:.*]], %[[VAL_5]] -> %[[VAL_7:.*]] : !fir.ref<i32>, !fir.ref<i32>) { |
| 633 |
!CHECK: ^bb0(%[[VAL_6]]: !fir.ref<i32>, %[[VAL_7]]: !fir.ref<i32>): |
| 634 |
!$omp target |
| 635 |
!CHECK: %[[VAL_8:.*]]:2 = hlfir.declare %[[VAL_6]] {uniq_name = "_QFtarget_unstructuredEi"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>) |
| 636 |
!CHECK: %[[VAL_9:.*]]:2 = hlfir.declare %[[VAL_7]] {uniq_name = "_QFtarget_unstructuredEj"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>) |
| 637 |
!CHECK: ^bb1: |
| 638 |
do while (i <= j) |
| 639 |
!CHECK: ^bb2: |
| 640 |
i = i + 1 |
| 641 |
end do |
| 642 |
!CHECK: ^bb3: |
| 643 |
!CHECK: omp.terminator |
| 644 |
!$omp end target |
| 645 |
!CHECK: } |
| 646 |
end subroutine target_unstructured |