Summary: Use a nested symbol to identify the kernel to be invoked by a `LaunchFuncOp` in the GPU dialect. This replaces the two attributes that were used to identify the kernel module and the kernel within seperately. Differential Revision: https://reviews.llvm.org/D78551
33 lines
1.5 KiB
MLIR
33 lines
1.5 KiB
MLIR
// RUN: mlir-opt %s -convert-gpu-launch-to-vulkan-launch | FileCheck %s
|
|
|
|
// CHECK: %[[resource:.*]] = alloc() : memref<12xf32>
|
|
// CHECK: %[[index:.*]] = constant 1 : index
|
|
// CHECK: call @vulkanLaunch(%[[index]], %[[index]], %[[index]], %[[resource]]) {spirv_blob = "{{.*}}", spirv_entry_point = "kernel"}
|
|
|
|
module attributes {gpu.container_module} {
|
|
spv.module Logical GLSL450 requires #spv.vce<v1.0, [Shader], [SPV_KHR_storage_buffer_storage_class]> {
|
|
spv.globalVariable @kernel_arg_0 bind(0, 0) : !spv.ptr<!spv.struct<!spv.array<12 x f32, stride=4> [0]>, StorageBuffer>
|
|
spv.func @kernel() "None" attributes {workgroup_attributions = 0 : i64} {
|
|
%0 = spv._address_of @kernel_arg_0 : !spv.ptr<!spv.struct<!spv.array<12 x f32, stride=4> [0]>, StorageBuffer>
|
|
%2 = spv.constant 0 : i32
|
|
%3 = spv._address_of @kernel_arg_0 : !spv.ptr<!spv.struct<!spv.array<12 x f32, stride=4> [0]>, StorageBuffer>
|
|
%4 = spv.AccessChain %0[%2, %2] : !spv.ptr<!spv.struct<!spv.array<12 x f32, stride=4> [0]>, StorageBuffer>
|
|
%5 = spv.Load "StorageBuffer" %4 : f32
|
|
spv.Return
|
|
}
|
|
spv.EntryPoint "GLCompute" @kernel
|
|
spv.ExecutionMode @kernel "LocalSize", 1, 1, 1
|
|
}
|
|
gpu.module @kernels {
|
|
gpu.func @kernel(%arg0: memref<12xf32>) kernel {
|
|
gpu.return
|
|
}
|
|
}
|
|
func @foo() {
|
|
%0 = alloc() : memref<12xf32>
|
|
%c1 = constant 1 : index
|
|
"gpu.launch_func"(%c1, %c1, %c1, %c1, %c1, %c1, %0) {kernel = @kernels::@kernel} : (index, index, index, index, index, index, memref<12xf32>) -> ()
|
|
return
|
|
}
|
|
}
|