File: int-range-interface.mlir

package info (click to toggle)
swiftlang 6.1.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,791,604 kB
  • sloc: cpp: 9,901,740; ansic: 2,201,431; asm: 1,091,827; python: 308,252; objc: 82,166; f90: 80,126; lisp: 38,358; pascal: 25,559; sh: 20,429; ml: 5,058; perl: 4,745; makefile: 4,484; awk: 3,535; javascript: 3,018; xml: 918; fortran: 664; cs: 573; ruby: 396
file content (331 lines) | stat: -rw-r--r-- 17,959 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
// RUN: mlir-opt -int-range-optimizations -split-input-file %s | FileCheck %s

// CHECK-LABEL: func @launch_func
func.func @launch_func(%arg0 : index) {
  %0 = test.with_bounds {
    umin = 3 : index, umax = 5 : index,
    smin = 3 : index, smax = 5 : index
  } : index
  %1 = test.with_bounds {
    umin = 7 : index, umax = 11 : index,
    smin = 7 : index, smax = 11 : index
  } : index
  gpu.launch blocks(%block_id_x, %block_id_y, %block_id_z) in (%grid_dim_x = %0, %grid_dim_y = %1, %grid_dim_z = %arg0)
      threads(%thread_id_x, %thread_id_y, %thread_id_z) in (%block_dim_x = %arg0, %block_dim_y = %0, %block_dim_z = %1) {

    // CHECK: test.reflect_bounds {smax = 5 : index, smin = 3 : index, umax = 5 : index, umin = 3 : index}
    // CHECK: test.reflect_bounds {smax = 11 : index, smin = 7 : index, umax = 11 : index, umin = 7 : index}
    // CHECK: test.reflect_bounds {smax = 4294967295 : index, smin = 1 : index, umax = 4294967295 : index, umin = 1 : index}
    %grid_dim_x0 = test.reflect_bounds %grid_dim_x : index
    %grid_dim_y0 = test.reflect_bounds %grid_dim_y : index
    %grid_dim_z0 = test.reflect_bounds %grid_dim_z : index

    // CHECK: test.reflect_bounds {smax = 4 : index, smin = 0 : index, umax = 4 : index, umin = 0 : index}
    // CHECK: test.reflect_bounds {smax = 10 : index, smin = 0 : index, umax = 10 : index, umin = 0 : index}
    // CHECK: test.reflect_bounds {smax = 4294967294 : index, smin = 0 : index, umax = 4294967294 : index, umin = 0 : index}
    %block_id_x0 = test.reflect_bounds %block_id_x : index
    %block_id_y0 = test.reflect_bounds %block_id_y : index
    %block_id_z0 = test.reflect_bounds %block_id_z : index

    // CHECK: test.reflect_bounds {smax = 4294967295 : index, smin = 1 : index, umax = 4294967295 : index, umin = 1 : index}
    // CHECK: test.reflect_bounds {smax = 5 : index, smin = 3 : index, umax = 5 : index, umin = 3 : index}
    // CHECK: test.reflect_bounds {smax = 11 : index, smin = 7 : index, umax = 11 : index, umin = 7 : index}
    %block_dim_x0 = test.reflect_bounds %block_dim_x : index
    %block_dim_y0 = test.reflect_bounds %block_dim_y : index
    %block_dim_z0 = test.reflect_bounds %block_dim_z : index

    // CHECK: test.reflect_bounds {smax = 4294967294 : index, smin = 0 : index, umax = 4294967294 : index, umin = 0 : index}
    // CHECK: test.reflect_bounds {smax = 4 : index, smin = 0 : index, umax = 4 : index, umin = 0 : index}
    // CHECK: test.reflect_bounds {smax = 10 : index, smin = 0 : index, umax = 10 : index, umin = 0 : index}
    %thread_id_x0 = test.reflect_bounds %thread_id_x : index
    %thread_id_y0 = test.reflect_bounds %thread_id_y : index
    %thread_id_z0 = test.reflect_bounds %thread_id_z : index

    // The launch bounds are not constant, and so this can't infer anything
    // CHECK: test.reflect_bounds {smax = 4294967294 : index, smin = 0 : index, umax = 4294967294 : index, umin = 0 : index}
    %thread_id_op = gpu.thread_id y
    %thread_id_op0 = test.reflect_bounds %thread_id_op : index
    gpu.terminator
  }

  func.return
}

// -----

