|
| 1 | +// RUN: not mlir-opt %s --split-input-file -convert-amdgpu-to-rocdl=chipset=gfx942 2>&1 | FileCheck %s --check-prefix=GFX942 |
| 2 | +// RUN: mlir-opt %s --split-input-file -convert-amdgpu-to-rocdl=chipset=gfx950 | FileCheck %s --check-prefix=GFX950 |
| 3 | + |
| 4 | +#gpu_global_addrspace = 1 |
| 5 | +#gpu_lds_addrspace = 3 |
| 6 | +#amdgpu_fat_buffer_addrspace = 7 |
| 7 | + |
| 8 | +// GFX950-LABEL: func @fat_buffer_load_to_rocdl_f96 |
| 9 | +// GFX950-SAME: (%[[ARG0:.*]]: memref<128x72xf32, 7>) |
| 10 | +func.func @fat_buffer_load_to_rocdl_f96(%global : memref<128x72xf32, #amdgpu_fat_buffer_addrspace>) { |
| 11 | + %c0 = arith.constant 0 : index |
| 12 | + %c12 = arith.constant 12 : index |
| 13 | + %c32 = arith.constant 32 : index |
| 14 | + %alloc = memref.alloc() : memref<64x64xf32, #gpu_lds_addrspace> |
| 15 | + // GFX950: %[[BUFFER_DESC:.*]] = builtin.unrealized_conversion_cast %[[ARG0]] |
| 16 | + |
| 17 | + // GFX950: %[[C0:.*]] = arith.constant 0 : index |
| 18 | + // GFX950: %[[IC0:.*]] = builtin.unrealized_conversion_cast %c0 : index to i64 |
| 19 | + // GFX950: %[[C12:.*]] = arith.constant 12 : index |
| 20 | + // GFX950: %[[IC12:.*]] = builtin.unrealized_conversion_cast %[[C12]] |
| 21 | + // GFX950: %[[C32:.*]] = arith.constant 32 : index |
| 22 | + // GFX950: %[[IC32:.*]] = builtin.unrealized_conversion_cast %[[C32]] |
| 23 | + |
| 24 | + // GFX950: %[[ALLOC:.*]] = memref.alloc() |
| 25 | + // GFX950: %[[LDS_DESC:.*]] = builtin.unrealized_conversion_cast |
| 26 | + // GFX950: %[[GLOBAL_BASE:.*]] = llvm.extractvalue %[[BUFFER_DESC]][1] |
| 27 | + |
| 28 | + // GFX950: %[[C72:.*]] = llvm.mlir.constant(72 : index) : i64 |
| 29 | + // GFX950: %[[MUL:.*]] = llvm.mul %[[IC12]], %[[C72]] : i64 |
| 30 | + // GFX950: %[[SRC_OFFSET:.*]] = llvm.add %[[MUL]], %[[IC0]] : i64 |
| 31 | + |
| 32 | + // GFX950: %[[GLOBAL_PTR:.*]] = llvm.getelementptr %[[GLOBAL_BASE]][%[[SRC_OFFSET]]] |
| 33 | + // GFX950: %[[LDS_BASE:.*]] = llvm.extractvalue %[[LDS_DESC]][1] |
| 34 | + |
| 35 | + // GFX950: %[[C64:.*]] = llvm.mlir.constant(64 : index) : i64 |
| 36 | + // GFX950: %[[MUL_2:.*]] = llvm.mul %[[IC32]], %[[C64]] : i64 |
| 37 | + // GFX950: %[[DST_OFFSET:.*]] = llvm.add %[[MUL_2]], %[[IC0]] : i64 |
| 38 | + |
| 39 | + // GFX950: %[[LDS_PTR:.*]] = llvm.getelementptr %[[LDS_BASE]][%[[DST_OFFSET]]] |
| 40 | + // GFX950: rocdl.load.to.lds %[[GLOBAL_PTR]], %[[LDS_PTR]], 12 |
| 41 | + // GFX942: error: 'amdgpu.gather_to_lds' op Gather to LDS instructions with 12-byte and 16-byte load widths are only supported on gfx950 |
| 42 | + amdgpu.gather_to_lds %global[%c12, %c0], %alloc[%c32, %c0] |
| 43 | + : vector<16xf6E3M2FN>, memref<128x72xf32, #amdgpu_fat_buffer_addrspace>, memref<64x64xf32, #gpu_lds_addrspace> |
| 44 | + func.return |
| 45 | +} |
| 46 | + |
| 47 | +// ----- |
| 48 | + |
| 49 | +#gpu_global_addrspace = 1 |
| 50 | +#gpu_lds_addrspace = 3 |
| 51 | +#amdgpu_fat_buffer_addrspace = 7 |
| 52 | + |
| 53 | +// GFX950-LABEL: func @fat_buffer_load_to_rocdl_f128 |
| 54 | +// GFX950-SAME: (%[[ARG0:.*]]: memref<128x72xf32, 7>) |
| 55 | +func.func @fat_buffer_load_to_rocdl_f128(%global : memref<128x72xf32, #amdgpu_fat_buffer_addrspace>) { |
| 56 | + %c0 = arith.constant 0 : index |
| 57 | + %c12 = arith.constant 12 : index |
| 58 | + %c32 = arith.constant 32 : index |
| 59 | + %alloc = memref.alloc() : memref<64x64xf32, #gpu_lds_addrspace> |
| 60 | + // GFX950: %[[BUFFER_DESC:.*]] = builtin.unrealized_conversion_cast %[[ARG0]] |
| 61 | + |
| 62 | + // GFX950: %[[C0:.*]] = arith.constant 0 : index |
| 63 | + // GFX950: %[[IC0:.*]] = builtin.unrealized_conversion_cast %c0 : index to i64 |
| 64 | + // GFX950: %[[C12:.*]] = arith.constant 12 : index |
| 65 | + // GFX950: %[[IC12:.*]] = builtin.unrealized_conversion_cast %[[C12]] |
| 66 | + // GFX950: %[[C32:.*]] = arith.constant 32 : index |
| 67 | + // GFX950: %[[IC32:.*]] = builtin.unrealized_conversion_cast %[[C32]] |
| 68 | + |
| 69 | + // GFX950: %[[ALLOC:.*]] = memref.alloc() |
| 70 | + // GFX950: %[[LDS_DESC:.*]] = builtin.unrealized_conversion_cast |
| 71 | + // GFX950: %[[GLOBAL_BASE:.*]] = llvm.extractvalue %[[BUFFER_DESC]][1] |
| 72 | + |
| 73 | + // GFX950: %[[C72:.*]] = llvm.mlir.constant(72 : index) : i64 |
| 74 | + // GFX950: %[[MUL:.*]] = llvm.mul %[[IC12]], %[[C72]] : i64 |
| 75 | + // GFX950: %[[SRC_OFFSET:.*]] = llvm.add %[[MUL]], %[[IC0]] : i64 |
| 76 | + |
| 77 | + // GFX950: %[[GLOBAL_PTR:.*]] = llvm.getelementptr %[[GLOBAL_BASE]][%[[SRC_OFFSET]]] |
| 78 | + // GFX950: %[[LDS_BASE:.*]] = llvm.extractvalue %[[LDS_DESC]][1] |
| 79 | + |
| 80 | + // GFX950: %[[C64:.*]] = llvm.mlir.constant(64 : index) : i64 |
| 81 | + // GFX950: %[[MUL_2:.*]] = llvm.mul %[[IC32]], %[[C64]] : i64 |
| 82 | + // GFX950: %[[DST_OFFSET:.*]] = llvm.add %[[MUL_2]], %[[IC0]] : i64 |
| 83 | + |
| 84 | + // GFX950: %[[LDS_PTR:.*]] = llvm.getelementptr %[[LDS_BASE]][%[[DST_OFFSET]]] |
| 85 | + // GFX950: rocdl.load.to.lds %[[GLOBAL_PTR]], %[[LDS_PTR]], 16 |
| 86 | + // GFX942: error: 'amdgpu.gather_to_lds' op Gather to LDS instructions with 12-byte and 16-byte load widths are only supported on gfx950 |
| 87 | + amdgpu.gather_to_lds %global[%c12, %c0], %alloc[%c32, %c0] |
| 88 | + : f128, memref<128x72xf32, #amdgpu_fat_buffer_addrspace>, memref<64x64xf32, #gpu_lds_addrspace> |
| 89 | + func.return |
| 90 | +} |
0 commit comments