vulkan: disambiguate gpus with the same name

This commit is contained in:
Aaron Miller 2023-09-13 09:51:40 -07:00 committed by Cebtenzzre
parent 68cf1df6fb
commit 8bea719879

View File

@ -145,6 +145,8 @@ std::vector<ggml_vk_device> ggml_vk_available_devices(size_t memoryRequired) {
if (deviceCount == 0) if (deviceCount == 0)
return results; return results;
std::unordered_map<std::string, size_t> count_by_name;
for (uint32_t i = 0; i < deviceCount; i++) { for (uint32_t i = 0; i < deviceCount; i++) {
VkPhysicalDeviceProperties properties = physicalDevices.at(i).getProperties(); VkPhysicalDeviceProperties properties = physicalDevices.at(i).getProperties();
VkPhysicalDeviceMemoryProperties memoryProperties = physicalDevices.at(i).getMemoryProperties(); VkPhysicalDeviceMemoryProperties memoryProperties = physicalDevices.at(i).getMemoryProperties();
@ -173,6 +175,10 @@ std::vector<ggml_vk_device> ggml_vk_available_devices(size_t memoryRequired) {
d.type = properties.deviceType; d.type = properties.deviceType;
d.heapSize = heapSize; d.heapSize = heapSize;
d.name = properties.deviceName; d.name = properties.deviceName;
size_t n_idx = ++count_by_name[d.name];
if (n_idx > 1) {
d.name += " (" + std::to_string(n_idx) + ")";
}
d.vendor = ggml_vk_getVendorName(properties.vendorID); d.vendor = ggml_vk_getVendorName(properties.vendorID);
results.push_back(d); results.push_back(d);
} }