Skip to content
This repository was archived by the owner on Apr 23, 2021. It is now read-only.

Commit a3bb5ad

Browse files
Stephan Herhuttensorflower-gardener
authored andcommitted
Make GPU kernel outlining test independent of value names.
PiperOrigin-RevId: 267323604
1 parent 75bf9ca commit a3bb5ad

File tree

1 file changed

+36
-24
lines changed

1 file changed

+36
-24
lines changed

test/Dialect/GPU/outlining.mlir

Lines changed: 36 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,24 @@
11
// RUN: mlir-opt -gpu-kernel-outlining -split-input-file %s | FileCheck %s
22

33
func @launch() {
4+
// CHECK: %[[ARG0:.*]] = "op"() : () -> f32
45
%0 = "op"() : () -> (f32)
6+
// CHECK: %[[ARG1:.*]] = "op"() : () -> memref<?xf32, 1>
57
%1 = "op"() : () -> (memref<?xf32, 1>)
8+
// CHECK: %[[GDIMX:.*]] = constant 8
69
%gDimX = constant 8 : index
10+
// CHECK: %[[GDIMY:.*]] = constant 12
711
%gDimY = constant 12 : index
12+
// CHECK: %[[GDIMZ:.*]] = constant 16
813
%gDimZ = constant 16 : index
14+
// CHECK: %[[BDIMX:.*]] = constant 20
915
%bDimX = constant 20 : index
16+
// CHECK: %[[BDIMY:.*]] = constant 24
1017
%bDimY = constant 24 : index
18+
// CHECK: %[[BDIMZ:.*]] = constant 28
1119
%bDimZ = constant 28 : index
1220

13-
// CHECK: "gpu.launch_func"(%c8, %c12, %c16, %c20, %c24, %c28, %0, %1) {kernel = @launch_kernel} : (index, index, index, index, index, index, f32, memref<?xf32, 1>) -> ()
21+
// CHECK: "gpu.launch_func"(%[[GDIMX]], %[[GDIMY]], %[[GDIMZ]], %[[BDIMX]], %[[BDIMY]], %[[BDIMZ]], %[[ARG0]], %[[ARG1]]) {kernel = @launch_kernel} : (index, index, index, index, index, index, f32, memref<?xf32, 1>) -> ()
1422
// CHECK-NOT: gpu.launch blocks
1523
gpu.launch blocks(%bx, %by, %bz) in (%grid_x = %gDimX, %grid_y = %gDimY,
1624
%grid_z = %gDimZ)
@@ -25,36 +33,37 @@ func @launch() {
2533
return
2634
}
2735

28-
// CHECK: func @launch_kernel(%arg0: f32, %arg1: memref<?xf32, 1>)
36+
// CHECK: func @launch_kernel(%[[ARG0:.*]]: f32, %[[ARG1:.*]]: memref<?xf32, 1>)
2937
// CHECK-NEXT: attributes {gpu.kernel}
30-
// CHECK-NEXT: %0 = "gpu.block_id"() {dimension = "x"} : () -> index
31-
// CHECK-NEXT: %1 = "gpu.block_id"() {dimension = "y"} : () -> index
32-
// CHECK-NEXT: %2 = "gpu.block_id"() {dimension = "z"} : () -> index
33-
// CHECK-NEXT: %3 = "gpu.thread_id"() {dimension = "x"} : () -> index
34-
// CHECK-NEXT: %4 = "gpu.thread_id"() {dimension = "y"} : () -> index
35-
// CHECK-NEXT: %5 = "gpu.thread_id"() {dimension = "z"} : () -> index
36-
// CHECK-NEXT: %6 = "gpu.grid_dim"() {dimension = "x"} : () -> index
37-
// CHECK-NEXT: %7 = "gpu.grid_dim"() {dimension = "y"} : () -> index
38-
// CHECK-NEXT: %8 = "gpu.grid_dim"() {dimension = "z"} : () -> index
39-
// CHECK-NEXT: %9 = "gpu.block_dim"() {dimension = "x"} : () -> index
40-
// CHECK-NEXT: %10 = "gpu.block_dim"() {dimension = "y"} : () -> index
41-
// CHECK-NEXT: %11 = "gpu.block_dim"() {dimension = "z"} : () -> index
42-
// CHECK-NEXT: "use"(%arg0) : (f32) -> ()
43-
// CHECK-NEXT: "some_op"(%0, %9) : (index, index) -> ()
44-
// CHECK-NEXT: %12 = load %arg1[%3] : memref<?xf32, 1>
38+
// CHECK-NEXT: %[[BID:.*]] = "gpu.block_id"() {dimension = "x"} : () -> index
39+
// CHECK-NEXT: = "gpu.block_id"() {dimension = "y"} : () -> index
40+
// CHECK-NEXT: = "gpu.block_id"() {dimension = "z"} : () -> index
41+
// CHECK-NEXT: %[[TID:.*]] = "gpu.thread_id"() {dimension = "x"} : () -> index
42+
// CHECK-NEXT: = "gpu.thread_id"() {dimension = "y"} : () -> index
43+
// CHECK-NEXT: = "gpu.thread_id"() {dimension = "z"} : () -> index
44+
// CHECK-NEXT: = "gpu.grid_dim"() {dimension = "x"} : () -> index
45+
// CHECK-NEXT: = "gpu.grid_dim"() {dimension = "y"} : () -> index
46+
// CHECK-NEXT: = "gpu.grid_dim"() {dimension = "z"} : () -> index
47+
// CHECK-NEXT: %[[BDIM:.*]] = "gpu.block_dim"() {dimension = "x"} : () -> index
48+
// CHECK-NEXT: = "gpu.block_dim"() {dimension = "y"} : () -> index
49+
// CHECK-NEXT: = "gpu.block_dim"() {dimension = "z"} : () -> index
50+
// CHECK-NEXT: "use"(%[[ARG0]]) : (f32) -> ()
51+
// CHECK-NEXT: "some_op"(%[[BID]], %[[BDIM]]) : (index, index) -> ()
52+
// CHECK-NEXT: = load %[[ARG1]][%[[TID]]] : memref<?xf32, 1>
4553

4654
// -----
4755

4856
func @multiple_launches() {
57+
// CHECK: %[[CST:.*]] = constant 8 : index
4958
%cst = constant 8 : index
50-
// CHECK: "gpu.launch_func"(%c8, %c8, %c8, %c8, %c8, %c8) {kernel = @multiple_launches_kernel} : (index, index, index, index, index, index) -> ()
59+
// CHECK: "gpu.launch_func"(%[[CST]], %[[CST]], %[[CST]], %[[CST]], %[[CST]], %[[CST]]) {kernel = @multiple_launches_kernel} : (index, index, index, index, index, index) -> ()
5160
gpu.launch blocks(%bx, %by, %bz) in (%grid_x = %cst, %grid_y = %cst,
5261
%grid_z = %cst)
5362
threads(%tx, %ty, %tz) in (%block_x = %cst, %block_y = %cst,
5463
%block_z = %cst) {
5564
gpu.return
5665
}
57-
// CHECK: "gpu.launch_func"(%c8, %c8, %c8, %c8, %c8, %c8) {kernel = @multiple_launches_kernel_0} : (index, index, index, index, index, index) -> ()
66+
// CHECK: "gpu.launch_func"(%[[CST]], %[[CST]], %[[CST]], %[[CST]], %[[CST]], %[[CST]]) {kernel = @multiple_launches_kernel_0} : (index, index, index, index, index, index) -> ()
5867
gpu.launch blocks(%bx2, %by2, %bz2) in (%grid_x2 = %cst, %grid_y2 = %cst,
5968
%grid_z2 = %cst)
6069
threads(%tx2, %ty2, %tz2) in (%block_x2 = %cst, %block_y2 = %cst,
@@ -64,25 +73,28 @@ func @multiple_launches() {
6473
return
6574
}
6675

67-
// CHECK: func @multiple_launches_kernel()
68-
// CHECK: func @multiple_launches_kernel_0()
76+
// CHECK-LABEL: func @multiple_launches_kernel()
77+
// CHECK-LABEL: func @multiple_launches_kernel_0()
6978

7079
// -----
7180

7281
func @extra_constants(%arg0 : memref<?xf32>) {
82+
// CHECK: %[[CST:.*]] = constant 8 : index
7383
%cst = constant 8 : index
7484
%cst2 = constant 2 : index
7585
%cst3 = constant 3 : index
76-
// CHECK: "gpu.launch_func"(%c8, %c8, %c8, %c8, %c8, %c8, %arg0) {kernel = @extra_constants_kernel} : (index, index, index, index, index, index, memref<?xf32>) -> ()
86+
// CHECK: "gpu.launch_func"(%[[CST]], %[[CST]], %[[CST]], %[[CST]], %[[CST]], %[[CST]], %{{.*}}) {kernel = @extra_constants_kernel} : (index, index, index, index, index, index, memref<?xf32>) -> ()
7787
gpu.launch blocks(%bx, %by, %bz) in (%grid_x = %cst, %grid_y = %cst,
7888
%grid_z = %cst)
7989
threads(%tx, %ty, %tz) in (%block_x = %cst, %block_y = %cst,
8090
%block_z = %cst)
8191
args(%kernel_arg0 = %cst2, %kernel_arg1 = %arg0, %kernel_arg2 = %cst3) : index, memref<?xf32>, index {
82-
// CHECK: constant
83-
// CHECK: constant
8492
"use"(%kernel_arg0, %kernel_arg1, %kernel_arg2) : (index, memref<?xf32>, index) -> ()
8593
gpu.return
8694
}
8795
return
8896
}
97+
98+
// CHECK-LABEL: func @extra_constants_kernel(%{{.*}}: memref<?xf32>)
99+
// CHECK: constant
100+
// CHECK: constant

0 commit comments

Comments
 (0)