|
1 | 1 | ! This test checks lowering of OpenMP declare mapper Directive.
|
2 | 2 |
|
3 | 3 | ! RUN: split-file %s %t
|
4 |
| -! RUN: %flang_fc1 -emit-hlfir -fopenmp -fopenmp-version=50 %t/declare-mapper-1.f90 -o - | FileCheck %t/declare-mapper-1.f90 |
5 |
| -! RUN %flang_fc1 -emit-hlfir -fopenmp -fopenmp-version=50 %t/declare-mapper-2.f90 -o - | FileCheck %t/declare-mapper-2.f90 |
| 4 | +! RUN: %flang_fc1 -emit-hlfir -fopenmp -fopenmp-version=50 %t/omp-declare-mapper-1.f90 -o - | FileCheck %t/omp-declare-mapper-1.f90 |
| 5 | +! RUN %flang_fc1 -emit-hlfir -fopenmp -fopenmp-version=50 %t/omp-declare-mapper-2.f90 -o - | FileCheck %t/omp-declare-mapper-2.f90 |
6 | 6 |
|
7 |
| -!--- declare-mapper-1.f90 |
8 |
| -subroutine mapper |
9 |
| - implicit none |
| 7 | +!--- omp-declare-mapper-1.f90 |
| 8 | +subroutine declare_mapper_1 |
| 9 | + integer, parameter :: nvals = 250 |
10 | 10 | type my_type
|
11 |
| - integer, pointer :: my_buffer |
12 |
| - integer :: my_buffer_size |
| 11 | + integer :: num_vals |
| 12 | + integer, allocatable :: values(:) |
13 | 13 | end type
|
14 |
| - !CHECK: %[[MY_VAR:.*]] = fir.alloca ![[VAR_TYPE:.*]] {bindc_name = "my_var"} |
15 |
| - !CHECK: %[[MAP_INFO:.*]] = omp.map.info var_ptr(%[[MY_VAR]] : !fir.ref<![[VAR_TYPE]]>, ![[VAR_TYPE]]) map_clauses(tofrom) capture(ByRef) -> !fir.ref<![[VAR_TYPE]]> {name = "my_var"} |
16 |
| - !CHECK: omp.declare_mapper @my_mapper : %[[MY_VAR]] : !fir.ref<![[VAR_TYPE]]> : ![[VAR_TYPE]] map_entries(%[[MAP_INFO]] : !fir.ref<![[VAR_TYPE]]>) |
17 |
| - !$omp DECLARE MAPPER(my_mapper : my_type :: my_var) map(tofrom : my_var) |
18 |
| -end subroutine |
19 | 14 |
|
20 |
| -!--- declare-mapper-2.f90 |
21 |
| -subroutine mapper_default |
22 |
| - implicit none |
| 15 | + type my_type2 |
| 16 | + type(my_type) :: my_type_var |
| 17 | + type(my_type) :: temp |
| 18 | + real, dimension(nvals) :: unmapped |
| 19 | + real, dimension(nvals) :: arr |
| 20 | + end type |
| 21 | + type(my_type2) :: t |
| 22 | + real :: x, y(nvals) |
| 23 | + !CHECK: omp.declare_mapper @default_my_type : ![[VAR_TYPE:.*]] { |
| 24 | + !CHECK: %[[VAL_5:.*]] = fir.alloca ![[VAR_TYPE]] {bindc_name = "var"} |
| 25 | + !CHECK: %[[VAL_6:.*]]:2 = hlfir.declare %[[VAL_5]] {uniq_name = "_QFdeclare_mapper_1Evar"} : (!fir.ref<![[VAR_TYPE]]>) -> (!fir.ref<![[VAR_TYPE]]>, !fir.ref<![[VAR_TYPE]]>) |
| 26 | + !CHECK: %[[VAL_7:.*]] = hlfir.designate %[[VAL_6]]#0{{.*}} : (!fir.ref<![[VAR_TYPE]]>) -> !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>> |
| 27 | + !CHECK: %[[VAL_8:.*]] = fir.load %[[VAL_7]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>> |
| 28 | + !CHECK: %[[VAL_9:.*]] = arith.constant 0 : index |
| 29 | + !CHECK: %[[VAL_10:.*]]:3 = fir.box_dims %[[VAL_8]], %[[VAL_9]] : (!fir.box<!fir.heap<!fir.array<?xi32>>>, index) -> (index, index, index) |
| 30 | + !CHECK: %[[VAL_11:.*]] = arith.constant 1 : index |
| 31 | + !CHECK: %[[VAL_12:.*]] = arith.constant 1 : index |
| 32 | + !CHECK: %[[VAL_13:.*]] = arith.subi %[[VAL_12]], %[[VAL_10]]#0 : index |
| 33 | + !CHECK: %[[VAL_14:.*]] = hlfir.designate %[[VAL_6]]#0{"num_vals"} : (!fir.ref<![[VAR_TYPE]]>) -> !fir.ref<i32> |
| 34 | + !CHECK: %[[VAL_15:.*]] = fir.load %[[VAL_14]] : !fir.ref<i32> |
| 35 | + !CHECK: %[[VAL_16:.*]] = fir.convert %[[VAL_15]] : (i32) -> i64 |
| 36 | + !CHECK: %[[VAL_17:.*]] = fir.convert %[[VAL_16]] : (i64) -> index |
| 37 | + !CHECK: %[[VAL_18:.*]] = arith.subi %[[VAL_17]], %[[VAL_10]]#0 : index |
| 38 | + !CHECK: %[[VAL_19:.*]] = omp.map.bounds lower_bound(%[[VAL_13]] : index) upper_bound(%[[VAL_18]] : index) extent(%[[VAL_10]]#1 : index) stride(%[[VAL_11]] : index) start_idx(%[[VAL_10]]#0 : index) |
| 39 | + !CHECK: %[[VAL_20:.*]] = arith.constant 1 : index |
| 40 | + !CHECK: %[[VAL_21:.*]] = fir.coordinate_of %[[VAL_6]]#0, %[[VAL_20]] : (!fir.ref<![[VAR_TYPE]]>, index) -> !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>> |
| 41 | + !CHECK: %[[VAL_22:.*]] = fir.box_offset %[[VAL_21]] base_addr : (!fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>) -> !fir.llvm_ptr<!fir.ref<!fir.array<?xi32>>> |
| 42 | + !CHECK: %[[VAL_23:.*]] = omp.map.info var_ptr(%[[VAL_21]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>, !fir.array<?xi32>) var_ptr_ptr(%[[VAL_22]] : !fir.llvm_ptr<!fir.ref<!fir.array<?xi32>>>) map_clauses(tofrom) capture(ByRef) bounds(%[[VAL_19]]) -> !fir.llvm_ptr<!fir.ref<!fir.array<?xi32>>> {name = ""} |
| 43 | + !CHECK: %[[VAL_24:.*]] = omp.map.info var_ptr(%[[VAL_21]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>, !fir.box<!fir.heap<!fir.array<?xi32>>>) map_clauses(to) capture(ByRef) -> !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>> {name = "var%[[VAL_25:.*]](1:var%[[VAL_26:.*]])"} |
| 44 | + !CHECK: %[[VAL_27:.*]] = omp.map.info var_ptr(%[[VAL_6]]#1 : !fir.ref<![[VAR_TYPE]]>, ![[VAR_TYPE]]) map_clauses(tofrom) capture(ByRef) members(%[[VAL_24]], %[[VAL_23]] : [1], [1, 0] : !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>, !fir.llvm_ptr<!fir.ref<!fir.array<?xi32>>>) -> !fir.ref<![[VAR_TYPE]]> {name = "var"} |
| 45 | + !CHECK: omp.declare_mapper_info map_entries(%[[VAL_27]], %[[VAL_24]], %[[VAL_23]] : !fir.ref<![[VAR_TYPE]]>, !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>, !fir.llvm_ptr<!fir.ref<!fir.array<?xi32>>>) |
| 46 | + !CHECK: omp.terminator |
| 47 | + !CHECK: } |
| 48 | + !$omp declare mapper (my_type :: var) map (var, var%values (1:var%num_vals)) |
| 49 | +end subroutine declare_mapper_1 |
| 50 | + |
| 51 | +!--- omp-declare-mapper-2.f90 |
| 52 | +subroutine declare_mapper_2 |
| 53 | + integer, parameter :: nvals = 250 |
23 | 54 | type my_type
|
24 |
| - integer, pointer :: my_buffer |
25 |
| - integer :: my_buffer_size |
| 55 | + integer :: num_vals |
| 56 | + integer, allocatable :: values(:) |
| 57 | + end type |
| 58 | + |
| 59 | + type my_type2 |
| 60 | + type(my_type) :: my_type_var |
| 61 | + type(my_type) :: temp |
| 62 | + real, dimension(nvals) :: unmapped |
| 63 | + real, dimension(nvals) :: arr |
26 | 64 | end type
|
27 |
| - !CHECK: %[[MY_VAR:.*]] = fir.alloca ![[VAR_TYPE:.*]] {bindc_name = "my_var"} |
28 |
| - !CHECK: %[[MAP_INFO:.*]] = omp.map.info var_ptr(%[[MY_VAR]] : !fir.ref<![[VAR_TYPE]]>, ![[VAR_TYPE]]) map_clauses(tofrom) capture(ByRef) -> !fir.ref<![[VAR_TYPE]]> {name = "my_var"} |
29 |
| - !CHECK: omp.declare_mapper @default_my_type : %[[MY_VAR]] : !fir.ref<![[VAR_TYPE]]> : ![[VAR_TYPE]] map_entries(%[[MAP_INFO]] : !fir.ref<![[VAR_TYPE]]>) |
30 |
| - !$omp DECLARE MAPPER(my_type :: my_var) map(tofrom : my_var) |
31 |
| -end subroutine |
| 65 | + type(my_type2) :: t |
| 66 | + real :: x, y(nvals) |
| 67 | + !CHECK: omp.declare_mapper @my_mapper : ![[VAR_TYPE:.*]] { |
| 68 | + !CHECK: %[[VAL_0:.*]] = fir.alloca ![[VAR_TYPE]] {bindc_name = "v"} |
| 69 | + !CHECK: %[[VAL_1:.*]]:2 = hlfir.declare %[[VAL_0]] {uniq_name = "_QFdeclare_mapper_2Ev"} : (!fir.ref<![[VAR_TYPE]]>) -> (!fir.ref<![[VAR_TYPE]]>, !fir.ref<![[VAR_TYPE]]>) |
| 70 | + !CHECK: %[[VAL_2:.*]] = arith.constant 250 : index |
| 71 | + !CHECK: %[[VAL_3:.*]] = fir.shape %[[VAL_2]] : (index) -> !fir.shape<1> |
| 72 | + !CHECK: %[[VAL_4:.*]] = hlfir.designate %[[VAL_1]]#0{"arr"} shape %[[VAL_3]] : (!fir.ref<![[VAR_TYPE]]>, !fir.shape<1>) -> !fir.ref<!fir.array<250xf32>> |
| 73 | + !CHECK: %[[VAL_5:.*]] = arith.constant 1 : index |
| 74 | + !CHECK: %[[VAL_6:.*]] = arith.constant 0 : index |
| 75 | + !CHECK: %[[VAL_7:.*]] = arith.subi %[[VAL_2]], %[[VAL_5]] : index |
| 76 | + !CHECK: %[[VAL_8:.*]] = omp.map.bounds lower_bound(%[[VAL_6]] : index) upper_bound(%[[VAL_7]] : index) extent(%[[VAL_2]] : index) stride(%[[VAL_5]] : index) start_idx(%[[VAL_5]] : index) |
| 77 | + !CHECK: %[[VAL_9:.*]] = omp.map.info var_ptr(%[[VAL_4]] : !fir.ref<!fir.array<250xf32>>, !fir.array<250xf32>) map_clauses(tofrom) capture(ByRef) bounds(%[[VAL_8]]) -> !fir.ref<!fir.array<250xf32>> {name = "v%[[VAL_10:.*]]"} |
| 78 | + !CHECK: %[[VAL_11:.*]] = omp.map.info var_ptr(%[[VAL_12:.*]]#1 : !fir.ref<f32>, f32) map_clauses(tofrom) capture(ByRef) -> !fir.ref<f32> {name = "x"} |
| 79 | + !CHECK: %[[VAL_13:.*]] = arith.constant 0 : index |
| 80 | + !CHECK: %[[VAL_14:.*]] = arith.constant 1 : index |
| 81 | + !CHECK: %[[VAL_15:.*]] = arith.subi %[[VAL_16:.*]], %[[VAL_14]] : index |
| 82 | + !CHECK: %[[VAL_17:.*]] = omp.map.bounds lower_bound(%[[VAL_13]] : index) upper_bound(%[[VAL_15]] : index) extent(%[[VAL_16]] : index) stride(%[[VAL_14]] : index) start_idx(%[[VAL_14]] : index) |
| 83 | + !CHECK: %[[VAL_18:.*]] = omp.map.info var_ptr(%[[VAL_19:.*]]#1 : !fir.ref<!fir.array<250xf32>>, !fir.array<250xf32>) map_clauses(tofrom) capture(ByRef) bounds(%[[VAL_17]]) -> !fir.ref<!fir.array<250xf32>> {name = "y(:)"} |
| 84 | + !CHECK: %[[VAL_20:.*]] = hlfir.designate %[[VAL_1]]#0{"temp"} : (!fir.ref<![[VAR_TYPE]]>) -> !fir.ref<!fir.type<_QFdeclare_mapper_2Tmy_type{num_vals:i32,values:!fir.box<!fir.heap<!fir.array<?xi32>>>}>> |
| 85 | + !CHECK: %[[VAL_21:.*]] = omp.map.info var_ptr(%[[VAL_20]] : !fir.ref<!fir.type<_QFdeclare_mapper_2Tmy_type{num_vals:i32,values:!fir.box<!fir.heap<!fir.array<?xi32>>>}>>, !fir.type<_QFdeclare_mapper_2Tmy_type{num_vals:i32,values:!fir.box<!fir.heap<!fir.array<?xi32>>>}>) map_clauses(exit_release_or_enter_alloc) capture(ByRef) -> !fir.ref<!fir.type<_QFdeclare_mapper_2Tmy_type{num_vals:i32,values:!fir.box<!fir.heap<!fir.array<?xi32>>>}>> {name = "v%[[VAL_22:.*]]"} |
| 86 | + !CHECK: %[[VAL_23:.*]] = omp.map.info var_ptr(%[[VAL_1]]#1 : !fir.ref<![[VAR_TYPE]]>, ![[VAR_TYPE]]) map_clauses(tofrom) capture(ByRef) members(%[[VAL_9]], %[[VAL_21]] : [3], [1] : !fir.ref<!fir.array<250xf32>>, !fir.ref<!fir.type<_QFdeclare_mapper_2Tmy_type{num_vals:i32,values:!fir.box<!fir.heap<!fir.array<?xi32>>>}>>) -> !fir.ref<![[VAR_TYPE]]> {name = "v", partial_map = true} |
| 87 | + !CHECK: omp.declare_mapper_info map_entries(%[[VAL_11]], %[[VAL_18]], %[[VAL_23]], %[[VAL_9]], %[[VAL_21]] : !fir.ref<f32>, !fir.ref<!fir.array<250xf32>>, !fir.ref<![[VAR_TYPE]]>, !fir.ref<!fir.array<250xf32>>, !fir.ref<!fir.type<_QFdeclare_mapper_2Tmy_type{num_vals:i32,values:!fir.box<!fir.heap<!fir.array<?xi32>>>}>>) |
| 88 | + !CHECK: omp.terminator |
| 89 | + !CHECK: } |
| 90 | + !$omp declare mapper (my_mapper : my_type2 :: v) map (v%arr, x, y(:)) & |
| 91 | + !$omp& map (alloc : v%temp) |
| 92 | +end subroutine declare_mapper_2 |
0 commit comments