Debian Codegraph @

flang/test/Lower/OpenACC/locations.f90

raw
1 ! This test checks correct propagation of location information in OpenACC
2 ! operations.
3
4
5 ! RUN: bbc -fopenacc -emit-hlfir --mlir-print-debuginfo --mlir-print-local-scope %s -o - | FileCheck %s
6 module acc_locations
7 implicit none
8
9 contains
10
11 subroutine standalone_data_directive_locations(arr)
12 real, dimension(10) :: arr
13
14 !$acc enter data create(arr)
15 !CHECK-LABEL: acc.enter_data
16 !CHECK-SAME: loc("{{.*}}locations.f90":14:11)
17
18 !$acc update device(arr)
19 !CHECK-LABEL: acc.update_device varPtr
20 !CHECK-SAME: loc("{{.*}}locations.f90":18:25)
21 !CHECK-LABEL: acc.update dataOperands
22 !CHECK-SAME: loc("{{.*}}locations.f90":18:11)
23
24 !$acc update host(arr)
25 !CHECK-LABEL: acc.getdeviceptr varPtr
26 !CHECK-SAME: loc("{{.*}}locations.f90":24:23)
27 !CHECK-LABEL: acc.update dataOperands
28 !CHECK-SAME: loc("{{.*}}locations.f90":24:11)
29 !CHECK-LABEL: acc.update_host
30 !CHECK-SAME: loc("{{.*}}locations.f90":24:23)
31
32 !$acc exit data delete(arr)
33 !CHECK-LABEL: acc.exit_data
34 !CHECK-SAME: loc("{{.*}}locations.f90":32:11)
35
36 end subroutine
37
38 subroutine nested_acc_locations(arr1d)
39 real, dimension(10) :: arr1d
40 integer :: i
41
42 !$acc data copy(arr1d)
43 !$acc parallel
44 !$acc loop
45 do i = 1, 10
46 arr1d(i) = arr1d(i) * 2
47 end do
48 !$acc end parallel
49 !$acc end data
50
51 !CHECK: acc.data
52 !CHECK: acc.parallel
53 !CHECK: acc.loop
54
55 !CHECK: acc.yield loc("{{.*}}locations.f90":44:11)
56 !CHECK-NEXT: } attributes {{.*}} loc(fused["{{.*}}locations.f90":44:11, "{{.*}}locations.f90":45:5])
57
58 !CHECK: acc.yield loc("{{.*}}locations.f90":43:11)
59 !CHECK-NEXT: } loc("{{.*}}locations.f90":43:11)
60
61 !CHECK-NEXT: acc.terminator loc("{{.*}}locations.f90":42:11)
62 !CHECK-NEXT: } loc("{{.*}}locations.f90":42:11)
63
64 end subroutine
65
66 subroutine runtime_directive()
67
68 !$acc init
69 !CHECK-LABEL: acc.init
70 !CHECK-SAME: loc("{{.*}}locations.f90":68:11)
71
72 !$acc shutdown
73 !CHECK-LABEL: acc.shutdown
74 !CHECK-SAME: loc("{{.*}}locations.f90":72:11)
75
76 end subroutine
77
78 subroutine combined_directive_locations(arr)
79 real :: arr(:)
80 integer :: i
81
82 !$acc parallel loop
83 do i = 1, size(arr)
84 arr(i) = arr(i) * arr(i)
85 end do
86
87 !CHECK: acc.parallel
88 !CHECK: acc.loop
89 !CHECK: acc.yield loc("{{.*}}locations.f90":82:11)
90 !CHECK-NEXT: } {{.*}} loc(fused["{{.*}}locations.f90":82:11, "{{.*}}locations.f90":83:5])
91 !CHECK: acc.yield loc("{{.*}}locations.f90":82:11)
92 !CHECK-NEXT: } loc("{{.*}}locations.f90":82:11)
93 end subroutine
94
95 subroutine if_clause_expr_location(arr)
96 real :: arr(:)
97 integer :: i
98
99 !$acc parallel loop if(.true.)
100 do i = 1, size(arr)
101 arr(i) = arr(i) * arr(i)
102 end do
103
104 !CHECK: %{{.*}} = arith.constant true loc("{{.*}}locations.f90":99:25)
105
106 !CHECK: acc.parallel
107 !CHECK: acc.loop
108 !CHECK: acc.yield loc("{{.*}}locations.f90":99:11)
109 !CHECK-NEXT: } {{.*}} loc(fused["{{.*}}locations.f90":99:11, "{{.*}}locations.f90":100:5])
110 !CHECK: acc.yield loc("{{.*}}locations.f90":99:11)
111 !CHECK-NEXT: } loc("{{.*}}locations.f90":99:11)
112 end subroutine
113
114 subroutine atomic_read_loc()
115 integer(4) :: x
116 integer(8) :: y
117
118 !$acc atomic read
119 y = x
120 end
121 !CHECK: acc.atomic.read {{.*}} loc("{{.*}}locations.f90":118:11)
122
123 subroutine atomic_capture_loc()
124 implicit none
125 integer :: k, v, i
126
127 k = 1
128 v = 0
129
130 !$acc atomic capture
131 v = k
132 k = (i + 1) * 3.14
133 !$acc end atomic
134
135 ! CHECK: acc.atomic.capture {
136 ! CHECK: acc.atomic.read {{.*}} loc("{{.*}}locations.f90":130:11)
137 ! CHECK: acc.atomic.write {{.*}} loc("{{.*}}locations.f90":130:11)
138 ! CHECK: } loc("{{.*}}locations.f90":130:11)
139
140 end subroutine
141
142 subroutine atomic_update_loc()
143 implicit none
144 integer :: x, y, z
145
146 !$acc atomic
147 y = y + 1
148 ! CHECK: acc.atomic.update %{{.*}} : !fir.ref<i32> {
149 ! CHECK: ^bb0(%{{.*}}: i32 loc("{{.*}}locations.f90":142:3)):
150 ! CHECK: } loc("{{.*}}locations.f90":142:3)
151
152 !$acc atomic update
153 z = x * z
154 end subroutine
155
156 subroutine acc_loop_fused_locations(arr)
157 real, dimension(10,10,10) :: arr
158 integer :: i, j, k
159
160 !$acc loop collapse(3)
161 do i = 1, 10
162 do j = 1, 10
163 do k = 1, 10
164 arr(i,j,k) = arr(i,j,k) * 2
165 end do
166 end do
167 end do
168 end subroutine
169
170 ! CHECK-LABEL: func.func @_QMacc_locationsPacc_loop_fused_locations
171 ! CHECK: acc.loop
172 ! CHECK: } attributes {collapse = [3]{{.*}}} loc(fused["{{.*}}locations.f90":160:11, "{{.*}}locations.f90":161:5, "{{.*}}locations.f90":162:7, "{{.*}}locations.f90":163:9])
173
174 end module
175
176