From 1c953c10a00dd2767a73cc71202271ef7c106b00 Mon Sep 17 00:00:00 2001 From: 0cc4m Date: Tue, 23 Jan 2024 08:00:39 +0100 Subject: [PATCH] Check for maintenance4 support before using it --- ggml-vulkan.cpp | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/ggml-vulkan.cpp b/ggml-vulkan.cpp index b5697d9c0..36705d6d5 100644 --- a/ggml-vulkan.cpp +++ b/ggml-vulkan.cpp @@ -973,22 +973,37 @@ std::cerr << "ggml_vulkan: Validation layers enabled" << std::endl; vk_instance = vk::createInstance(instance_create_info); vk_device.physical_device = vk_instance.enumeratePhysicalDevices()[dev_num]; + std::vector ext_props = vk_device.physical_device.enumerateDeviceExtensionProperties(); + + bool maintenance4_support = false; + + // Check if maintenance4 is supported + for (auto properties : ext_props) { + if (strcmp("VK_KHR_maintenance4", properties.extensionName) == 0) { + maintenance4_support = true; + } + } + vk::PhysicalDeviceProperties2 props2; vk::PhysicalDeviceMaintenance3Properties props3; vk::PhysicalDeviceMaintenance4Properties props4; props2.pNext = &props3; - props3.pNext = &props4; - props4.pNext = nullptr; + if (maintenance4_support) { + props3.pNext = &props4; + } vk_device.physical_device.getProperties2(&props2); vk_device.properties = props2.properties; - vk_device.max_memory_allocation_size = std::min(props3.maxMemoryAllocationSize, props4.maxBufferSize); + + if (maintenance4_support) { + vk_device.max_memory_allocation_size = std::min(props3.maxMemoryAllocationSize, props4.maxBufferSize); + } else { + vk_device.max_memory_allocation_size = props3.maxMemoryAllocationSize; + } std::cerr << "ggml_vulkan: Using " << vk_device.properties.deviceName << std::endl; vk_device.vendor_id = vk_device.properties.vendorID; - std::vector ext_props = vk_device.physical_device.enumerateDeviceExtensionProperties(); - bool fp16_storage = false; bool fp16_compute = false;