// CHECK-LABEL: func @kernel
module attributes {gpu.container_module} {
  gpu.module @gpu_module {
    llvm.func @kernel() attributes {gpu.kernel} {

      %grid_dim_x = gpu.grid_dim x
      %grid_dim_y = gpu.grid_dim y
      %grid_dim_z = gpu.grid_dim z

      // CHECK: test.reflect_bounds {smax = 4294967295 : index, smin = 1 : index, umax = 4294967295 : index, umin = 1 : index}
      // CHECK: test.reflect_bounds {smax = 4294967295 : index, smin = 1 : index, umax = 4294967295 : index, umin = 1 : index}
      // CHECK: test.reflect_bounds {smax = 4294967295 : index, smin = 1 : index, umax = 4294967295 : index, umin = 1 : index}
      %grid_dim_x0 = test.reflect_bounds %grid_dim_x : index
      %grid_dim_y0 = test.reflect_bounds %grid_dim_y : index
      %grid_dim_z0 = test.reflect_bounds %grid_dim_z : index

      %block_id_x = gpu.block_id x
      %block_id_y = gpu.block_id y
      %block_id_z = gpu.block_id z

      // CHECK: test.reflect_bounds {smax = 4294967294 : index, smin = 0 : index, umax = 4294967294 : index, umin = 0 : index}
      // CHECK: test.reflect_bounds {smax = 4294967294 : index, smin = 0 : index, umax = 4294967294 : index, umin = 0 : index}
      // CHECK: test.reflect_bounds {smax = 4294967294 : index, smin = 0 : index, umax = 4294967294 : index, umin = 0 : index}
      %block_id_x0 = test.reflect_bounds %block_id_x : index
      %block_id_y0 = test.reflect_bounds %block_id_y : index
      %block_id_z0 = test.reflect_bounds %block_id_z : index

      %block_dim_x = gpu.block_dim x
      %block_dim_y = gpu.block_dim y
      %block_dim_z = gpu.block_dim z

      // CHECK: test.reflect_bounds {smax = 4294967295 : index, smin = 1 : index, umax = 4294967295 : index, umin = 1 : index}
      // CHECK: test.reflect_bounds {smax = 4294967295 : index, smin = 1 : index, umax = 4294967295 : index, umin = 1 : index}
      // CHECK: test.reflect_bounds {smax = 4294967295 : index, smin = 1 : index, umax = 4294967295 : index, umin = 1 : index}
      %block_dim_x0 = test.reflect_bounds %block_dim_x : index
      %block_dim_y0 = test.reflect_bounds %block_dim_y : index
      %block_dim_z0 = test.reflect_bounds %block_dim_z : index

      %thread_id_x = gpu.thread_id x
      %thread_id_y = gpu.thread_id y
      %thread_id_z = gpu.thread_id z

      // CHECK: test.reflect_bounds {smax = 4294967294 : index, smin = 0 : index, umax = 4294967294 : index, umin = 0 : index}
      // CHECK: test.reflect_bounds {smax = 4294967294 : index, smin = 0 : index, umax = 4294967294 : index, umin = 0 : index}
      // CHECK: test.reflect_bounds {smax = 4294967294 : index, smin = 0 : index, umax = 4294967294 : index, umin = 0 : index}
      %thread_id_x0 = test.reflect_bounds %thread_id_x : index
      %thread_id_y0 = test.reflect_bounds %thread_id_y : index
      %thread_id_z0 = test.reflect_bounds %thread_id_z : index

      %global_id_x = gpu.global_id x
      %global_id_y = gpu.global_id y
      %global_id_z = gpu.global_id z

      // CHECK: test.reflect_bounds {smax = 9223372036854775807 : index, smin = -9223372036854775808 : index, umax = -8589934592 : index, umin = 0 : index}
      // CHECK: test.reflect_bounds {smax = 9223372036854775807 : index, smin = -9223372036854775808 : index, umax = -8589934592 : index, umin = 0 : index}
      // CHECK: test.reflect_bounds {smax = 9223372036854775807 : index, smin = -9223372036854775808 : index, umax = -8589934592 : index, umin = 0 : index}
      %global_id_x0 = test.reflect_bounds %global_id_x : index
      %global_id_y0 = test.reflect_bounds %global_id_y : index
      %global_id_z0 = test.reflect_bounds %global_id_z : index

      %subgroup_size = gpu.subgroup_size : index
      %lane_id = gpu.lane_id
      %num_subgroups = gpu.num_subgroups : index
      %subgroup_id = gpu.subgroup_id : index

      // CHECK: test.reflect_bounds {smax = 128 : index, smin = 1 : index, umax = 128 : index, umin = 1 : index}
      // CHECK: test.reflect_bounds {smax = 127 : index, smin = 0 : index, umax = 127 : index, umin = 0 : index}
      // CHECK: test.reflect_bounds {smax = 4294967295 : index, smin = 1 : index, umax = 4294967295 : index, umin = 1 : index}
      // CHECK: test.reflect_bounds {smax = 4294967294 : index, smin = 0 : index, umax = 4294967294 : index, umin = 0 : index}
      %subgroup_size0 = test.reflect_bounds %subgroup_size : index
      %lane_id0 = test.reflect_bounds %lane_id : index
      %num_subgroups0 = test.reflect_bounds %num_subgroups : index
      %subgroup_id0 = test.reflect_bounds %subgroup_id : index

      llvm.return
    }
  }
}

