[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 07:34:23 PST 2025
================
@@ -26,6 +28,37 @@
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 char *ptr, size_t size) : blob(ptr, ptr + size) {}
+ ~VulkanModule() = default;
+
+ VulkanFunction *getFunction(const char *name) {
+ return functions.emplace_back(std::make_unique<VulkanFunction>(this, name))
+ .get();
+ }
+
+ uint8_t *blobData() { return reinterpret_cast<uint8_t *>(blob.data()); }
+ uint32_t blobSize() { return static_cast<uint32_t>(blob.size()); }
+
+private:
+ std::vector<char> blob;
+ std::vector<std::unique_ptr<VulkanFunction>> functions;
----------------
andfau-amd wrote:
Actually no, I think I was right the first time:
https://github.com/llvm/llvm-project/blob/9e863cd44945345f22a28cdd3ea12aaa7963345e/mlir/tools/mlir-vulkan-runner/CMakeLists.txt#L42-L49
The usage of the Support libraries must be in some header-only fashion. I guess everything about `SmallVector` is probably templated but I'd still rather avoid using it, it feels risky.
https://github.com/llvm/llvm-project/pull/123114
More information about the Mlir-commits
mailing list