|
| 1 | +!RUN: %flang_fc1 -emit-fir -fopenmp %s -o - | FileCheck %s --check-prefixes HOST |
| 2 | +!RUN: %flang_fc1 -emit-fir -fopenmp -fopenmp-is-target-device %s -o - | FileCheck %s --check-prefixes DEVICE |
| 3 | + |
| 4 | +!DEVICE-LABEL: func.func @_QPread_write_section_omp_outline_0( |
| 5 | +!DEVICE-SAME: %[[ARG0:.*]]: !fir.ref<i32>, %[[ARG1:.*]]: !fir.ref<!fir.array<10xi32>>, %[[ARG2:.*]]: !fir.ref<!fir.array<10xi32>>) attributes {omp.declare_target = #omp.declaretarget<device_type = (host), capture_clause = (to)>, omp.outline_parent_name = "_QPread_write_section"} { |
| 6 | +!DEVICE: %[[C1:.*]] = arith.constant 1 : index |
| 7 | +!DEVICE: %[[C2:.*]] = arith.constant 4 : index |
| 8 | +!DEVICE: %[[C3:.*]] = arith.constant 1 : index |
| 9 | +!DEVICE: %[[C4:.*]] = arith.constant 1 : index |
| 10 | +!DEVICE: %[[BOUNDS0:.*]] = omp.bounds lower_bound(%[[C1]] : index) upper_bound(%[[C2]] : index) stride(%[[C4]] : index) start_idx(%[[C4]] : index) |
| 11 | +!DEVICE: %[[MAP0:.*]] = omp.map_info var_ptr(%[[ARG1]] : !fir.ref<!fir.array<10xi32>>) map_clauses(tofrom) capture(ByRef) bounds(%[[BOUNDS0]]) -> !fir.ref<!fir.array<10xi32>> {name = "sp_read(2:5)"} |
| 12 | +!DEVICE: %[[C5:.*]] = arith.constant 1 : index |
| 13 | +!DEVICE: %[[C6:.*]] = arith.constant 4 : index |
| 14 | +!DEVICE: %[[C7:.*]] = arith.constant 1 : index |
| 15 | +!DEVICE: %[[C8:.*]] = arith.constant 1 : index |
| 16 | +!DEVICE: %[[BOUNDS1:.*]] = omp.bounds lower_bound(%[[C5]] : index) upper_bound(%[[C6]] : index) stride(%[[C8]] : index) start_idx(%[[C8]] : index) |
| 17 | +!DEVICE: %[[MAP1:.*]] = omp.map_info var_ptr(%[[ARG2]] : !fir.ref<!fir.array<10xi32>>) map_clauses(tofrom) capture(ByRef) bounds(%[[BOUNDS1]]) -> !fir.ref<!fir.array<10xi32>> {name = "sp_write(2:5)"} |
| 18 | +!DEVICE: omp.target map_entries(%[[MAP0]], %[[MAP1]] : !fir.ref<!fir.array<10xi32>>, !fir.ref<!fir.array<10xi32>>) { |
| 19 | + |
| 20 | +!HOST-LABEL: func.func @_QPread_write_section() { |
| 21 | +!HOST: %0 = fir.alloca i32 {bindc_name = "i", uniq_name = "_QFread_write_sectionEi"} |
| 22 | +!HOST: %[[READ:.*]] = fir.address_of(@_QFread_write_sectionEsp_read) : !fir.ref<!fir.array<10xi32>> |
| 23 | +!HOST: %[[WRITE:.*]] = fir.address_of(@_QFread_write_sectionEsp_write) : !fir.ref<!fir.array<10xi32>> |
| 24 | +!HOST: %[[C1:.*]] = arith.constant 1 : index |
| 25 | +!HOST: %[[C2:.*]] = arith.constant 1 : index |
| 26 | +!HOST: %[[C3:.*]] = arith.constant 4 : index |
| 27 | +!HOST: %[[BOUNDS0:.*]] = omp.bounds lower_bound(%[[C2]] : index) upper_bound(%[[C3]] : index) stride(%[[C1]] : index) start_idx(%[[C1]] : index) |
| 28 | +!HOST: %[[MAP0:.*]] = omp.map_info var_ptr(%[[READ]] : !fir.ref<!fir.array<10xi32>>) map_clauses(tofrom) capture(ByRef) bounds(%[[BOUNDS0]]) -> !fir.ref<!fir.array<10xi32>> {name = "sp_read(2:5)"} |
| 29 | +!HOST: %[[C4:.*]] = arith.constant 1 : index |
| 30 | +!HOST: %[[C5:.*]] = arith.constant 1 : index |
| 31 | +!HOST: %[[C6:.*]] = arith.constant 4 : index |
| 32 | +!HOST: %[[BOUNDS1:.*]] = omp.bounds lower_bound(%[[C5]] : index) upper_bound(%[[C6]] : index) stride(%[[C4]] : index) start_idx(%[[C4]] : index) |
| 33 | +!HOST: %[[MAP1:.*]] = omp.map_info var_ptr(%[[WRITE]] : !fir.ref<!fir.array<10xi32>>) map_clauses(tofrom) capture(ByRef) bounds(%[[BOUNDS1]]) -> !fir.ref<!fir.array<10xi32>> {name = "sp_write(2:5)"} |
| 34 | +!HOST: omp.target map_entries(%[[MAP0]], %[[MAP1]] : !fir.ref<!fir.array<10xi32>>, !fir.ref<!fir.array<10xi32>>) { |
| 35 | + |
| 36 | +subroutine read_write_section() |
| 37 | + integer :: sp_read(10) = (/1,2,3,4,5,6,7,8,9,10/) |
| 38 | + integer :: sp_write(10) = (/0,0,0,0,0,0,0,0,0,0/) |
| 39 | + |
| 40 | +!$omp target map(tofrom:sp_read(2:5)) map(tofrom:sp_write(2:5)) |
| 41 | + do i = 2, 5 |
| 42 | + sp_write(i) = sp_read(i) |
| 43 | + end do |
| 44 | +!$omp end target |
| 45 | +end subroutine read_write_section |
| 46 | + |
| 47 | + |
| 48 | +module assumed_array_routines |
| 49 | + contains |
| 50 | +!DEVICE-LABEL: func.func @_QMassumed_array_routinesPassumed_shape_array_omp_outline_0( |
| 51 | +!DEVICE-SAME: %[[ARG0:.*]]: !fir.ref<i32>, %[[ARG1:.*]]: !fir.box<!fir.array<?xi32>>) attributes {omp.declare_target = #omp.declaretarget<device_type = (host), capture_clause = (to)>, omp.outline_parent_name = "_QMassumed_array_routinesPassumed_shape_array"} { |
| 52 | +!DEVICE: %[[C0:.*]] = arith.constant 1 : index |
| 53 | +!DEVICE: %[[C1:.*]] = arith.constant 4 : index |
| 54 | +!DEVICE: %[[C2:.*]] = arith.constant 0 : index |
| 55 | +!DEVICE: %[[C3:.*]]:3 = fir.box_dims %[[ARG1]], %[[C2]] : (!fir.box<!fir.array<?xi32>>, index) -> (index, index, index) |
| 56 | +!DEVICE: %[[C4:.*]] = arith.constant 1 : index |
| 57 | +!DEVICE: %[[BOUNDS:.*]] = omp.bounds lower_bound(%[[C0]] : index) upper_bound(%[[C1]] : index) stride(%[[C3]]#2 : index) start_idx(%[[C4]] : index) {stride_in_bytes = true} |
| 58 | +!DEVICE: %[[ARGADDR:.*]] = fir.box_addr %[[ARG1]] : (!fir.box<!fir.array<?xi32>>) -> !fir.ref<!fir.array<?xi32>> |
| 59 | +!DEVICE: %[[MAP:.*]] = omp.map_info var_ptr(%[[ARGADDR]] : !fir.ref<!fir.array<?xi32>>) map_clauses(tofrom) capture(ByRef) bounds(%[[BOUNDS]]) -> !fir.ref<!fir.array<?xi32>> {name = "arr_read_write(2:5)"} |
| 60 | +!DEVICE: omp.target map_entries(%[[MAP]] : !fir.ref<!fir.array<?xi32>>) { |
| 61 | + |
| 62 | +!HOST-LABEL: func.func @_QMassumed_array_routinesPassumed_shape_array( |
| 63 | +!HOST-SAME: %[[ARG0:.*]]: !fir.box<!fir.array<?xi32>> {fir.bindc_name = "arr_read_write"}) { |
| 64 | +!HOST: %[[ALLOCA:.*]] = fir.alloca i32 {bindc_name = "i", uniq_name = "_QMassumed_array_routinesFassumed_shape_arrayEi"} |
| 65 | +!HOST: %[[C0:.*]] = arith.constant 1 : index |
| 66 | +!HOST: %[[C1:.*]] = arith.constant 0 : index |
| 67 | +!HOST: %[[C2:.*]]:3 = fir.box_dims %arg0, %[[C1]] : (!fir.box<!fir.array<?xi32>>, index) -> (index, index, index) |
| 68 | +!HOST: %[[C3:.*]] = arith.constant 1 : index |
| 69 | +!HOST: %[[C4:.*]] = arith.constant 4 : index |
| 70 | +!HOST: %[[BOUNDS:.*]] = omp.bounds lower_bound(%[[C3]] : index) upper_bound(%[[C4]] : index) stride(%[[C2]]#2 : index) start_idx(%[[C0]] : index) {stride_in_bytes = true} |
| 71 | +!HOST: %[[ADDROF:.*]] = fir.box_addr %arg0 : (!fir.box<!fir.array<?xi32>>) -> !fir.ref<!fir.array<?xi32>> |
| 72 | +!HOST: %[[MAP:.*]] = omp.map_info var_ptr(%[[ADDROF]] : !fir.ref<!fir.array<?xi32>>) map_clauses(tofrom) capture(ByRef) bounds(%[[BOUNDS]]) -> !fir.ref<!fir.array<?xi32>> {name = "arr_read_write(2:5)"} |
| 73 | +!HOST: omp.target map_entries(%[[MAP]] : !fir.ref<!fir.array<?xi32>>) { |
| 74 | + subroutine assumed_shape_array(arr_read_write) |
| 75 | + integer, intent(inout) :: arr_read_write(:) |
| 76 | + |
| 77 | + !$omp target map(tofrom:arr_read_write(2:5)) |
| 78 | + do i = 2, 5 |
| 79 | + arr_read_write(i) = i |
| 80 | + end do |
| 81 | + !$omp end target |
| 82 | + end subroutine assumed_shape_array |
| 83 | + |
| 84 | +!DEVICE-LABEL: func.func @_QMassumed_array_routinesPassumed_size_array_omp_outline_0( |
| 85 | +!DEVICE-SAME: %[[ARG0:.*]]: !fir.ref<i32>, %[[ARG1:.*]]: !fir.ref<!fir.array<?xi32>>) attributes {omp.declare_target = #omp.declaretarget<device_type = (host), capture_clause = (to)>, omp.outline_parent_name = "_QMassumed_array_routinesPassumed_size_array"} { |
| 86 | +!DEVICE: %[[C0:.*]] = arith.constant 1 : index |
| 87 | +!DEVICE: %[[C1:.*]] = arith.constant 4 : index |
| 88 | +!DEVICE: %[[C2:.*]] = arith.constant 1 : index |
| 89 | +!DEVICE: %[[C3:.*]] = arith.constant 1 : index |
| 90 | +!DEVICE: %[[BOUNDS:.*]] = omp.bounds lower_bound(%[[C0]] : index) upper_bound(%[[C1]] : index) stride(%[[C3]] : index) start_idx(%[[C3]] : index) |
| 91 | +!DEVICE: %[[MAP:.*]] = omp.map_info var_ptr(%[[ARG1]] : !fir.ref<!fir.array<?xi32>>) map_clauses(tofrom) capture(ByRef) bounds(%[[BOUNDS]]) -> !fir.ref<!fir.array<?xi32>> {name = "arr_read_write(2:5)"} |
| 92 | +!DEVICE: omp.target map_entries(%[[MAP]] : !fir.ref<!fir.array<?xi32>>) { |
| 93 | + |
| 94 | +!HOST-LABEL: func.func @_QMassumed_array_routinesPassumed_size_array( |
| 95 | +!HOST-SAME: %[[ARG0:.*]]: !fir.ref<!fir.array<?xi32>> {fir.bindc_name = "arr_read_write"}) { |
| 96 | +!HOST: %[[ALLOCA:.*]] = fir.alloca i32 {bindc_name = "i", uniq_name = "_QMassumed_array_routinesFassumed_size_arrayEi"} |
| 97 | +!HOST: %[[C0:.*]] = arith.constant 1 : index |
| 98 | +!HOST: %[[C1:.*]] = arith.constant 1 : index |
| 99 | +!HOST: %[[C2:.*]] = arith.constant 4 : index |
| 100 | +!HOST: %[[BOUNDS:.*]] = omp.bounds lower_bound(%[[C1]] : index) upper_bound(%[[C2]] : index) stride(%[[C0]] : index) start_idx(%[[C0]] : index) |
| 101 | +!HOST: %[[MAP:.*]] = omp.map_info var_ptr(%[[ARG0]] : !fir.ref<!fir.array<?xi32>>) map_clauses(tofrom) capture(ByRef) bounds(%[[BOUNDS]]) -> !fir.ref<!fir.array<?xi32>> {name = "arr_read_write(2:5)"} |
| 102 | +!HOST: omp.target map_entries(%[[MAP]] : !fir.ref<!fir.array<?xi32>>) { |
| 103 | + subroutine assumed_size_array(arr_read_write) |
| 104 | + integer, intent(inout) :: arr_read_write(*) |
| 105 | + |
| 106 | + !$omp target map(tofrom:arr_read_write(2:5)) |
| 107 | + do i = 2, 5 |
| 108 | + arr_read_write(i) = i |
| 109 | + end do |
| 110 | + !$omp end target |
| 111 | + end subroutine assumed_size_array |
| 112 | + end module assumed_array_routines |
| 113 | + |
| 114 | + |
| 115 | +!HOST-LABEL:func.func @_QPcall_assumed_shape_and_size_array() { |
| 116 | +!HOST:%{{.*}} = arith.constant 20 : index |
| 117 | +!HOST:%[[ALLOCA:.*]] = fir.alloca !fir.array<20xi32> {bindc_name = "arr_read_write", uniq_name = "_QFcall_assumed_shape_and_size_arrayEarr_read_write"} |
| 118 | +!HOST:%{{.*}} = arith.constant 1 : i64 |
| 119 | +!HOST:%{{.*}} = fir.convert %{{.*}} : (i64) -> index |
| 120 | +!HOST:%{{.*}} = arith.constant 1 : i64 |
| 121 | +!HOST:%{{.*}} = fir.convert %{{.*}} : (i64) -> index |
| 122 | +!HOST:%{{.*}} = arith.constant 10 : i64 |
| 123 | +!HOST:%{{.*}} = fir.convert %{{.*}} : (i64) -> index |
| 124 | +!HOST:%[[SHAPE0:.*]] = fir.shape %{{.*}} : (index) -> !fir.shape<1> |
| 125 | +!HOST:%[[SLICE0:.*]] = fir.slice %{{.*}}, %{{.*}}, %{{.*}} : (index, index, index) -> !fir.slice<1> |
| 126 | +!HOST:%[[ARG0EMB:.*]] = fir.embox %[[ALLOCA]](%[[SHAPE0]]) [%[[SLICE0]]] : (!fir.ref<!fir.array<20xi32>>, !fir.shape<1>, !fir.slice<1>) -> !fir.box<!fir.array<10xi32>> |
| 127 | +!HOST:%[[ARG0:.*]] = fir.convert %[[ARG0EMB]] : (!fir.box<!fir.array<10xi32>>) -> !fir.box<!fir.array<?xi32>> |
| 128 | +!HOST:fir.call @_QMassumed_array_routinesPassumed_shape_array(%[[ARG0]]) fastmath<contract> : (!fir.box<!fir.array<?xi32>>) -> () |
| 129 | +!HOST:%{{.*}} = arith.constant 10 : i64 |
| 130 | +!HOST:%{{.*}} = fir.convert %{{.*}} : (i64) -> index |
| 131 | +!HOST:%{{.*}} = arith.constant 1 : i64 |
| 132 | +!HOST:%{{.*}} = fir.convert %{{.*}} : (i64) -> index |
| 133 | +!HOST:%{{.*}} = arith.constant 20 : i64 |
| 134 | +!HOST:%{{.*}} = fir.convert %{{.*}} : (i64) -> index |
| 135 | +!HOST:%[[SHAPE1:.*]] = fir.shape %{{.*}} : (index) -> !fir.shape<1> |
| 136 | +!HOST:%[[SLICE1:.*]] = fir.slice %{{.*}}, %{{.*}}, %{{.*}} : (index, index, index) -> !fir.slice<1> |
| 137 | +!HOST:%[[ARG1EMB:.*]] = fir.embox %[[ALLOCA]](%[[SHAPE1]]) [%[[SLICE1]]] : (!fir.ref<!fir.array<20xi32>>, !fir.shape<1>, !fir.slice<1>) -> !fir.box<!fir.array<11xi32>> |
| 138 | +!HOST:%[[ADDROF:.*]] = fir.box_addr %[[ARG1EMB]] : (!fir.box<!fir.array<11xi32>>) -> !fir.ref<!fir.array<11xi32>> |
| 139 | +!HOST:%[[ARG1:.*]] = fir.convert %[[ADDROF]] : (!fir.ref<!fir.array<11xi32>>) -> !fir.ref<!fir.array<?xi32>> |
| 140 | +!HOST:fir.call @_QMassumed_array_routinesPassumed_size_array(%[[ARG1]]) fastmath<contract> : (!fir.ref<!fir.array<?xi32>>) -> () |
| 141 | +!HOST:return |
| 142 | +!HOST:} |
| 143 | + |
| 144 | +subroutine call_assumed_shape_and_size_array |
| 145 | + use assumed_array_routines |
| 146 | + integer :: arr_read_write(20) |
| 147 | + call assumed_shape_array(arr_read_write(1:10)) |
| 148 | + call assumed_size_array(arr_read_write(10:20)) |
| 149 | +end subroutine call_assumed_shape_and_size_array |
0 commit comments