Changeset View
Changeset View
Standalone View
Standalone View
mlir/test/Dialect/GPU/outlining.mlir
Show All 15 Lines | func @launch() { | ||||
%gDimZ = constant 16 : index | %gDimZ = constant 16 : index | ||||
// CHECK: %[[BDIMX:.*]] = constant 20 | // CHECK: %[[BDIMX:.*]] = constant 20 | ||||
%bDimX = constant 20 : index | %bDimX = constant 20 : index | ||||
// CHECK: %[[BDIMY:.*]] = constant 24 | // CHECK: %[[BDIMY:.*]] = constant 24 | ||||
%bDimY = constant 24 : index | %bDimY = constant 24 : index | ||||
// CHECK: %[[BDIMZ:.*]] = constant 28 | // CHECK: %[[BDIMZ:.*]] = constant 28 | ||||
%bDimZ = constant 28 : index | %bDimZ = constant 28 : index | ||||
// CHECK: "gpu.launch_func"(%[[GDIMX]], %[[GDIMY]], %[[GDIMZ]], %[[BDIMX]], %[[BDIMY]], %[[BDIMZ]], %[[ARG0]], %[[ARG1]]) {kernel = @launch_kernel::@launch_kernel} : (index, index, index, index, index, index, f32, memref<?xf32, 1>) -> () | // CHECK: gpu.launch_func @launch_kernel::@launch_kernel blocks in (%[[GDIMX]], %[[GDIMY]], %[[GDIMZ]]) threads in (%[[BDIMX]], %[[BDIMY]], %[[BDIMZ]]) args(%[[ARG0]] : f32, %[[ARG1]] : memref<?xf32, 1>) | ||||
// CHECK-NOT: gpu.launch blocks | // CHECK-NOT: gpu.launch blocks | ||||
gpu.launch blocks(%bx, %by, %bz) in (%grid_x = %gDimX, %grid_y = %gDimY, | gpu.launch blocks(%bx, %by, %bz) in (%grid_x = %gDimX, %grid_y = %gDimY, | ||||
%grid_z = %gDimZ) | %grid_z = %gDimZ) | ||||
threads(%tx, %ty, %tz) in (%block_x = %bDimX, %block_y = %bDimY, | threads(%tx, %ty, %tz) in (%block_x = %bDimX, %block_y = %bDimY, | ||||
%block_z = %bDimZ) { | %block_z = %bDimZ) { | ||||
"use"(%0): (f32) -> () | "use"(%0): (f32) -> () | ||||
"some_op"(%bx, %block_x) : (index, index) -> () | "some_op"(%bx, %block_x) : (index, index) -> () | ||||
%42 = load %1[%tx] : memref<?xf32, 1> | %42 = load %1[%tx] : memref<?xf32, 1> | ||||
Show All 26 Lines | |||||
// ----- | // ----- | ||||
// CHECK: module attributes {gpu.container_module} | // CHECK: module attributes {gpu.container_module} | ||||
// CHECK-LABEL: @multiple_launches | // CHECK-LABEL: @multiple_launches | ||||
func @multiple_launches() { | func @multiple_launches() { | ||||
// CHECK: %[[CST:.*]] = constant 8 : index | // CHECK: %[[CST:.*]] = constant 8 : index | ||||
%cst = constant 8 : index | %cst = constant 8 : index | ||||
// CHECK: "gpu.launch_func"(%[[CST]], %[[CST]], %[[CST]], %[[CST]], %[[CST]], %[[CST]]) {kernel = @multiple_launches_kernel::@multiple_launches_kernel} : (index, index, index, index, index, index) -> () | // CHECK: gpu.launch_func @multiple_launches_kernel::@multiple_launches_kernel blocks in (%[[CST]], %[[CST]], %[[CST]]) threads in (%[[CST]], %[[CST]], %[[CST]]) | ||||
gpu.launch blocks(%bx, %by, %bz) in (%grid_x = %cst, %grid_y = %cst, | gpu.launch blocks(%bx, %by, %bz) in (%grid_x = %cst, %grid_y = %cst, | ||||
%grid_z = %cst) | %grid_z = %cst) | ||||
threads(%tx, %ty, %tz) in (%block_x = %cst, %block_y = %cst, | threads(%tx, %ty, %tz) in (%block_x = %cst, %block_y = %cst, | ||||
%block_z = %cst) { | %block_z = %cst) { | ||||
gpu.terminator | gpu.terminator | ||||
} | } | ||||
// CHECK: "gpu.launch_func"(%[[CST]], %[[CST]], %[[CST]], %[[CST]], %[[CST]], %[[CST]]) {kernel = @multiple_launches_kernel_0::@multiple_launches_kernel} : (index, index, index, index, index, index) -> () | // CHECK: gpu.launch_func @multiple_launches_kernel_0::@multiple_launches_kernel blocks in (%[[CST]], %[[CST]], %[[CST]]) threads in (%[[CST]], %[[CST]], %[[CST]]) | ||||
gpu.launch blocks(%bx2, %by2, %bz2) in (%grid_x2 = %cst, %grid_y2 = %cst, | gpu.launch blocks(%bx2, %by2, %bz2) in (%grid_x2 = %cst, %grid_y2 = %cst, | ||||
%grid_z2 = %cst) | %grid_z2 = %cst) | ||||
threads(%tx2, %ty2, %tz2) in (%block_x2 = %cst, %block_y2 = %cst, | threads(%tx2, %ty2, %tz2) in (%block_x2 = %cst, %block_y2 = %cst, | ||||
%block_z2 = %cst) { | %block_z2 = %cst) { | ||||
gpu.terminator | gpu.terminator | ||||
} | } | ||||
return | return | ||||
} | } | ||||
// CHECK: module @multiple_launches_kernel | // CHECK: module @multiple_launches_kernel | ||||
// CHECK: func @multiple_launches_kernel | // CHECK: func @multiple_launches_kernel | ||||
// CHECK: module @multiple_launches_kernel_0 | // CHECK: module @multiple_launches_kernel_0 | ||||
// CHECK: func @multiple_launches_kernel | // CHECK: func @multiple_launches_kernel | ||||
// ----- | // ----- | ||||
// CHECK-LABEL: @extra_constants_not_inlined | // CHECK-LABEL: @extra_constants_not_inlined | ||||
func @extra_constants_not_inlined(%arg0: memref<?xf32>) { | func @extra_constants_not_inlined(%arg0: memref<?xf32>) { | ||||
// CHECK: %[[CST:.*]] = constant 8 : index | // CHECK: %[[CST:.*]] = constant 8 : index | ||||
%cst = constant 8 : index | %cst = constant 8 : index | ||||
%cst2 = constant 2 : index | %cst2 = constant 2 : index | ||||
%c0 = constant 0 : index | %c0 = constant 0 : index | ||||
%cst3 = "secret_constant"() : () -> index | %cst3 = "secret_constant"() : () -> index | ||||
// CHECK: "gpu.launch_func"(%[[CST]], %[[CST]], %[[CST]], %[[CST]], %[[CST]], %[[CST]], %{{.*}}, %{{.*}}) {kernel = @extra_constants_not_inlined_kernel::@extra_constants_not_inlined_kernel} : (index, index, index, index, index, index, memref<?xf32>, index) -> () | // CHECK: gpu.launch_func @extra_constants_not_inlined_kernel::@extra_constants_not_inlined_kernel blocks in (%[[CST]], %[[CST]], %[[CST]]) threads in (%[[CST]], %[[CST]], %[[CST]]) args({{.*}} : memref<?xf32>, {{.*}} : index) | ||||
gpu.launch blocks(%bx, %by, %bz) in (%grid_x = %cst, %grid_y = %cst, | gpu.launch blocks(%bx, %by, %bz) in (%grid_x = %cst, %grid_y = %cst, | ||||
%grid_z = %cst) | %grid_z = %cst) | ||||
threads(%tx, %ty, %tz) in (%block_x = %cst, %block_y = %cst, | threads(%tx, %ty, %tz) in (%block_x = %cst, %block_y = %cst, | ||||
%block_z = %cst) { | %block_z = %cst) { | ||||
"use"(%cst2, %arg0, %cst3) : (index, memref<?xf32>, index) -> () | "use"(%cst2, %arg0, %cst3) : (index, memref<?xf32>, index) -> () | ||||
gpu.terminator | gpu.terminator | ||||
} | } | ||||
return | return | ||||
} | } | ||||
// CHECK-LABEL: func @extra_constants_not_inlined_kernel(%{{.*}}: memref<?xf32>, %{{.*}}: index) | // CHECK-LABEL: func @extra_constants_not_inlined_kernel(%{{.*}}: memref<?xf32>, %{{.*}}: index) | ||||
// CHECK: constant 2 | // CHECK: constant 2 | ||||
// ----- | // ----- | ||||
// CHECK-LABEL: @extra_constants | // CHECK-LABEL: @extra_constants | ||||
// CHECK-SAME: %[[ARG0:.*]]: memref<?xf32> | // CHECK-SAME: %[[ARG0:.*]]: memref<?xf32> | ||||
func @extra_constants(%arg0: memref<?xf32>) { | func @extra_constants(%arg0: memref<?xf32>) { | ||||
// CHECK: %[[CST:.*]] = constant 8 : index | // CHECK: %[[CST:.*]] = constant 8 : index | ||||
%cst = constant 8 : index | %cst = constant 8 : index | ||||
%cst2 = constant 2 : index | %cst2 = constant 2 : index | ||||
%c0 = constant 0 : index | %c0 = constant 0 : index | ||||
%cst3 = dim %arg0, %c0 : memref<?xf32> | %cst3 = dim %arg0, %c0 : memref<?xf32> | ||||
// CHECK: "gpu.launch_func"(%[[CST]], %[[CST]], %[[CST]], %[[CST]], %[[CST]], %[[CST]], %[[ARG0]]) {kernel = @extra_constants_kernel::@extra_constants_kernel} : (index, index, index, index, index, index, memref<?xf32>) -> () | // CHECK: gpu.launch_func @extra_constants_kernel::@extra_constants_kernel blocks in (%[[CST]], %[[CST]], %[[CST]]) threads in (%[[CST]], %[[CST]], %[[CST]]) args(%[[ARG0]] : memref<?xf32>) | ||||
gpu.launch blocks(%bx, %by, %bz) in (%grid_x = %cst, %grid_y = %cst, | gpu.launch blocks(%bx, %by, %bz) in (%grid_x = %cst, %grid_y = %cst, | ||||
%grid_z = %cst) | %grid_z = %cst) | ||||
threads(%tx, %ty, %tz) in (%block_x = %cst, %block_y = %cst, | threads(%tx, %ty, %tz) in (%block_x = %cst, %block_y = %cst, | ||||
%block_z = %cst) { | %block_z = %cst) { | ||||
"use"(%cst2, %arg0, %cst3) : (index, memref<?xf32>, index) -> () | "use"(%cst2, %arg0, %cst3) : (index, memref<?xf32>, index) -> () | ||||
gpu.terminator | gpu.terminator | ||||
} | } | ||||
return | return | ||||
} | } | ||||
// CHECK-LABEL: func @extra_constants_kernel | // CHECK-LABEL: func @extra_constants_kernel( | ||||
// CHECK-SAME: %[[KARG0:.*]]: memref<?xf32> | // CHECK-SAME: %[[KARG0:.*]]: memref<?xf32> | ||||
// CHECK: constant 2 | // CHECK: constant 2 | ||||
// CHECK: constant 0 | // CHECK: constant 0 | ||||
// CHECK: dim %[[KARG0]] | // CHECK: dim %[[KARG0]] | ||||
// ----- | // ----- | ||||
// CHECK-LABEL: @extra_constants_noarg | // CHECK-LABEL: @extra_constants_noarg | ||||
// CHECK-SAME: %[[ARG0:.*]]: memref<?xf32>, %[[ARG1:.*]]: memref<?xf32> | // CHECK-SAME: %[[ARG0:.*]]: memref<?xf32>, %[[ARG1:.*]]: memref<?xf32> | ||||
func @extra_constants_noarg(%arg0: memref<?xf32>, %arg1: memref<?xf32>) { | func @extra_constants_noarg(%arg0: memref<?xf32>, %arg1: memref<?xf32>) { | ||||
// CHECK: %[[CST:.*]] = constant 8 : index | // CHECK: %[[CST:.*]] = constant 8 : index | ||||
%cst = constant 8 : index | %cst = constant 8 : index | ||||
%cst2 = constant 2 : index | %cst2 = constant 2 : index | ||||
%c0 = constant 0 : index | %c0 = constant 0 : index | ||||
// CHECK: dim %[[ARG1]] | // CHECK: dim %[[ARG1]] | ||||
%cst3 = dim %arg1, %c0 : memref<?xf32> | %cst3 = dim %arg1, %c0 : memref<?xf32> | ||||
// CHECK: "gpu.launch_func"(%[[CST]], %[[CST]], %[[CST]], %[[CST]], %[[CST]], %[[CST]], %[[ARG0]], %{{.*}}) {kernel = @extra_constants_noarg_kernel::@extra_constants_noarg_kernel} : (index, index, index, index, index, index, memref<?xf32>, index) -> () | // CHECK: gpu.launch_func @extra_constants_noarg_kernel::@extra_constants_noarg_kernel blocks in (%[[CST]], %[[CST]], %[[CST]]) threads in (%[[CST]], %[[CST]], %[[CST]]) args(%[[ARG0]] : memref<?xf32>, {{.*}} : index) | ||||
gpu.launch blocks(%bx, %by, %bz) in (%grid_x = %cst, %grid_y = %cst, | gpu.launch blocks(%bx, %by, %bz) in (%grid_x = %cst, %grid_y = %cst, | ||||
%grid_z = %cst) | %grid_z = %cst) | ||||
threads(%tx, %ty, %tz) in (%block_x = %cst, %block_y = %cst, | threads(%tx, %ty, %tz) in (%block_x = %cst, %block_y = %cst, | ||||
%block_z = %cst) { | %block_z = %cst) { | ||||
"use"(%cst2, %arg0, %cst3) : (index, memref<?xf32>, index) -> () | "use"(%cst2, %arg0, %cst3) : (index, memref<?xf32>, index) -> () | ||||
gpu.terminator | gpu.terminator | ||||
} | } | ||||
return | return | ||||
} | } | ||||
// CHECK-LABEL: func @extra_constants_noarg_kernel | // CHECK-LABEL: func @extra_constants_noarg_kernel( | ||||
// CHECK-SAME: %[[KARG0:.*]]: memref<?xf32>, %[[KARG1:.*]]: index | // CHECK-SAME: %[[KARG0:.*]]: memref<?xf32>, %[[KARG1:.*]]: index | ||||
// CHECK: %[[KCST:.*]] = constant 2 | // CHECK: %[[KCST:.*]] = constant 2 | ||||
// CHECK: "use"(%[[KCST]], %[[KARG0]], %[[KARG1]]) | // CHECK: "use"(%[[KCST]], %[[KARG0]], %[[KARG1]]) | ||||
// ----- | // ----- | ||||
// CHECK-LABEL: @multiple_uses | // CHECK-LABEL: @multiple_uses | ||||
func @multiple_uses(%arg0 : memref<?xf32>) { | func @multiple_uses(%arg0 : memref<?xf32>) { | ||||
▲ Show 20 Lines • Show All 87 Lines • Show Last 20 Lines |