[Mlir-commits] [mlir] [mlir][spirv] Add mgpu* wrappers for Vulkan runtime, migrate some tests (PR #123114)
Andrea Faulds
llvmlistbot at llvm.org
Thu Jan 16 09:49:39 PST 2025
================
@@ -26,6 +28,38 @@
namespace {
+class VulkanModule;
+
+// Class to be a thing that can be returned from `mgpuModuleGetFunction`.
+struct VulkanFunction {
+ VulkanModule *module;
+ std::string name;
+
+ VulkanFunction(VulkanModule *module, const char *name)
+ : module(module), name(name) {}
+};
+
+// Class to own a copy of the SPIR-V provided to `mgpuModuleLoad` and to manage
+// allocation of pointers returned from `mgpuModuleGetFunction`.
+class VulkanModule {
+public:
+ VulkanModule(const uint8_t *ptr, size_t sizeInBytes)
+ : blob(ptr, ptr + sizeInBytes) {}
+ ~VulkanModule() = default;
+
+ VulkanFunction *getFunction(const char *name) {
+ return functions.emplace_back(std::make_unique<VulkanFunction>(this, name))
+ .get();
+ }
+
+ uint8_t *blobData() { return blob.data(); }
+ size_t blobSizeInBytes() { return blob.size(); }
----------------
andfau-amd wrote:
I don't think I can make these use `const` (unless you mean only the qualifier on the method?) without changing the `VulkanRuntime` code to accept `const` pointers. I don't think there's any particularly good reason for it not taking a `const`-qualified pointer, but I don't want to touch that code right now.
https://github.com/llvm/llvm-project/pull/123114
More information about the Mlir-commits
mailing list