[Mlir-commits] [mlir] [mlir] Remove mlir-vulkan-runner and GPUToVulkan conversion passes (PR #123750)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Tue Jan 21 05:55:57 PST 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-mlir-execution-engine

Author: Andrea Faulds (andfau-amd)

<details>
<summary>Changes</summary>

This follows up on 733be4ed7dcf976719f424c0cb81b77a14f91f5a, which made mlir-vulkan-runner and its associated passes redundant, and completes the main goal of #<!-- -->73457. The mlir-vulkan-runner tests become part of the integration test suite, and the Vulkan runner runtime components become part of ExecutionEngine, just as was done when removing other target-specific runners.

---

Patch is 67.98 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/123750.diff


33 Files Affected:

- (removed) mlir/include/mlir/Conversion/GPUToVulkan/ConvertGPUToVulkanPass.h (-36) 
- (modified) mlir/include/mlir/Conversion/Passes.h (-1) 
- (modified) mlir/include/mlir/Conversion/Passes.td (-25) 
- (modified) mlir/lib/Conversion/CMakeLists.txt (-1) 
- (removed) mlir/lib/Conversion/GPUToVulkan/CMakeLists.txt (-19) 
- (removed) mlir/lib/Conversion/GPUToVulkan/ConvertGPULaunchFuncToVulkanLaunchFunc.cpp (-219) 
- (removed) mlir/lib/Conversion/GPUToVulkan/ConvertLaunchFuncToVulkanCalls.cpp (-448) 
- (modified) mlir/lib/ExecutionEngine/CMakeLists.txt (+45) 
- (renamed) mlir/lib/ExecutionEngine/VulkanRuntime.cpp () 
- (renamed) mlir/lib/ExecutionEngine/VulkanRuntime.h () 
- (renamed) mlir/lib/ExecutionEngine/VulkanRuntimeWrappers.cpp (+4-73) 
- (modified) mlir/test/CMakeLists.txt (+1-1) 
- (removed) mlir/test/Conversion/GPUToVulkan/invoke-vulkan.mlir (-62) 
- (removed) mlir/test/Conversion/GPUToVulkan/lower-gpu-launch-vulkan-launch.mlir (-35) 
- (renamed) mlir/test/Integration/GPU/Vulkan/addf.mlir (+2-2) 
- (renamed) mlir/test/Integration/GPU/Vulkan/addf_if.mlir (+2-2) 
- (renamed) mlir/test/Integration/GPU/Vulkan/addi.mlir (+2-2) 
- (renamed) mlir/test/Integration/GPU/Vulkan/addi8.mlir (+2-2) 
- (renamed) mlir/test/Integration/GPU/Vulkan/addui_extended.mlir (+4-4) 
- (renamed) mlir/test/Integration/GPU/Vulkan/lit.local.cfg () 
- (renamed) mlir/test/Integration/GPU/Vulkan/mulf.mlir (+2-2) 
- (renamed) mlir/test/Integration/GPU/Vulkan/smul_extended.mlir (+4-4) 
- (renamed) mlir/test/Integration/GPU/Vulkan/subf.mlir (+2-2) 
- (renamed) mlir/test/Integration/GPU/Vulkan/time.mlir (+2-2) 
- (renamed) mlir/test/Integration/GPU/Vulkan/umul_extended.mlir (+4-4) 
- (renamed) mlir/test/Integration/GPU/Vulkan/vector-deinterleave.mlir (+2-2) 
- (renamed) mlir/test/Integration/GPU/Vulkan/vector-interleave.mlir (+2-2) 
- (renamed) mlir/test/Integration/GPU/Vulkan/vector-shuffle.mlir (+2-2) 
- (modified) mlir/test/lib/Pass/TestVulkanRunnerPipeline.cpp (+12-17) 
- (modified) mlir/test/lit.cfg.py (+1-1) 
- (modified) mlir/tools/CMakeLists.txt (-1) 
- (removed) mlir/tools/mlir-vulkan-runner/CMakeLists.txt (-99) 
- (removed) mlir/tools/mlir-vulkan-runner/mlir-vulkan-runner.cpp (-88) 


``````````diff
diff --git a/mlir/include/mlir/Conversion/GPUToVulkan/ConvertGPUToVulkanPass.h b/mlir/include/mlir/Conversion/GPUToVulkan/ConvertGPUToVulkanPass.h
deleted file mode 100644
index f69720328f2a42..00000000000000
--- a/mlir/include/mlir/Conversion/GPUToVulkan/ConvertGPUToVulkanPass.h
+++ /dev/null
@@ -1,36 +0,0 @@
-//===- ConvertGPUToVulkanPass.h - GPU to Vulkan conversion pass -*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-//
-// The file declares a pass to convert GPU dialect ops to to Vulkan runtime
-// calls.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef MLIR_CONVERSION_GPUTOVULKAN_CONVERTGPUTOVULKANPASS_H
-#define MLIR_CONVERSION_GPUTOVULKAN_CONVERTGPUTOVULKANPASS_H
-
-#include "mlir/Support/LLVM.h"
-
-#include <memory>
-
-namespace mlir {
-
-class ModuleOp;
-template <typename T>
-class OperationPass;
-class Pass;
-
-#define GEN_PASS_DECL_CONVERTVULKANLAUNCHFUNCTOVULKANCALLSPASS
-#define GEN_PASS_DECL_CONVERTGPULAUNCHFUNCTOVULKANLAUNCHFUNC
-#include "mlir/Conversion/Passes.h.inc"
-
-std::unique_ptr<OperationPass<mlir::ModuleOp>>
-createConvertGpuLaunchFuncToVulkanLaunchFuncPass();
-
-} // namespace mlir
-#endif // MLIR_CONVERSION_GPUTOVULKAN_CONVERTGPUTOVULKANPASS_H
diff --git a/mlir/include/mlir/Conversion/Passes.h b/mlir/include/mlir/Conversion/Passes.h
index 6a564e9bfc5a9b..e9761c20642c0f 100644
--- a/mlir/include/mlir/Conversion/Passes.h
+++ b/mlir/include/mlir/Conversion/Passes.h
@@ -39,7 +39,6 @@
 #include "mlir/Conversion/GPUToNVVM/GPUToNVVMPass.h"
 #include "mlir/Conversion/GPUToROCDL/GPUToROCDLPass.h"
 #include "mlir/Conversion/GPUToSPIRV/GPUToSPIRVPass.h"
-#include "mlir/Conversion/GPUToVulkan/ConvertGPUToVulkanPass.h"
 #include "mlir/Conversion/IndexToLLVM/IndexToLLVM.h"
 #include "mlir/Conversion/IndexToSPIRV/IndexToSPIRV.h"
 #include "mlir/Conversion/LinalgToStandard/LinalgToStandard.h"
diff --git a/mlir/include/mlir/Conversion/Passes.td b/mlir/include/mlir/Conversion/Passes.td
index ac417fff27eb80..f9fa2d4595f999 100644
--- a/mlir/include/mlir/Conversion/Passes.td
+++ b/mlir/include/mlir/Conversion/Passes.td
@@ -654,31 +654,6 @@ def ConvertGPUToSPIRV : Pass<"convert-gpu-to-spirv", "ModuleOp"> {
   ];
 }
 
