Skip to content

Commit

Permalink
vulkan: remove unneeded variables
Browse files Browse the repository at this point in the history
  • Loading branch information
Adriankhl committed Jun 20, 2024
1 parent a9e8dc4 commit 2f290b5
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions ggml-vulkan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1745,23 +1745,22 @@ void ggml_vk_instance_init() {

// Default to using all dedicated GPUs
for (size_t i = 0; i < devices.size(); i++) {
vk::PhysicalDeviceProperties new_props_1 = devices[i].getProperties();
vk::PhysicalDeviceProperties2 new_props_2;
vk::PhysicalDeviceProperties2 new_props;
vk::PhysicalDeviceDriverProperties new_driver;
vk::PhysicalDeviceIDProperties new_id;
new_props_2.pNext = &new_driver;
new_props.pNext = &new_driver;
new_driver.pNext = &new_id;
devices[i].getProperties2(&new_props_2);
devices[i].getProperties2(&new_props);

if (new_props_1.deviceType == vk::PhysicalDeviceType::eDiscreteGpu) {
if (new_props.properties.deviceType == vk::PhysicalDeviceType::eDiscreteGpu) {
// Check if there are two physical devices corresponding to the same GPU
auto old_device = std::find_if(
vk_instance.device_indices.begin(),
vk_instance.device_indices.end(),
[&devices, &new_id](const size_t k){
vk::PhysicalDeviceProperties2 old_props_2;
[&devices, &new_id](const size_t k){
vk::PhysicalDeviceProperties2 old_props;
vk::PhysicalDeviceIDProperties old_id;
devices[k].getProperties2(&old_props_2);
devices[k].getProperties2(&old_props);
return std::equal(std::begin(old_id.deviceUUID), std::end(old_id.deviceUUID), std::begin(new_id.deviceUUID));
}
);
Expand All @@ -1772,18 +1771,18 @@ void ggml_vk_instance_init() {
// This can cause error when splitting layers aross the devices, need to keep only 1
VK_LOG_DEBUG("Device " << i << " and device " << *old_device << " have the same deviceUUID");

vk::PhysicalDeviceProperties2 old_props_2;
vk::PhysicalDeviceProperties2 old_props;
vk::PhysicalDeviceDriverProperties old_driver;
old_props_2.pNext = &old_driver;
devices[*old_device].getProperties2(&old_props_2);
old_props.pNext = &old_driver;
devices[*old_device].getProperties2(&old_props);

std::map<vk::DriverId, int> driver_priorities {};
int old_priority = std::numeric_limits<int>::max();
int new_priority = std::numeric_limits<int>::max();

// Check https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkDriverId.html for the list of driver id
// Smaller number -> higher priority
switch (old_props_2.properties.vendorID) {
switch (old_props.properties.vendorID) {
case VK_VENDOR_ID_AMD:
driver_priorities[vk::DriverId::eMesaRadv] = 1;
driver_priorities[vk::DriverId::eAmdOpenSource] = 2;
Expand Down

0 comments on commit 2f290b5

Please sign in to comment.