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
1
+ ! RUN: %flang_fc1 -emit-fir -fopenmp %s -o - | FileCheck %s --check-prefixes= HOST,ALL
2
+ ! RUN: %flang_fc1 -emit-fir -fopenmp -fopenmp-is-target-device %s -o - | FileCheck %s --check-prefixes= DEVICE,ALL
3
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>>, !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>>, !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>>, !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>>, !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>>) {
4
+ ! ALL-LABEL: func.func @_QPread_write_section(
5
+ ! ALL: %[[ITER:.*]] = fir.alloca i32 {bindc_name = "i", uniq_name = "_QFread_write_sectionEi"}
6
+ ! ALL: %[[READ:.*]] = fir.address_of(@_QFread_write_sectionEsp_read) : !fir.ref<!fir.array<10xi32>>
7
+ ! ALL: %[[WRITE:.*]] = fir.address_of(@_QFread_write_sectionEsp_write) : !fir.ref<!fir.array<10xi32>>
8
+ ! ALL: %[[C1:.*]] = arith.constant 1 : index
9
+ ! ALL: %[[C2:.*]] = arith.constant 1 : index
10
+ ! ALL: %[[C3:.*]] = arith.constant 4 : index
11
+ ! ALL: %[[BOUNDS0:.*]] = omp.bounds lower_bound(%[[C2]] : index) upper_bound(%[[C3]] : index) stride(%[[C1]] : index) start_idx(%[[C1]] : index)
12
+ ! ALL: %[[MAP0:.*]] = omp.map_info var_ptr(%[[READ]] : !fir.ref<!fir.array<10xi32>>, !fir.array<10xi32>) map_clauses(tofrom) capture(ByRef) bounds(%[[BOUNDS0]]) -> !fir.ref<!fir.array<10xi32>> {name = "sp_read(2:5)"}
13
+ ! ALL: %[[C4:.*]] = arith.constant 1 : index
14
+ ! ALL: %[[C5:.*]] = arith.constant 1 : index
15
+ ! ALL: %[[C6:.*]] = arith.constant 4 : index
16
+ ! ALL: %[[BOUNDS1:.*]] = omp.bounds lower_bound(%[[C5]] : index) upper_bound(%[[C6]] : index) stride(%[[C4]] : index) start_idx(%[[C4]] : index)
17
+ ! ALL: %[[MAP1:.*]] = omp.map_info var_ptr(%[[WRITE]] : !fir.ref<!fir.array<10xi32>>, !fir.array<10xi32>) map_clauses(tofrom) capture(ByRef) bounds(%[[BOUNDS1]]) -> !fir.ref<!fir.array<10xi32>> {name = "sp_write(2:5)"}
18
+ ! ALL: %[[MAP2:.*]] = omp.map_info var_ptr(%[[ITER]] : !fir.ref<i32>, i32) map_clauses(implicit, exit_release_or_enter_alloc) capture(ByCopy) -> !fir.ref<i32> {name = "i"}
19
+ ! ALL: omp.target map_entries(%[[MAP0]] -> %{{.*}}, %[[MAP1]] -> %{{.*}}, %[[MAP2]] -> %{{.*}}, %{{.*}} -> %{{.*}}, %{{.*}} -> %{{.*}} : !fir.ref<!fir.array<10xi32>>, !fir.ref<!fir.array<10xi32>>, !fir.ref<i32>, index, index) {
35
20
36
21
subroutine read_write_section ()
37
22
integer :: sp_read(10 ) = (/ 1 ,2 ,3 ,4 ,5 ,6 ,7 ,8 ,9 ,10 / )
@@ -44,33 +29,22 @@ subroutine read_write_section()
44
29
! $omp end target
45
30
end subroutine read_write_section
46
31
47
-
48
32
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>>, %[[ARG2:.*]]: !fir.ref<!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>>, !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>>) {
33
+ contains
34
+ ! ALL-LABEL: func.func @_QMassumed_array_routinesPassumed_shape_array(
35
+ ! ALL-SAME: %[[ARG0:.*]]: !fir.box<!fir.array<?xi32>> {fir.bindc_name = "arr_read_write"}) {
36
+ ! ALL: %[[ALLOCA:.*]] = fir.alloca i32 {bindc_name = "i", uniq_name = "_QMassumed_array_routinesFassumed_shape_arrayEi"}
37
+ ! ALL: %[[C0:.*]] = arith.constant 1 : index
38
+ ! ALL: %[[C1:.*]] = arith.constant 0 : index
39
+ ! ALL: %[[C2:.*]]:3 = fir.box_dims %arg0, %[[C1]] : (!fir.box<!fir.array<?xi32>>, index) -> (index, index, index)
40
+ ! ALL: %[[C3:.*]] = arith.constant 1 : index
41
+ ! ALL: %[[C4:.*]] = arith.constant 4 : index
42
+ ! ALL: %[[BOUNDS:.*]] = omp.bounds lower_bound(%[[C3]] : index) upper_bound(%[[C4]] : index) stride(%[[C2]]#2 : index) start_idx(%[[C0]] : index) {stride_in_bytes = true}
43
+ ! ALL: %[[ADDROF:.*]] = fir.box_addr %arg0 : (!fir.box<!fir.array<?xi32>>) -> !fir.ref<!fir.array<?xi32>>
44
+ ! ALL: %[[MAP:.*]] = omp.map_info var_ptr(%[[ADDROF]] : !fir.ref<!fir.array<?xi32>>, !fir.array<?xi32>) map_clauses(tofrom) capture(ByRef) bounds(%[[BOUNDS]]) -> !fir.ref<!fir.array<?xi32>> {name = "arr_read_write(2:5)"}
45
+ ! ALL: %[[MAP2:.*]] = omp.map_info var_ptr(%[[ALLOCA]] : !fir.ref<i32>, i32) map_clauses(implicit, exit_release_or_enter_alloc) capture(ByCopy) -> !fir.ref<i32> {name = "i"}
46
+ ! ALL: omp.target map_entries(%[[MAP]] -> %{{.*}}, %[[MAP2]] -> %{{.*}} : !fir.ref<!fir.array<?xi32>>, !fir.ref<i32>) {
61
47
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>>, !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
48
subroutine assumed_shape_array (arr_read_write )
75
49
integer , intent (inout ) :: arr_read_write(:)
76
50
@@ -81,25 +55,17 @@ subroutine assumed_shape_array(arr_read_write)
81
55
! $omp end target
82
56
end subroutine assumed_shape_array
83
57
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>>, !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>>) {
58
+ ! ALL-LABEL: func.func @_QMassumed_array_routinesPassumed_size_array(
59
+ ! ALL-SAME: %[[ARG0:.*]]: !fir.ref<!fir.array<?xi32>> {fir.bindc_name = "arr_read_write"}) {
60
+ ! ALL: %[[ALLOCA:.*]] = fir.alloca i32 {bindc_name = "i", uniq_name = "_QMassumed_array_routinesFassumed_size_arrayEi"}
61
+ ! ALL: %[[C0:.*]] = arith.constant 1 : index
62
+ ! ALL: %[[C1:.*]] = arith.constant 1 : index
63
+ ! ALL: %[[C2:.*]] = arith.constant 4 : index
64
+ ! ALL: %[[BOUNDS:.*]] = omp.bounds lower_bound(%[[C1]] : index) upper_bound(%[[C2]] : index) stride(%[[C0]] : index) start_idx(%[[C0]] : index)
65
+ ! ALL: %[[MAP:.*]] = omp.map_info var_ptr(%[[ARG0]] : !fir.ref<!fir.array<?xi32>>, !fir.array<?xi32>) map_clauses(tofrom) capture(ByRef) bounds(%[[BOUNDS]]) -> !fir.ref<!fir.array<?xi32>> {name = "arr_read_write(2:5)"}
66
+ ! ALL: %[[MAP2:.*]] = omp.map_info var_ptr(%[[ALLOCA]] : !fir.ref<i32>, i32) map_clauses(implicit, exit_release_or_enter_alloc) capture(ByCopy) -> !fir.ref<i32> {name = "i"}
67
+ ! ALL: omp.target map_entries(%[[MAP]] -> %{{.*}}, %[[MAP2]] -> %{{.*}}, %{{.*}} -> %{{.*}} : !fir.ref<!fir.array<?xi32>>, !fir.ref<i32>, index) {
93
68
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>>, !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
69
subroutine assumed_size_array (arr_read_write )
104
70
integer , intent (inout ) :: arr_read_write(* )
105
71
@@ -111,6 +77,7 @@ subroutine assumed_size_array(arr_read_write)
111
77
end subroutine assumed_size_array
112
78
end module assumed_array_routines
113
79
80
+ ! DEVICE-NOT:func.func @_QPcall_assumed_shape_and_size_array() {
114
81
115
82
! HOST-LABEL:func.func @_QPcall_assumed_shape_and_size_array() {
116
83
! HOST:%{{.*}} = arith.constant 20 : index
0 commit comments