// -----

// CHECK-LABEL: func @annotated_kernel
module attributes {gpu.container_module} {
  gpu.module @gpu_module {
    gpu.func @annotated_kernel() kernel
      attributes {known_block_size = array<i32: 8, 12, 16>,
          known_grid_size = array<i32: 20, 24, 28>} {

      %grid_dim_x = gpu.grid_dim x
      %grid_dim_y = gpu.grid_dim y
      %grid_dim_z = gpu.grid_dim z

      // CHECK: test.reflect_bounds {smax = 20 : index, smin = 20 : index, umax = 20 : index, umin = 20 : index}
      // CHECK: test.reflect_bounds {smax = 24 : index, smin = 24 : index, umax = 24 : index, umin = 24 : index}
      // CHECK: test.reflect_bounds {smax = 28 : index, smin = 28 : index, umax = 28 : index, umin = 28 : index}
      %grid_dim_x0 = test.reflect_bounds %grid_dim_x : index
      %grid_dim_y0 = test.reflect_bounds %grid_dim_y : index
      %grid_dim_z0 = test.reflect_bounds %grid_dim_z : index

      %block_id_x = gpu.block_id x
      %block_id_y = gpu.block_id y
      %block_id_z = gpu.block_id z

      // CHECK: test.reflect_bounds {smax = 19 : index, smin = 0 : index, umax = 19 : index, umin = 0 : index}
      // CHECK: test.reflect_bounds {smax = 23 : index, smin = 0 : index, umax = 23 : index, umin = 0 : index}
      // CHECK: test.reflect_bounds {smax = 27 : index, smin = 0 : index, umax = 27 : index, umin = 0 : index}
      %block_id_x0 = test.reflect_bounds %block_id_x : index
      %block_id_y0 = test.reflect_bounds %block_id_y : index
      %block_id_z0 = test.reflect_bounds %block_id_z : index

      %block_dim_x = gpu.block_dim x
      %block_dim_y = gpu.block_dim y
      %block_dim_z = gpu.block_dim z

      // CHECK: test.reflect_bounds {smax = 8 : index, smin = 8 : index, umax = 8 : index, umin = 8 : index}
      // CHECK: test.reflect_bounds {smax = 12 : index, smin = 12 : index, umax = 12 : index, umin = 12 : index}
      // CHECK: test.reflect_bounds {smax = 16 : index, smin = 16 : index, umax = 16 : index, umin = 16 : index}
      %block_dim_x0 = test.reflect_bounds %block_dim_x : index
      %block_dim_y0 = test.reflect_bounds %block_dim_y : index
      %block_dim_z0 = test.reflect_bounds %block_dim_z : index

      %thread_id_x = gpu.thread_id x
      %thread_id_y = gpu.thread_id y
      %thread_id_z = gpu.thread_id z

      // CHECK: test.reflect_bounds {smax = 7 : index, smin = 0 : index, umax = 7 : index, umin = 0 : index}
      // CHECK: test.reflect_bounds {smax = 11 : index, smin = 0 : index, umax = 11 : index, umin = 0 : index}
      // CHECK: test.reflect_bounds {smax = 15 : index, smin = 0 : index, umax = 15 : index, umin = 0 : index}
      %thread_id_x0 = test.reflect_bounds %thread_id_x : index
      %thread_id_y0 = test.reflect_bounds %thread_id_y : index
      %thread_id_z0 = test.reflect_bounds %thread_id_z : index

      %global_id_x = gpu.global_id x
      %global_id_y = gpu.global_id y
      %global_id_z = gpu.global_id z

      // CHECK: test.reflect_bounds {smax = 159 : index, smin = 0 : index, umax = 159 : index, umin = 0 : index}
      // CHECK: test.reflect_bounds {smax = 287 : index, smin = 0 : index, umax = 287 : index, umin = 0 : index}
      // CHECK: test.reflect_bounds {smax = 447 : index, smin = 0 : index, umax = 447 : index, umin = 0 : index}
      %global_id_x0 = test.reflect_bounds %global_id_x : index
      %global_id_y0 = test.reflect_bounds %global_id_y : index
      %global_id_z0 = test.reflect_bounds %global_id_z : index

      %subgroup_size = gpu.subgroup_size : index
      %lane_id = gpu.lane_id
      %num_subgroups = gpu.num_subgroups : index
      %subgroup_id = gpu.subgroup_id : index

      // CHECK: test.reflect_bounds {smax = 128 : index, smin = 1 : index, umax = 128 : index, umin = 1 : index}
      // CHECK: test.reflect_bounds {smax = 127 : index, smin = 0 : index, umax = 127 : index, umin = 0 : index}
      // CHECK: test.reflect_bounds {smax = 4294967295 : index, smin = 1 : index, umax = 4294967295 : index, umin = 1 : index}
      // CHECK: test.reflect_bounds {smax = 4294967294 : index, smin = 0 : index, umax = 4294967294 : index, umin = 0 : index}
      %subgroup_size0 = test.reflect_bounds %subgroup_size : index
      %lane_id0 = test.reflect_bounds %lane_id : index
      %num_subgroups0 = test.reflect_bounds %num_subgroups : index
      %subgroup_id0 = test.reflect_bounds %subgroup_id : index

      gpu.return
    }
  }
}

