Skip to content

Commit 815b2a4

Browse files
[AMD] Use more detailed convert_layout.mlir test (#7554)
Add more detailed checks in general swizzling part of convert_layout test; Replace canonicalize with cse, it should be more robust, all this test needs is to merge constants for easier pattern matching. Co-authored-by: Alexander Efimov <[email protected]>
1 parent e090c31 commit 815b2a4

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

test/Conversion/amd/convert_layout.mlir

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,25 @@
1-
// RUN: triton-opt %s -split-input-file --allocate-shared-memory --convert-triton-amdgpu-to-llvm=arch=gfx942 --canonicalize| FileCheck %s
1+
// RUN: triton-opt %s -split-input-file --allocate-shared-memory --convert-triton-amdgpu-to-llvm=arch=gfx942 --cse| FileCheck %s
22

33
#blocked0 = #ttg.blocked<{sizePerThread = [1, 4], threadsPerWarp = [16, 4], warpsPerCTA = [2, 2], order = [1, 0], CTAsPerCGA = [1, 1], CTASplitNum = [1, 1], CTAOrder = [1, 0]}>
44
#blocked1 = #ttg.blocked<{sizePerThread = [4, 1], threadsPerWarp = [4, 16], warpsPerCTA = [2, 2], order = [0, 1], CTAsPerCGA = [1, 1], CTASplitNum = [1, 1], CTAOrder = [1, 0]}>
55
module attributes {"ttg.num-ctas" = 1 : i32, "ttg.num-warps" = 4 : i32, ttg.target = "hip:gfx942", "ttg.threads-per-warp" = 64 : i32} {
66
// CHECK: llvm.mlir.global external @global_smem
77
tt.func @convert_layout_general_swizzling(%arg0: tensor<64x64xf32, #blocked0>, %arg1: tensor<64x64x!tt.ptr<f32>, #blocked1>) {
88

9-
// verify that following convert layout uses general swizzling
9+
// verify that following convert layout uses general swizzling path
1010

11-
// CHECK-NOT: llvm.lshr
11+
// CHECK: [[CST_128:%.*]] = llvm.mlir.constant(128 : i32) : i32
12+
13+
// Part of offset computation generated by applyLinearLayout function
14+
// CHECK: [[SEL:%.*]]= llvm.select {{.*}}, {{.*}}, [[CST_128]]
15+
// CHECK: [[OFFSET_0:%.*]] = llvm.xor {{.*}}, [[SEL]]
16+
// CHECK: [[OFFSET_1:%.*]] = llvm.xor {{.*}}, [[OFFSET_0]] : i32
17+
18+
// Part of offset computation generated by lowerLdSt function after applyLinearLayout
19+
// CHECK: [[OFFSET_2:%.*]] = llvm.xor [[OFFSET_1]], {{.*}} : i32
20+
// CHECK: [[OFFSET_3:%.*]] = llvm.xor [[OFFSET_2]], {{.*}} : i32
21+
// CHECK: [[OFFSET_4:%.*]] = llvm.add [[OFFSET_3]], {{.*}} : i32
22+
// CHECK: llvm.getelementptr inbounds {{.*}}{{\[}}[[OFFSET_4]]{{\]}}
1223

1324
%0 = ttg.convert_layout %arg0 : tensor<64x64xf32, #blocked0> -> tensor<64x64xf32, #blocked1>
1425
tt.store %arg1, %0 : tensor<64x64x!tt.ptr<f32>, #blocked1>

0 commit comments

Comments
 (0)