Skip to content

Commit cb5bb6c

Browse files
authored
vulkan: automatically remove unsupported devices (#15976)
* remove unsupported vulkan devices * make this happen during selection instead * pass by reference
1 parent a91d035 commit cb5bb6c

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

ggml/src/ggml-vulkan/ggml-vulkan.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4423,8 +4423,8 @@ static void ggml_vk_print_gpu_info(size_t idx) {
44234423

44244424
static bool ggml_vk_instance_validation_ext_available();
44254425
static bool ggml_vk_instance_portability_enumeration_ext_available(const std::vector<vk::ExtensionProperties>& instance_extensions);
4426-
44274426
static bool ggml_vk_instance_debug_utils_ext_available(const std::vector<vk::ExtensionProperties> & instance_extensions);
4427+
static bool ggml_vk_device_is_supported(const vk::PhysicalDevice & vkdev);
44284428

44294429
static void ggml_vk_instance_init() {
44304430
if (vk_instance_initialized) {
@@ -4540,7 +4540,7 @@ static void ggml_vk_instance_init() {
45404540
new_driver.pNext = &new_id;
45414541
devices[i].getProperties2(&new_props);
45424542

4543-
if (new_props.properties.deviceType == vk::PhysicalDeviceType::eDiscreteGpu || new_props.properties.deviceType == vk::PhysicalDeviceType::eIntegratedGpu) {
4543+
if ((new_props.properties.deviceType == vk::PhysicalDeviceType::eDiscreteGpu || new_props.properties.deviceType == vk::PhysicalDeviceType::eIntegratedGpu) && ggml_vk_device_is_supported(devices[i])) {
45444544
// Check if there are two physical devices corresponding to the same GPU
45454545
auto old_device = std::find_if(
45464546
vk_instance.device_indices.begin(),
@@ -12738,6 +12738,20 @@ static bool ggml_vk_instance_debug_utils_ext_available(
1273812738
UNUSED(instance_extensions);
1273912739
}
1274012740

12741+
static bool ggml_vk_device_is_supported(const vk::PhysicalDevice & vkdev) {
12742+
VkPhysicalDeviceFeatures2 device_features2;
12743+
device_features2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
12744+
12745+
VkPhysicalDeviceVulkan11Features vk11_features;
12746+
vk11_features.pNext = nullptr;
12747+
vk11_features.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_1_FEATURES;
12748+
device_features2.pNext = &vk11_features;
12749+
12750+
vkGetPhysicalDeviceFeatures2(vkdev, &device_features2);
12751+
12752+
return vk11_features.storageBuffer16BitAccess;
12753+
}
12754+
1274112755
static bool ggml_vk_khr_cooperative_matrix_support(const vk::PhysicalDeviceProperties& props, const vk::PhysicalDeviceDriverProperties& driver_props, vk_device_architecture arch) {
1274212756
switch (props.vendorID) {
1274312757
case VK_VENDOR_ID_INTEL:

0 commit comments

Comments
 (0)