// -----

// CHECK-LABEL: func @annotated_kernel
module {
  func.func @annotated_kernel()
    attributes {gpu.known_block_size = array<i32: 8, 12, 16>,
        gpu.known_grid_size = array<i32: 20, 24, 28>} {

    %block_id_x = gpu.block_id x
    %block_id_y = gpu.block_id y
    %block_id_z = gpu.block_id z

    // CHECK: test.reflect_bounds {smax = 19 : index, smin = 0 : index, umax = 19 : index, umin = 0 : index}
    // CHECK: test.reflect_bounds {smax = 23 : index, smin = 0 : index, umax = 23 : index, umin = 0 : index}
    // CHECK: test.reflect_bounds {smax = 27 : index, smin = 0 : index, umax = 27 : index, umin = 0 : index}
    %block_id_x0 = test.reflect_bounds %block_id_x : index
    %block_id_y0 = test.reflect_bounds %block_id_y : index
    %block_id_z0 = test.reflect_bounds %block_id_z : index

    %thread_id_x = gpu.thread_id x
    %thread_id_y = gpu.thread_id y
    %thread_id_z = gpu.thread_id z

    // CHECK: test.reflect_bounds {smax = 7 : index, smin = 0 : index, umax = 7 : index, umin = 0 : index}
    // CHECK: test.reflect_bounds {smax = 11 : index, smin = 0 : index, umax = 11 : index, umin = 0 : index}
    // CHECK: test.reflect_bounds {smax = 15 : index, smin = 0 : index, umax = 15 : index, umin = 0 : index}
    %thread_id_x0 = test.reflect_bounds %thread_id_x : index
    %thread_id_y0 = test.reflect_bounds %thread_id_y : index
    %thread_id_z0 = test.reflect_bounds %thread_id_z : index

    return
  }
}

// -----

