[Mlir-commits] [mlir] [mlir][spirv] Do SPIR-V serialization in -test-vulkan-runner-pipeline (PR #121494)
Andrea Faulds
llvmlistbot at llvm.org
Thu Jan 2 10:18:28 PST 2025
================
@@ -12,33 +12,57 @@
#include "mlir/Conversion/ConvertToSPIRV/ConvertToSPIRVPass.h"
#include "mlir/Conversion/GPUToSPIRV/GPUToSPIRVPass.h"
+#include "mlir/Dialect/GPU/IR/GPUDialect.h"
#include "mlir/Dialect/GPU/Transforms/Passes.h"
#include "mlir/Dialect/MemRef/Transforms/Passes.h"
#include "mlir/Dialect/SPIRV/IR/SPIRVOps.h"
#include "mlir/Dialect/SPIRV/Transforms/Passes.h"
#include "mlir/Pass/PassManager.h"
+#include "mlir/Pass/PassOptions.h"
using namespace mlir;
namespace {
-void buildTestVulkanRunnerPipeline(OpPassManager &passManager) {
+struct VulkanRunnerPipelineOptions
+ : public PassPipelineOptions<VulkanRunnerPipelineOptions> {
+ Option<bool> spirvWebGPUPrepare{
+ *this, "spirv-webgpu-prepare",
+ llvm::cl::desc("Run MLIR transforms used when targetting WebGPU")};
+};
+
+void buildTestVulkanRunnerPipeline(OpPassManager &passManager,
+ const VulkanRunnerPipelineOptions &options) {
passManager.addPass(createGpuKernelOutliningPass());
passManager.addPass(memref::createFoldMemRefAliasOpsPass());
+ GpuSPIRVAttachTargetOptions attachTargetOptions{};
+ attachTargetOptions.spirvVersion = "v1.0";
+ attachTargetOptions.spirvCapabilities.push_back("Shader");
+ attachTargetOptions.spirvExtensions.push_back(
+ "SPV_KHR_storage_buffer_storage_class");
+ passManager.addPass(createGpuSPIRVAttachTarget(attachTargetOptions));
+
ConvertToSPIRVPassOptions convertToSPIRVOptions{};
convertToSPIRVOptions.convertGPUModules = true;
+ convertToSPIRVOptions.nestInGPUModule = true;
passManager.addPass(createConvertToSPIRVPass(convertToSPIRVOptions));
- OpPassManager &modulePM = passManager.nest<spirv::ModuleOp>();
- modulePM.addPass(spirv::createSPIRVLowerABIAttributesPass());
- modulePM.addPass(spirv::createSPIRVUpdateVCEPass());
+
+ OpPassManager &gpuModulePM = passManager.nest<gpu::GPUModuleOp>();
+ OpPassManager &spirvModulePM = gpuModulePM.nest<spirv::ModuleOp>();
----------------
andfau-amd wrote:
I was scared that might be a use-after-free of a temporary, but actually the reference here is produced by the `nest()` function itself, very convenient. So, yes we can. :)
https://github.com/llvm/llvm-project/pull/121494
More information about the Mlir-commits
mailing list