Skip to content

Commit fb18202

Browse files
committed
[AMDGPU] Fix ROCm unit test memref initialization
1 parent e09107a commit fb18202

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

mlir/test/mlir-rocm-runner/vecadd.mlir

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,20 @@ func @vecadd(%arg0 : memref<?xf32>, %arg1 : memref<?xf32>, %arg2 : memref<?xf32>
1717

1818
// CHECK: [2.46, 2.46, 2.46, 2.46, 2.46]
1919
func @main() {
20+
%c0 = constant 0 : index
21+
%c1 = constant 1 : index
22+
%c5 = constant 5 : index
23+
%cf1dot23 = constant 1.23 : f32
2024
%0 = alloc() : memref<5xf32>
2125
%1 = alloc() : memref<5xf32>
2226
%2 = alloc() : memref<5xf32>
2327
%3 = memref_cast %0 : memref<5xf32> to memref<?xf32>
2428
%4 = memref_cast %1 : memref<5xf32> to memref<?xf32>
2529
%5 = memref_cast %2 : memref<5xf32> to memref<?xf32>
30+
scf.for %i = %c0 to %c5 step %c1 {
31+
store %cf1dot23, %3[%i] : memref<?xf32>
32+
store %cf1dot23, %4[%i] : memref<?xf32>
33+
}
2634
%6 = memref_cast %3 : memref<?xf32> to memref<*xf32>
2735
%7 = memref_cast %4 : memref<?xf32> to memref<*xf32>
2836
%8 = memref_cast %5 : memref<?xf32> to memref<*xf32>

mlir/test/mlir-rocm-runner/vector-transferops.mlir

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,23 @@ func @vectransferx4(%arg0 : memref<?xf32>, %arg1 : memref<?xf32>) {
4444
}
4545

4646
func @main() {
47+
%c0 = constant 0 : index
48+
%c1 = constant 1 : index
49+
%c4 = constant 4 : index
4750
%cf1 = constant 1.0 : f32
51+
%cf1dot23 = constant 1.23 : f32
4852

4953
%arg0 = alloc() : memref<4xf32>
5054
%arg1 = alloc() : memref<4xf32>
5155

5256
%22 = memref_cast %arg0 : memref<4xf32> to memref<?xf32>
5357
%23 = memref_cast %arg1 : memref<4xf32> to memref<?xf32>
5458

59+
scf.for %i = %c0 to %c4 step %c1 {
60+
store %cf1dot23, %22[%i] : memref<?xf32>
61+
store %cf1dot23, %23[%i] : memref<?xf32>
62+
}
63+
5564
%cast0 = memref_cast %22 : memref<?xf32> to memref<*xf32>
5665
%cast1 = memref_cast %23 : memref<?xf32> to memref<*xf32>
5766

mlir/tools/mlir-rocm-runner/mlir-rocm-runner.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
#include "mlir/Conversion/GPUCommon/GPUCommonPass.h"
1818
#include "mlir/Conversion/GPUToROCDL/GPUToROCDLPass.h"
19+
#include "mlir/Conversion/SCFToStandard/SCFToStandard.h"
1920
#include "mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h"
2021
#include "mlir/Conversion/StandardToLLVM/ConvertStandardToLLVMPass.h"
2122
#include "mlir/Dialect/GPU/GPUDialect.h"
@@ -302,6 +303,7 @@ static LogicalResult runMLIRPasses(ModuleOp m) {
302303
configTargetFeatures();
303304

304305
const char gpuBinaryAnnotation[] = "rocdl.hsaco";
306+
pm.addPass(createLowerToCFGPass());
305307
pm.addPass(createGpuKernelOutliningPass());
306308
auto &kernelPm = pm.nest<gpu::GPUModuleOp>();
307309
kernelPm.addPass(createStripDebugInfoPass());

0 commit comments

Comments
 (0)