// CHECK-LABEL: func @local_bounds_kernel
module attributes {gpu.container_module} {
  gpu.module @gpu_module {
    gpu.func @local_bounds_kernel() kernel {

      %grid_dim_x = gpu.grid_dim x upper_bound 20
      %grid_dim_y = gpu.grid_dim y upper_bound 24
      %grid_dim_z = gpu.grid_dim z upper_bound 28

      // CHECK: test.reflect_bounds {smax = 20 : index, smin = 1 : index, umax = 20 : index, umin = 1 : index}
      // CHECK: test.reflect_bounds {smax = 24 : index, smin = 1 : index, umax = 24 : index, umin = 1 : index}
      // CHECK: test.reflect_bounds {smax = 28 : index, smin = 1 : index, umax = 28 : index, umin = 1 : index}
      %grid_dim_x0 = test.reflect_bounds %grid_dim_x : index
      %grid_dim_y0 = test.reflect_bounds %grid_dim_y : index
      %grid_dim_z0 = test.reflect_bounds %grid_dim_z : index

      %block_id_x = gpu.block_id x upper_bound 20
      %block_id_y = gpu.block_id y upper_bound 24
      %block_id_z = gpu.block_id z upper_bound 28

      // CHECK: test.reflect_bounds {smax = 19 : index, smin = 0 : index, umax = 19 : index, umin = 0 : index}
      // CHECK: test.reflect_bounds {smax = 23 : index, smin = 0 : index, umax = 23 : index, umin = 0 : index}
      // CHECK: test.reflect_bounds {smax = 27 : index, smin = 0 : index, umax = 27 : index, umin = 0 : index}
      %block_id_x0 = test.reflect_bounds %block_id_x : index
      %block_id_y0 = test.reflect_bounds %block_id_y : index
      %block_id_z0 = test.reflect_bounds %block_id_z : index

      %block_dim_x = gpu.block_dim x upper_bound 8
      %block_dim_y = gpu.block_dim y upper_bound 12
      %block_dim_z = gpu.block_dim z upper_bound 16

      // CHECK: test.reflect_bounds {smax = 8 : index, smin = 1 : index, umax = 8 : index, umin = 1 : index}
      // CHECK: test.reflect_bounds {smax = 12 : index, smin = 1 : index, umax = 12 : index, umin = 1 : index}
      // CHECK: test.reflect_bounds {smax = 16 : index, smin = 1 : index, umax = 16 : index, umin = 1 : index}
      %block_dim_x0 = test.reflect_bounds %block_dim_x : index
      %block_dim_y0 = test.reflect_bounds %block_dim_y : index
      %block_dim_z0 = test.reflect_bounds %block_dim_z : index

      %thread_id_x = gpu.thread_id x upper_bound 8
      %thread_id_y = gpu.thread_id y upper_bound 12
      %thread_id_z = gpu.thread_id z upper_bound 16

      // CHECK: test.reflect_bounds {smax = 7 : index, smin = 0 : index, umax = 7 : index, umin = 0 : index}
      // CHECK: test.reflect_bounds {smax = 11 : index, smin = 0 : index, umax = 11 : index, umin = 0 : index}
      // CHECK: test.reflect_bounds {smax = 15 : index, smin = 0 : index, umax = 15 : index, umin = 0 : index}
      %thread_id_x0 = test.reflect_bounds %thread_id_x : index
      %thread_id_y0 = test.reflect_bounds %thread_id_y : index
      %thread_id_z0 = test.reflect_bounds %thread_id_z : index

      %global_id_x = gpu.global_id x upper_bound 160
      %global_id_y = gpu.global_id y upper_bound 288
      %global_id_z = gpu.global_id z upper_bound 448

      // CHECK: test.reflect_bounds {smax = 159 : index, smin = 0 : index, umax = 159 : index, umin = 0 : index}
      // CHECK: test.reflect_bounds {smax = 287 : index, smin = 0 : index, umax = 287 : index, umin = 0 : index}
      // CHECK: test.reflect_bounds {smax = 447 : index, smin = 0 : index, umax = 447 : index, umin = 0 : index}
      %global_id_x0 = test.reflect_bounds %global_id_x : index
      %global_id_y0 = test.reflect_bounds %global_id_y : index
      %global_id_z0 = test.reflect_bounds %global_id_z : index

      %subgroup_size = gpu.subgroup_size upper_bound 32 : index
      %subgroup_id = gpu.subgroup_id upper_bound 32 : index
      %num_subgroups = gpu.num_subgroups upper_bound 8 : index
      %lane_id = gpu.lane_id upper_bound 64

      // CHECK: test.reflect_bounds {smax = 32 : index, smin = 1 : index, umax = 32 : index, umin = 1 : index}
      // CHECK: test.reflect_bounds {smax = 31 : index, smin = 0 : index, umax = 31 : index, umin = 0 : index}
      // CHECK: test.reflect_bounds {smax = 8 : index, smin = 1 : index, umax = 8 : index, umin = 1 : index}
      // CHECK: test.reflect_bounds {smax = 63 : index, smin = 0 : index, umax = 63 : index, umin = 0 : index}
      %subgroup_size0 = test.reflect_bounds %subgroup_size : index
      %subgroup_id0 = test.reflect_bounds %subgroup_id : index
      %num_subgroups0 = test.reflect_bounds %num_subgroups : index
      %lane_id0 = test.reflect_bounds %lane_id : index

      gpu.return
    }
  }
}