|
| 1 | +// RUN: triton-opt %s -split-input-file --intel-allocate-shared-memory | FileCheck %s |
| 2 | + |
| 3 | +#blocked = #ttg.blocked<{sizePerThread = [1, 16], threadsPerWarp = [16, 1], warpsPerCTA = [1, 1], order = [0, 1]}> |
| 4 | +#blocked1 = #ttg.blocked<{sizePerThread = [16, 1], threadsPerWarp = [1, 16], warpsPerCTA = [1, 1], order = [0, 1]}> |
| 5 | + |
| 6 | +// Check no scratch memory is allocated for sub-group shuffle-like layout conversions. |
| 7 | + |
| 8 | +// CHECK-LABEL: module attributes |
| 9 | +// CHECK-SAME: ttg.shared = 0 : i32 |
| 10 | +module attributes {"ttg.num-ctas" = 1 : i32, "ttg.num-warps" = 1 : i32, "ttg.threads-per-warp" = 16 : i32} { |
| 11 | + // CHECK: tt.func @test_sub_group_shuffle |
| 12 | + // CHECK-NOT: llvm.ptr<3> |
| 13 | + tt.func @test_sub_group_shuffle(%arg0: tensor<16xf16, #ttg.slice<{dim = 1, parent = #blocked}>>) -> tensor<16xf16, #ttg.slice<{dim = 1, parent = #blocked1}>> { |
| 14 | + %0 = ttg.convert_layout %arg0 : tensor<16xf16, #ttg.slice<{dim = 1, parent = #blocked}>> -> tensor<16xf16, #ttg.slice<{dim = 1, parent = #blocked1}>> |
| 15 | + tt.return %0 : tensor<16xf16, #ttg.slice<{dim = 1, parent = #blocked1}>> |
| 16 | + } |
| 17 | +} |
| 18 | + |
| 19 | +// ----- |
| 20 | + |
| 21 | +#blocked = #ttg.blocked<{sizePerThread = [2, 1], threadsPerWarp = [16, 1], warpsPerCTA = [1, 1], order = [0, 1]}> |
| 22 | +#blocked1 = #ttg.blocked<{sizePerThread = [32, 1], threadsPerWarp = [1, 16], warpsPerCTA = [1, 1], order = [0, 1]}> |
| 23 | + |
| 24 | +// Check no scratch memory is allocated for sub-group shuffle-like layout conversions. |
| 25 | + |
| 26 | +// CHECK-LABEL: module attributes |
| 27 | +// CHECK-SAME: ttg.shared = 0 : i32 |
| 28 | +module attributes {"ttg.num-ctas" = 1 : i32, "ttg.num-warps" = 1 : i32, "ttg.threads-per-warp" = 16 : i32} { |
| 29 | + // CHECK: tt.func @test_sub_group_shuffle |
| 30 | + // CHECK-NOT: llvm.ptr<3> |
| 31 | + tt.func @test_sub_group_shuffle(%arg0: tensor<32xf16, #ttg.slice<{dim = 1, parent = #blocked}>>) -> tensor<32xf16, #ttg.slice<{dim = 1, parent = #blocked1}>> { |
| 32 | + %0 = ttg.convert_layout %arg0 : tensor<32xf16, #ttg.slice<{dim = 1, parent = #blocked}>> -> tensor<32xf16, #ttg.slice<{dim = 1, parent = #blocked1}>> |
| 33 | + tt.return %0 : tensor<32xf16, #ttg.slice<{dim = 1, parent = #blocked1}>> |
| 34 | + } |
| 35 | +} |
| 36 | + |
| 37 | +// ----- |
| 38 | + |
| 39 | +#blocked = #ttg.blocked<{sizePerThread = [16, 1], threadsPerWarp = [1, 16], warpsPerCTA = [1, 1], order = [0, 1]}> |
| 40 | +#blocked1 = #ttg.blocked<{sizePerThread = [1, 16], threadsPerWarp = [16, 1], warpsPerCTA = [1, 1], order = [0, 1]}> |
| 41 | + |
| 42 | +// Check scracth memory configuration for different sub-group transpose-like layout conversions. |
| 43 | + |
| 44 | +// CHECK-LABEL: module attributes |
| 45 | +// CHECK-SAME: ttg.shared = 544 : i32 |
| 46 | +module attributes {"ttg.num-ctas" = 1 : i32, "ttg.num-warps" = 1 : i32, "ttg.threads-per-warp" = 16 : i32} { |
| 47 | + tt.func @test_f16(%arg0: tensor<16x16xf16, #blocked>) -> tensor<16x16xf16, #blocked1> { |
| 48 | + %0 = ttg.convert_layout %arg0 : tensor<16x16xf16, #blocked> -> tensor<16x16xf16, #blocked1> |
| 49 | + tt.return %0 : tensor<16x16xf16, #blocked1> |
| 50 | + } |
| 51 | +} |
| 52 | + |
| 53 | +// ----- |
| 54 | + |
| 55 | +#blocked = #ttg.blocked<{sizePerThread = [16, 1], threadsPerWarp = [1, 16], warpsPerCTA = [1, 1], order = [0, 1]}> |
| 56 | +#blocked1 = #ttg.blocked<{sizePerThread = [1, 16], threadsPerWarp = [16, 1], warpsPerCTA = [1, 1], order = [0, 1]}> |
| 57 | + |
| 58 | +// Check scracth memory configuration for different sub-group transpose-like layout conversions. |
| 59 | + |
| 60 | +// CHECK-LABEL: module attributes |
| 61 | +// CHECK-SAME: ttg.shared = 1088 : i32 |
| 62 | +module attributes {"ttg.num-ctas" = 1 : i32, "ttg.num-warps" = 1 : i32, "ttg.threads-per-warp" = 16 : i32} { |
| 63 | + tt.func @test_f32(%arg0: tensor<16x16xf32, #blocked>) -> tensor<16x16xf32, #blocked1> { |
| 64 | + %0 = ttg.convert_layout %arg0 : tensor<16x16xf32, #blocked> -> tensor<16x16xf32, #blocked1> |
| 65 | + tt.return %0 : tensor<16x16xf32, #blocked1> |
| 66 | + } |
| 67 | +} |
| 68 | + |
| 69 | +// ----- |
| 70 | + |
| 71 | +#blocked = #ttg.blocked<{sizePerThread = [16, 1], threadsPerWarp = [1, 16], warpsPerCTA = [4, 2], order = [0, 1]}> |
| 72 | +#blocked1 = #ttg.blocked<{sizePerThread = [1, 16], threadsPerWarp = [16, 1], warpsPerCTA = [4, 2], order = [0, 1]}> |
| 73 | + |
| 74 | +// Check scracth memory configuration for different sub-group transpose-like layout conversions. |
| 75 | + |
| 76 | +// CHECK-LABEL: module attributes |
| 77 | +// CHECK-SAME: ttg.shared = 34816 : i32 |
| 78 | +module attributes {"ttg.num-ctas" = 1 : i32, "ttg.num-warps" = 8 : i32, "ttg.threads-per-warp" = 16 : i32} { |
| 79 | + tt.func @test_f32(%arg0: tensor<128x64xf32, #blocked>) -> tensor<128x64xf32, #blocked1> { |
| 80 | + %0 = ttg.convert_layout %arg0 : tensor<128x64xf32, #blocked> -> tensor<128x64xf32, #blocked1> |
| 81 | + tt.return %0 : tensor<128x64xf32, #blocked1> |
| 82 | + } |
| 83 | +} |
| 84 | + |
| 85 | +// ----- |
| 86 | + |
| 87 | +#blocked = #ttg.blocked<{sizePerThread = [1, 32], threadsPerWarp = [16, 1], warpsPerCTA = [2, 4], order = [0, 1]}> |
| 88 | +#blocked1 = #ttg.blocked<{sizePerThread = [16, 2], threadsPerWarp = [1, 16], warpsPerCTA = [2, 4], order = [0, 1]}> |
| 89 | + |
| 90 | +// Check scracth memory configuration for different sub-group transpose-like layout conversions. |
| 91 | + |
| 92 | +// CHECK-LABEL: module attributes |
| 93 | +// CHECK-SAME: ttg.shared = 17408 : i32 |
| 94 | +module attributes {"ttg.num-ctas" = 1 : i32, "ttg.num-warps" = 8 : i32, "ttg.threads-per-warp" = 16 : i32} { |
| 95 | + tt.func @test_contiguous(%arg0: tensor<32x128xf32, #blocked>) -> tensor<32x128xf32, #blocked1> { |
| 96 | + %0 = ttg.convert_layout %arg0 : tensor<32x128xf32, #blocked> -> tensor<32x128xf32, #blocked1> |
| 97 | + tt.return %0 : tensor<32x128xf32, #blocked1> |
| 98 | + } |
| 99 | +} |
0 commit comments