Skip to content

Commit b249afc

Browse files
authored
[SYCL][Bindless] Fix bindless vulkan interop tests selecting wrong vulkan device (#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.
1 parent c844334 commit b249afc

File tree

4 files changed

+23
-16
lines changed

4 files changed

+23
-16
lines changed

sycl/test-e2e/bindless_images/vulkan_interop/mipmaps.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -444,11 +444,10 @@ int main() {
444444
return EXIT_FAILURE;
445445
}
446446

447-
const char *devices[] = {"Intel", "NVIDIA"};
448-
if (std::none_of(std::begin(devices), std::end(devices),
449-
[](const char *device) {
450-
return vkutil::setupDevice(device) == VK_SUCCESS;
451-
})) {
447+
sycl::device dev;
448+
449+
if (vkutil::setupDevice(dev.get_info<sycl::info::device::name>()) !=
450+
VK_SUCCESS) {
452451
std::cerr << "Device setup failed!\n";
453452
return EXIT_FAILURE;
454453
}

sycl/test-e2e/bindless_images/vulkan_interop/sampled_images.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -364,11 +364,10 @@ int main() {
364364
return EXIT_FAILURE;
365365
}
366366

367-
const char *devices[] = {"Intel", "NVIDIA"};
368-
if (std::none_of(std::begin(devices), std::end(devices),
369-
[](const char *device) {
370-
return vkutil::setupDevice(device) == VK_SUCCESS;
371-
})) {
367+
sycl::device dev;
368+
369+
if (vkutil::setupDevice(dev.get_info<sycl::info::device::name>()) !=
370+
VK_SUCCESS) {
372371
std::cerr << "Device setup failed!\n";
373372
return EXIT_FAILURE;
374373
}

sycl/test-e2e/bindless_images/vulkan_interop/unsampled_images.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -622,11 +622,10 @@ int main() {
622622
return EXIT_FAILURE;
623623
}
624624

625-
const char *devices[] = {"Intel", "NVIDIA"};
626-
if (std::none_of(std::begin(devices), std::end(devices),
627-
[](const char *device) {
628-
return vkutil::setupDevice(device) == VK_SUCCESS;
629-
})) {
625+
sycl::device dev;
626+
627+
if (vkutil::setupDevice(dev.get_info<sycl::info::device::name>()) !=
628+
VK_SUCCESS) {
630629
std::cerr << "Device setup failed!\n";
631630
return EXIT_FAILURE;
632631
}

sycl/test-e2e/bindless_images/vulkan_interop/vulkan_common.hpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,11 @@ VkResult setupDevice(std::string device) {
232232
#endif
233233
};
234234

235+
// Make lowercase to fix inconsistent capitalization between SYCL and Vulkan
236+
// device naming.
237+
std::transform(device.begin(), device.end(), device.begin(),
238+
[](unsigned char c) { return std::tolower(c); });
239+
235240
// From all physical devices, find the first one that supports all our
236241
// required device extensions.
237242
for (int i = 0; i < physicalDeviceCount; i++) {
@@ -240,6 +245,10 @@ VkResult setupDevice(std::string device) {
240245
vkGetPhysicalDeviceProperties(vk_physical_device, &props);
241246
std::string name(props.deviceName);
242247

248+
// Make lowercase for comparision.
249+
std::transform(name.begin(), name.end(), name.begin(),
250+
[](unsigned char c) { return std::tolower(c); });
251+
243252
if (name.find(device) == std::string::npos) {
244253
continue;
245254
}
@@ -261,7 +270,8 @@ VkResult setupDevice(std::string device) {
261270
}
262271

263272
foundDevice = true;
264-
std::cout << "Found suitable Vulkan device: " << name << std::endl;
273+
std::cout << "Found suitable Vulkan device: " << props.deviceName
274+
<< std::endl;
265275
break;
266276
}
267277

0 commit comments

Comments
 (0)