A memref argument is converted into a pointer-to-struct argument
of type {T*, T*, i64, i64[N], i64[N]}* in the wrapper function,
where T is the converted element type and N is the memref rank.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
This patch eliminates VulkanLaunchOpOperandAdaptor and enables emitCWrappers while lowering to LLVM dialect. By doing this we follow the official guideline for calling convention https://mlir.llvm.org/docs/ConversionToLLVMDialect/#calling-convention.
emitCWrappers enables the following steps:
- Declares a new function _mlir_ciface_vulkanLaunch where memref arguments are converted to pointer-to-struct and the remaining arguments are converted as usual.
- Adds a body to the original function (making it non-external) that
- allocates a memref descriptor,
- populates it, and
- passes the pointer to it into the newly declared interface function
- collects the result of the call and returns it to the caller.
mlir/lib/Conversion/GPUToVulkan/ConvertLaunchFuncToVulkanCalls.cpp | ||
---|---|---|
208 | nit: You shouldn't need to construct a vector here, just use the operand_range directly. You can then change the llvm::drop_begin to operands.drop_front(...). | |
210 | Why not use llvm::enumerate here? That would remove the need for the extra index variable. |
Awesome! Thanks for the fix, Denis! Sorry for the delay. Overall LGTM; just a few nits. :)
mlir/lib/Conversion/GPUToVulkan/ConvertLaunchFuncToVulkanCalls.cpp | ||
---|---|---|
120 | Nit: isCInterfaceVulkanLaunchCallOp? Just spell it out to make it clear. Applies to other parameter names, etc. | |
151 | I think we can use gpu::LaunchOp::kNumConfigOperands instead of having our own here. | |
158 | Nit: SPIR-V |
@denis13 FYI if you haven't already, you really can ask for commit access: https://llvm.org/docs/DeveloperPolicy.html#obtaining-commit-access
Nit: isCInterfaceVulkanLaunchCallOp? Just spell it out to make it clear. Applies to other parameter names, etc.