Skip to content

Commit 87c2b7c

Browse files
[mlir][gpu]add AffineScope Trait to gpu.launch. (#121058)
add AffineScope Trait to gpu.launch.
1 parent e78074e commit 87c2b7c

File tree

3 files changed

+21
-21
lines changed

3 files changed

+21
-21
lines changed

mlir/include/mlir/Dialect/GPU/IR/GPUOps.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -794,9 +794,9 @@ def GPU_LaunchFuncOp :GPU_Op<"launch_func", [
794794
}
795795

796796
def GPU_LaunchOp : GPU_Op<"launch", [
797-
AutomaticAllocationScope, AttrSizedOperandSegments, GPU_AsyncOpInterface,
797+
AffineScope, AutomaticAllocationScope, AttrSizedOperandSegments,
798798
DeclareOpInterfaceMethods<InferIntRangeInterface, ["inferResultRanges"]>,
799-
RecursiveMemoryEffects]>,
799+
GPU_AsyncOpInterface, RecursiveMemoryEffects]>,
800800
Arguments<(ins Variadic<GPU_AsyncToken>:$asyncDependencies,
801801
Index:$gridSizeX, Index:$gridSizeY, Index:$gridSizeZ,
802802
Index:$blockSizeX, Index:$blockSizeY, Index:$blockSizeZ,

mlir/test/Dialect/Affine/ops.mlir

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -301,29 +301,29 @@ func.func @linearize_mixed(%index0: index, %index1: index, %index2: index, %basi
301301

302302
// -----
303303

304-
#map = affine_map<()[s0] -> (s0)>
304+
// CHECK-LABEL: @gpu_launch_affine
305305

306-
// CHECK-LABEL: @gpu_affine_for
306+
// Test `thread_id` in AffineScope, the `thread_id` is in AffineScope's toplevel,
307+
// it is a valid symbol.
307308

308-
module attributes {gpu.container_module} {
309-
gpu.module @gpu {
310-
gpu.func @gpu_affine_for(%arg0: memref<?x?xf32>) kernel {
311-
%c3 = arith.constant 1 : index
312-
%dim = memref.dim %arg0, %c3 : memref<?x?xf32>
313-
%c0 = arith.constant 0 : index
314-
affine.for %arg3 = %c0 to #map()[%dim] step 32 {
309+
module {
310+
func.func @gpu_launch_affine() {
311+
%c1 = arith.constant 1 : index
312+
gpu.launch blocks(%arg0, %arg1, %arg2) in (%arg6 = %c1, %arg7 = %c1, %arg8 = %c1)
313+
threads(%arg3, %arg4, %arg5) in (%arg9 = %c1, %arg10 = %c1, %arg11 = %c1) {
314+
%thread_id_x = gpu.thread_id x
315+
%c128 = arith.constant 128 : index
316+
affine.for %arg12 = %thread_id_x to %c128 step 8 {
315317
}
316-
gpu.return
318+
gpu.terminator
317319
}
320+
return
318321
}
319322
}
320-
// CHECK-SAME: (%[[VAL_0:.*]]: memref<?x?xf32>) kernel {
321-
// CHECK: %[[VAL_1:.*]] = arith.constant 1 : index
322-
// CHECK: %[[VAL_2:.*]] = memref.dim %[[VAL_0]], %[[VAL_1]] : memref<?x?xf32>
323-
// CHECK: %[[VAL_3:.*]] = arith.constant 0 : index
324-
// CHECK: affine.for %[[VAL_4:.*]] = %[[VAL_3]] to %[[VAL_2]] step 32 {
325-
// CHECK: }
326-
// CHECK: gpu.return
323+
324+
// CHECK: %[[THREAD_ID:.*]] = gpu.thread_id x
325+
// CHECK: %[[VAL:.*]] = arith.constant 128 : index
326+
// CHECK: affine.for %{{.*}} = %[[THREAD_ID]] to %[[VAL]] step 8 {
327327

328328
// -----
329329

mlir/test/Dialect/GPU/transform-gpu.mlir

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ module attributes {transform.with_named_sequence} {
4343
!type = memref<2 x 32 x f32>
4444
!type1d = memref<32 x f32>
4545

46-
// CHECK-DAG: #[[$MAP:.*]] = affine_map<()[s0] -> (s0 floordiv 128)>
46+
// CHECK-DAG: #[[$MAP:.*]] = affine_map<()[s0] -> (s0 floordiv 128)>
4747

4848
// CHECK-LABEL: func.func @warpgroup_3d(
4949
// CHECK-SAME: %[[ARGX:[0-9a-z]+]]: memref<2x32xf32>
@@ -647,7 +647,7 @@ module attributes {transform.with_named_sequence} {
647647
#map = affine_map<(d0) -> (d0 * 128)>
648648
#map1 = affine_map<(d0) -> (d0 * 32)>
649649

650-
// CHECK-DAG: #[[$MAPB:.*]] = affine_map<()[s0] -> (s0 * 128)>
650+
// CHECK-DAG: #[[$MAPB:.*]] = affine_map<()[s0] -> (s0 * 128)>
651651
// CHECK-DAG: #[[$MAPW:.*]] = affine_map<()[s0, s1, s2] -> (s2 * 32 + ((s0 + s1 * 4) floordiv 32) * 32)>
652652

653653
// CHECK-LABEL: func.func @simple_fill(

0 commit comments

Comments
 (0)