-//===----------------------------------------------------------------------===//
-// GPUToVulkan
-//===----------------------------------------------------------------------===//
-
-def ConvertGpuLaunchFuncToVulkanLaunchFunc
-    : Pass<"convert-gpu-launch-to-vulkan-launch", "ModuleOp"> {
-  let summary = "Convert gpu.launch_func to vulkanLaunch external call";
-  let description = [{
-    This pass is only intended for the mlir-vulkan-runner.
-  }];
-  let constructor = "mlir::createConvertGpuLaunchFuncToVulkanLaunchFuncPass()";
-  let dependentDialects = ["spirv::SPIRVDialect"];
-}
-
-def ConvertVulkanLaunchFuncToVulkanCallsPass
-    : Pass<"launch-func-to-vulkan", "ModuleOp"> {
-  let summary = "Convert vulkanLaunch external call to Vulkan runtime external "
-                "calls";
-  let description = [{
-    This pass is only intended for the mlir-vulkan-runner.
-  }];
-
-  let dependentDialects = ["LLVM::LLVMDialect"];
-}
-
 //===----------------------------------------------------------------------===//
 // ConvertIndexToLLVMPass
 //===----------------------------------------------------------------------===//
diff --git a/mlir/lib/Conversion/CMakeLists.txt b/mlir/lib/Conversion/CMakeLists.txt
index 791e94e491587c..a570978f03757c 100644
--- a/mlir/lib/Conversion/CMakeLists.txt
+++ b/mlir/lib/Conversion/CMakeLists.txt
@@ -28,7 +28,6 @@ add_subdirectory(GPUToLLVMSPV)
 add_subdirectory(GPUToNVVM)
 add_subdirectory(GPUToROCDL)
 add_subdirectory(GPUToSPIRV)
