Skip to content

Commit e7a41e8

Browse files
committed
Add e2e test for vector.interleave
1 parent de32786 commit e7a41e8

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// RUN: mlir-vulkan-runner %s \
2+
// RUN: --shared-libs=%vulkan-runtime-wrappers,%mlir_runner_utils \
3+
// RUN: --entry-point-result=void | FileCheck %s
4+
5+
// CHECK: [0, 2, 1, 3]
6+
module attributes {
7+
gpu.container_module,
8+
spirv.target_env = #spirv.target_env<
9+
#spirv.vce<v1.0, [Shader], [SPV_KHR_storage_buffer_storage_class]>, #spirv.resource_limits<>>
10+
} {
11+
gpu.module @kernels {
12+
gpu.func @kernel_vector_interleave(%arg0 : vector<2xi32>, %arg1 : vector<2xi32>, %arg2 : memref<4xi32>)
13+
kernel attributes { spirv.entry_point_abi = #spirv.entry_point_abi<workgroup_size = [1, 1, 1]>} {
14+
%c0 = arith.constant 0 : index
15+
%result = vector.interleave %arg0, %arg1 : vector<2xi32>
16+
vector.store %result, %arg2[%c0] : memref<4xi32>, vector<4xi32>
17+
gpu.return
18+
}
19+
}
20+
21+
func.func @main() {
22+
// Allocate 3 buffers.
23+
%buf0 = arith.constant dense<[0, 1]> : vector<2xi32>
24+
%buf1 = arith.constant dense<[2, 3]> : vector<2xi32>
25+
%buf2 = memref.alloc() : memref<4xi32>
26+
27+
%idx0 = arith.constant 0 : index
28+
%idx1 = arith.constant 1 : index
29+
%idx4 = arith.constant 4 : index
30+
31+
// Initialize output buffer.
32+
%value0 = arith.constant 0 : i32
33+
%buf3 = memref.cast %buf2 : memref<4xi32> to memref<?xi32>
34+
call @fillResource1DInt(%buf3, %value0) : (memref<?xi32>, i32) -> ()
35+
36+
gpu.launch_func @kernels::@kernel_vector_interleave
37+
blocks in (%idx4, %idx1, %idx1) threads in (%idx1, %idx1, %idx1)
38+
args(%buf0 : vector<2xi32>, %buf1 : vector<2xi32>, %buf2 : memref<4xi32>)
39+
%buf4 = memref.cast %buf3 : memref<?xi32> to memref<*xi32>
40+
call @printMemrefI32(%buf4) : (memref<*xi32>) -> ()
41+
return
42+
}
43+
func.func private @fillResource1DInt(%0 : memref<?xi32>, %1 : i32)
44+
func.func private @printMemrefI32(%ptr : memref<*xi32>)
45+
}

0 commit comments

Comments
 (0)