Skip to content

Commit

Permalink
[SYCL][Bindless] Fix bindless vulkan interop tests selecting wrong vu…
Browse files Browse the repository at this point in the history
…lkan device (intel#14386)

The incorrect vulkan device can be selected when both Intel and Nvidia
devices are available on the same system. Change tests to use the same
device as SYCL default to.
  • Loading branch information
DBDuncan committed Jul 4, 2024
1 parent c844334 commit b249afc
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 16 deletions.
9 changes: 4 additions & 5 deletions sycl/test-e2e/bindless_images/vulkan_interop/mipmaps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -444,11 +444,10 @@ int main() {
return EXIT_FAILURE;
}

const char *devices[] = {"Intel", "NVIDIA"};
if (std::none_of(std::begin(devices), std::end(devices),
[](const char *device) {
return vkutil::setupDevice(device) == VK_SUCCESS;
})) {
sycl::device dev;

if (vkutil::setupDevice(dev.get_info<sycl::info::device::name>()) !=
VK_SUCCESS) {
std::cerr << "Device setup failed!\n";
return EXIT_FAILURE;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -364,11 +364,10 @@ int main() {
return EXIT_FAILURE;
}

const char *devices[] = {"Intel", "NVIDIA"};
if (std::none_of(std::begin(devices), std::end(devices),
[](const char *device) {
return vkutil::setupDevice(device) == VK_SUCCESS;
})) {
sycl::device dev;

if (vkutil::setupDevice(dev.get_info<sycl::info::device::name>()) !=
VK_SUCCESS) {
std::cerr << "Device setup failed!\n";
return EXIT_FAILURE;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -622,11 +622,10 @@ int main() {
return EXIT_FAILURE;
}

const char *devices[] = {"Intel", "NVIDIA"};
if (std::none_of(std::begin(devices), std::end(devices),
[](const char *device) {
return vkutil::setupDevice(device) == VK_SUCCESS;
})) {
sycl::device dev;

if (vkutil::setupDevice(dev.get_info<sycl::info::device::name>()) !=
VK_SUCCESS) {
std::cerr << "Device setup failed!\n";
return EXIT_FAILURE;
}
Expand Down
12 changes: 11 additions & 1 deletion sycl/test-e2e/bindless_images/vulkan_interop/vulkan_common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,11 @@ VkResult setupDevice(std::string device) {
#endif
};

// Make lowercase to fix inconsistent capitalization between SYCL and Vulkan
// device naming.
std::transform(device.begin(), device.end(), device.begin(),
[](unsigned char c) { return std::tolower(c); });

// From all physical devices, find the first one that supports all our
// required device extensions.
for (int i = 0; i < physicalDeviceCount; i++) {
Expand All @@ -240,6 +245,10 @@ VkResult setupDevice(std::string device) {
vkGetPhysicalDeviceProperties(vk_physical_device, &props);
std::string name(props.deviceName);

// Make lowercase for comparision.
std::transform(name.begin(), name.end(), name.begin(),
[](unsigned char c) { return std::tolower(c); });

if (name.find(device) == std::string::npos) {
continue;
}
Expand All @@ -261,7 +270,8 @@ VkResult setupDevice(std::string device) {
}

foundDevice = true;
std::cout << "Found suitable Vulkan device: " << name << std::endl;
std::cout << "Found suitable Vulkan device: " << props.deviceName
<< std::endl;
break;
}

Expand Down

0 comments on commit b249afc

Please sign in to comment.