-add_subdirectory(GPUToVulkan)
 add_subdirectory(IndexToLLVM)
 add_subdirectory(IndexToSPIRV)
 add_subdirectory(LinalgToStandard)
diff --git a/mlir/lib/Conversion/GPUToVulkan/CMakeLists.txt b/mlir/lib/Conversion/GPUToVulkan/CMakeLists.txt
deleted file mode 100644
index faeb32f2bc8cd3..00000000000000
--- a/mlir/lib/Conversion/GPUToVulkan/CMakeLists.txt
+++ /dev/null
@@ -1,19 +0,0 @@
-add_mlir_conversion_library(MLIRGPUToVulkanTransforms
-  ConvertLaunchFuncToVulkanCalls.cpp
-  ConvertGPULaunchFuncToVulkanLaunchFunc.cpp
-
-  DEPENDS
-  MLIRConversionPassIncGen
-
-  LINK_LIBS PUBLIC
-  MLIRFuncDialect
-  MLIRGPUDialect
-  MLIRIR
-  MLIRLLVMDialect
-  MLIRPass
-  MLIRSPIRVDialect
-  MLIRSPIRVSerialization
-  MLIRSupport
-  MLIRTransforms
-  MLIRTranslateLib
-  )
diff --git a/mlir/lib/Conversion/GPUToVulkan/ConvertGPULaunchFuncToVulkanLaunchFunc.cpp b/mlir/lib/Conversion/GPUToVulkan/ConvertGPULaunchFuncToVulkanLaunchFunc.cpp
deleted file mode 100644
index 8488fac69e8e31..00000000000000
--- a/mlir/lib/Conversion/GPUToVulkan/ConvertGPULaunchFuncToVulkanLaunchFunc.cpp
+++ /dev/null
@@ -1,219 +0,0 @@
-//===- ConvertGPULaunchFuncToVulkanLaunchFunc.cpp - MLIR conversion pass --===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-//
-// This file implements a pass to convert gpu launch function into a vulkan
-// launch function. Extracts the SPIR-V from a `gpu::BinaryOp` and attaches it
-// along with the entry point name as attributes to a Vulkan launch call op.
-//
-//===----------------------------------------------------------------------===//
-
-#include "mlir/Conversion/GPUToVulkan/ConvertGPUToVulkanPass.h"
-
-#include "mlir/Dialect/Func/IR/FuncOps.h"
-#include "mlir/Dialect/GPU/IR/GPUDialect.h"
-#include "mlir/Dialect/SPIRV/IR/SPIRVDialect.h"
-#include "mlir/Dialect/SPIRV/IR/SPIRVOps.h"
-#include "mlir/IR/Attributes.h"
-#include "mlir/IR/Builders.h"
-#include "mlir/IR/BuiltinOps.h"
-#include "mlir/IR/BuiltinTypes.h"
-#include "mlir/Pass/Pass.h"
-#include "mlir/Target/SPIRV/Serialization.h"
-
-namespace mlir {
-#define GEN_PASS_DEF_CONVERTGPULAUNCHFUNCTOVULKANLAUNCHFUNC
-#include "mlir/Conversion/Passes.h.inc"
-} // namespace mlir
-
-using namespace mlir;
-
-static constexpr const char *kSPIRVBlobAttrName = "spirv_blob";
-static constexpr const char *kSPIRVEntryPointAttrName = "spirv_entry_point";
-static constexpr const char *kSPIRVElementTypesAttrName = "spirv_element_types";
-static constexpr const char *kVulkanLaunch = "vulkanLaunch";
-
-namespace {
-
-/// A pass to convert gpu launch op to vulkan launch call op, by extracting a
-/// SPIR-V binary shader from a `gpu::BinaryOp` and attaching binary data and
-/// entry point name as an attributes to created vulkan launch call op.
-class ConvertGpuLaunchFuncToVulkanLaunchFunc
-    : public impl::ConvertGpuLaunchFuncToVulkanLaunchFuncBase<
-          ConvertGpuLaunchFuncToVulkanLaunchFunc> {
-public:
-  void runOnOperation() override;
-
-private:
-  /// Extracts a SPIR-V binary shader from the given `module`, if any.
-  /// Note that this also removes the binary from the IR.
-  FailureOr<StringAttr> getBinaryShader(ModuleOp module);
-
-  /// Converts the given `launchOp` to vulkan launch call.
-  void convertGpuLaunchFunc(gpu::LaunchFuncOp launchOp);
-
-  /// Checks where the given type is supported by Vulkan runtime.
-  bool isSupportedType(Type type) {
-    if (auto memRefType = dyn_cast_or_null<MemRefType>(type)) {
-      auto elementType = memRefType.getElementType();
-      return memRefType.hasRank() &&
-             (memRefType.getRank() >= 1 && memRefType.getRank() <= 3) &&
-             (elementType.isIntOrFloat());
-    }
-    return false;
-  }
-
-  /// Declares the vulkan launch function. Returns an error if the any type of
-  /// operand is unsupported by Vulkan runtime.
-  LogicalResult declareVulkanLaunchFunc(Location loc,
-                                        gpu::LaunchFuncOp launchOp);
-
-private:
-  /// The number of vulkan launch configuration operands, placed at the leading
-  /// positions of the operand list.
-  static constexpr unsigned kVulkanLaunchNumConfigOperands = 3;
-};
-
-} // namespace
-
-void ConvertGpuLaunchFuncToVulkanLaunchFunc::runOnOperation() {
-  bool done = false;
-  getOperation().walk([this, &done](gpu::LaunchFuncOp op) {
-    if (done) {
-      op.emitError("should only contain one 'gpu::LaunchFuncOp' op");
-      return signalPassFailure();
-    }
-    done = true;
-    convertGpuLaunchFunc(op);
-  });
-
-  // Erase `gpu::GPUModuleOp` and `spirv::Module` operations.
-  for (auto gpuModule :
-       llvm::make_early_inc_range(getOperation().getOps<gpu::GPUModuleOp>()))
-    gpuModule.erase();
-
-  for (auto spirvModule :
-       llvm::make_early_inc_range(getOperation().getOps<spirv::ModuleOp>()))
-    spirvModule.erase();
-}
-
-LogicalResult ConvertGpuLaunchFuncToVulkanLaunchFunc::declareVulkanLaunchFunc(
-    Location loc, gpu::LaunchFuncOp launchOp) {
-  auto builder = OpBuilder::atBlockEnd(getOperation().getBody());
-
-  // Workgroup size is written into the kernel. So to properly modelling
-  // vulkan launch, we have to skip local workgroup size configuration here.
-  SmallVector<Type, 8> gpuLaunchTypes(launchOp.getOperandTypes());
-  // The first kVulkanLaunchNumConfigOperands of the gpu.launch_func op are the
-  // same as the config operands for the vulkan launch call op.
-  SmallVector<Type, 8> vulkanLaunchTypes(gpuLaunchTypes.begin(),
-                                         gpuLaunchTypes.begin() +
-                                             kVulkanLaunchNumConfigOperands);
-  vulkanLaunchTypes.append(gpuLaunchTypes.begin() +
-                               gpu::LaunchOp::kNumConfigOperands,
-                           gpuLaunchTypes.end());
-
-  // Check that all operands have supported types except those for the
-  // launch configuration.
-  for (auto type :
-       llvm::drop_begin(vulkanLaunchTypes, kVulkanLaunchNumConfigOperands)) {
-    if (!isSupportedType(type))
-      return launchOp.emitError() << type << " is unsupported to run on Vulkan";
-  }
-
-  // Declare vulkan launch function.
-  auto funcType = builder.getFunctionType(vulkanLaunchTypes, {});
-  builder.create<func::FuncOp>(loc, kVulkanLaunch, funcType).setPrivate();
-
-  return success();
-}
-
-FailureOr<StringAttr>
-ConvertGpuLaunchFuncToVulkanLaunchFunc::getBinaryShader(ModuleOp module) {
-  bool done = false;
-  StringAttr binaryAttr;
-  gpu::BinaryOp binaryToErase;
-  for (auto gpuBinary : module.getOps<gpu::BinaryOp>()) {
-    if (done)
-      return gpuBinary.emitError("should only contain one 'gpu.binary' op");
-    done = true;
-
-    ArrayRef<Attribute> objects = gpuBinary.getObjectsAttr().getValue();
-    if (objects.size() != 1)
-      return gpuBinary.emitError("should only contain a single object");
-
-    auto object = cast<gpu::ObjectAttr>(objects[0]);
-
-    if (!isa<spirv::TargetEnvAttr>(object.getTarget()))
-      return gpuBinary.emitError(
-          "should contain an object with a SPIR-V target environment");
-
-    binaryAttr = object.getObject();
-    binaryToErase = gpuBinary;
-  }
-  if (!done)
-    return module.emitError("should contain a 'gpu.binary' op");
-
-  // Remove the binary to avoid confusing later conversion passes.
-  binaryToErase.erase();
-  return binaryAttr;
-}
-
-void ConvertGpuLaunchFuncToVulkanLaunchFunc::convertGpuLaunchFunc(
-    gpu::LaunchFuncOp launchOp) {
-  ModuleOp module = getOperation();
-  OpBuilder builder(launchOp);
-  Location loc = launchOp.getLoc();
-
-  FailureOr<StringAttr> binaryAttr = getBinaryShader(module);
-  // Extract SPIR-V from `gpu.binary` op.
-  if (failed(binaryAttr))
-    return signalPassFailure();
-
-  // Declare vulkan launch function.
-  if (failed(declareVulkanLaunchFunc(loc, launchOp)))
-    return signalPassFailure();
-
-  SmallVector<Value, 8> gpuLaunchOperands(launchOp.getOperands());
-  SmallVector<Value, 8> vulkanLaunchOperands(
-      gpuLaunchOperands.begin(),
-      gpuLaunchOperands.begin() + kVulkanLaunchNumConfigOperands);
-  vulkanLaunchOperands.append(gpuLaunchOperands.begin() +
-                                  gpu::LaunchOp::kNumConfigOperands,
-                              gpuLaunchOperands.end());
-
-  // Create vulkan launch call op.
-  auto vulkanLaunchCallOp = builder.create<func::CallOp>(
-      loc, TypeRange{}, SymbolRefAttr::get(builder.getContext(), kVulkanLaunch),
-      vulkanLaunchOperands);
-
-  // Set SPIR-V binary shader data as an attribute.
-  vulkanLaunchCallOp->setAttr(kSPIRVBlobAttrName, *binaryAttr);
-
-  // Set entry point name as an attribute.
-  vulkanLaunchCallOp->setAttr(kSPIRVEntryPointAttrName,
-                              launchOp.getKernelName());
-
-  // Add MemRef element types before they're lost when lowering to LLVM.
-  SmallVector<Type> elementTypes;
-  for (Type type : llvm::drop_begin(launchOp.getOperandTypes(),
-                                    gpu::LaunchOp::kNumConfigOperands)) {
-    // The below cast always succeeds as it has already been verified in
-    // 'declareVulkanLaunchFunc' that these are MemRefs with compatible element
-    // types.
-    elementTypes.push_back(cast<MemRefType>(type).getElementType());
-  }
-  vulkanLaunchCallOp->setAttr(kSPIRVElementTypesAttrName,
-                              builder.getTypeArrayAttr(elementTypes));
-
-  launchOp.erase();
-}
-
-std::unique_ptr<mlir::OperationPass<mlir::ModuleOp>>
-mlir::createConvertGpuLaunchFuncToVulkanLaunchFuncPass() {
-  return std::make_unique<ConvertGpuLaunchFuncToVulkanLaunchFunc>();
-}
diff --git a/mlir/lib/Conversion/GPUToVulkan/ConvertLaunchFuncToVulkanCalls.cpp b/mlir/lib/Conversion/GPUToVulkan/ConvertLaunchFuncToVulkanCalls.cpp
deleted file mode 100644
index 938db549630680..00000000000000
--- a/mlir/lib/Conversion/GPUToVulkan/ConvertLaunchFuncToVulkanCalls.cpp
+++ /dev/null
@@ -1,448 +0,0 @@
-//===- ConvertLaunchFuncToVulkanCalls.cpp - MLIR Vulkan conversion passes -===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-//
-// This file implements a pass to convert vulkan launch call into a sequence of
-// Vulkan runtime calls. The Vulkan runtime API surface is huge so currently we
-// don't expose separate external functions in IR for each of them, instead we
-// expose a few external functions to wrapper libraries which manages Vulkan
-// runtime.
-//
-//===----------------------------------------------------------------------===//
-
-#include "mlir/Conversion/GPUToVulkan/ConvertGPUToVulkanPass.h"
-
-#include "mlir/Dialect/LLVMIR/LLVMDialect.h"
-#include "mlir/IR/Attributes.h"
-#include "mlir/IR/Builders.h"
-#include "mlir/IR/BuiltinOps.h"
-#include "mlir/Pass/Pass.h"
-#include "llvm/ADT/SmallString.h"
-#include "llvm/Support/FormatVariadic.h"
-
-namespace mlir {
-#define GEN_PASS_DEF_CONVERTVULKANLAUNCHFUNCTOVULKANCALLSPASS
-#include "mlir/Conversion/Passes.h.inc"
-} // namespace mlir
-
-using namespace mlir;
-
-static constexpr const char *kCInterfaceVulkanLaunch =
-    "_mlir_ciface_vulkanLaunch";
-static constexpr const char *kDeinitVulkan = "deinitVulkan";
-static constexpr const char *kRunOnVulkan = "runOnVulkan";
-static constexpr const char *kInitVulkan = "initVulkan";
-static constexpr const char *kSetBinaryShader = "setBinaryShader";
-static constexpr const char *kSetEntryPoint = "setEntryPoint";
-static constexpr const char *kSetNumWorkGroups = "setNumWorkGroups";
-static constexpr const char *kSPIRVBinary = "SPIRV_BIN";
-static constexpr const char *kSPIRVBlobAttrName = "spirv_blob";
-static constexpr const char *kSPIRVEntryPointAttrName = "spirv_entry_point";
-static constexpr const char *kSPIRVElementTypesAttrName = "spirv_element_types";
-static constexpr const char *kVulkanLaunch = "vulkanLaunch";
-
-namespace {
-
-/// A pass to convert vulkan launch call op into a sequence of Vulkan
-/// runtime calls in the following order:
-///
-/// * initVulkan           -- initializes vulkan runtime
-/// * bindMemRef           -- binds memref
-/// * setBinaryShader      -- sets the binary shader data
-/// * setEntryPoint        -- sets the entry point name
-/// * setNumWorkGroups     -- sets the number of a local workgroups
-/// * runOnVulkan          -- runs vulkan runtime
-/// * deinitVulkan         -- deinitializes vulkan runtime
-///
-class VulkanLaunchFuncToVulkanCallsPass
-    : public impl::ConvertVulkanLaunchFuncToVulkanCallsPassBase<
-          VulkanLaunchFuncToVulkanCallsPass> {
-private:
-  void initializeCachedTypes() {
-    llvmFloatType = Float32Type::get(&getContext());
-    llvmVoidType = LLVM::LLVMVoidType::get(&getContext());
-    llvmPointerType = LLVM::LLVMPointerType::get(&getContext());
-    llvmInt32Type = IntegerType::get(&getContext(), 32);
-    llvmInt64Type = IntegerType::get(&getContext(), 64);
-  }
-
-  Type getMemRefType(uint32_t rank, Type elemenType) {
-    // According to the MLIR doc memref argument is converted into a
-    // pointer-to-struct argument of type:
-    // template <typename Elem, size_t Rank>
-    // struct {
-    //   Elem *allocated;
-    //   Elem *aligned;
-    //   int64_t offset;
-    //   int64_t sizes[Rank]; // omitted when rank == 0
-    //   int64_t strides[Rank]; // omitted when rank == 0
-    // };
-    auto llvmArrayRankElementSizeType =
-        LLVM::LLVMArrayType::get(getInt64Type(), rank);
-
-    // Create a type
-    // `!llvm<"{ `element-type`*, `element-type`*, i64,
-    // [`rank` x i64], [`rank` x i64]}">`.
-    return LLVM::LLVMStructType::getLiteral(
-        &getContext(),
-        {llvmPointerType, llvmPointerType, getInt64Type(),
-         llvmArrayRankElementSizeType, llvmArrayRankElementSizeType});
-  }
-
-  Type getVoidType() { return llvmVoidType; }
-  Type getPointerType() { return llvmPointerType; }
-  Type getInt32Type() { return llvmInt32Type; }
-  Type getInt64Type() { return llvmInt64Type; }
-
-  /// Creates an LLVM global for the given `name`.
-  Value createEntryPointNameConstant(StringRef name, Location loc,
-                                     OpBuilder &builder);
-
-  /// Declares all needed runtime functions.
-  void declareVulkanFunctions(Location loc);
-
-  /// Checks whether the given LLVM::CallOp is a vulkan launch call op.
-  bool isVulkanLaunchCallOp(LLVM::CallOp callOp) {
-    return (callOp.getCallee() && *callOp.getCallee() == kVulkanLaunch &&
-            callOp.getNumOperands() >= kVulkanLaunchNumConfigOperands);
-  }
-
-  /// Checks whether the given LLVM::CallOp is a "ci_face" vulkan launch call
-  /// op.
-  bool isCInterfaceVulkanLaunchCallOp(LLVM::CallOp callOp) {
-    return (callOp.getCallee() &&
-            *callOp.getCallee() == kCInterfaceVulkanLaunch &&
-            callOp.getNumOperands() >= kVulkanLaunchNumConfigOperands);
-  }
-
-  /// Translates the given `vulkanLaunchCallOp` to the sequence of Vulkan
-  /// runtime calls.
-  void translateVulkanLaunchCall(LLVM::CallOp vulkanLaunchCallOp);
-
-  /// Creates call to `bindMemRef` for each memref operand.
-  void createBindMemRefCalls(LLVM::CallOp vulkanLaunchCallOp,
-                             Value vulkanRuntime);
-
-  /// Collects SPIRV attributes from the given `vulkanLaunchCallOp`.
-  void collectSPIRVAttributes(LLVM::CallOp vulkanLaunchCallOp);
-
-  /// Deduces a rank from the given 'launchCallArg`.
-  LogicalResult deduceMemRefRank(Value launchCallArg, uint32_t &rank);
-
-  /// Returns a string representation from the given `type`.
-  StringRef stringifyType(Type type) {
-    if (isa<Float32Type>(type))
-      return "Float";
-    if (isa<Float16Type>(type))
-      return "Half";
-    if (auto intType = dyn_cast<IntegerType>(type)) {
-      if (intType.getWidth() == 32)
-        return "Int32";
-      if (intType.getWidth() == 16)
-        return "Int16";
-      if (intType.getWidth() == 8)
-        return "Int8";
-    }
-
-    llvm_unreachable("unsupported type");
-  }
-
-public:
-  using Base::Base;
-
-  void runOnOperation() override;
-
-private:
-  Type llvmFloatType;
-  Type llvmVoidType;
-  Type llvmPointerType;
-  Type llvmInt32Type...
[truncated]

``````````

</details>


https://github.com/llvm/llvm-project/pull/123750


More information about the Mlir-commits mailing list