Fix errors in test_vulkan (#2183)

This fixes three problems in `test_vulkan`:

1. One negative test is violating the OpenCL specification. A call to
`clEnqueue{Wait,Signal}SemaphoresKHR` with an invalid semaphore should
return `CL_INVALID_SEMAPHORE_KHR` and not `CL_INVALID_VALUE`.
>
[CL_INVALID_SEMAPHORE_KHR](https://registry.khronos.org/OpenCL/specs/3.0-unified/html/OpenCL_API.html#CL_INVALID_SEMAPHORE_KHR)
if any of the semaphore objects specified by sema_objects is not valid.

2. When populating the list of supported external memory handle types
for Vulkan, the types are unconditionally added to the list, without
checking if the device supports it or not, this fix is namely for
`VULKAN_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD`.

3. If a device does not support an optional extension (that is required
for a test), the test should skip, not throw an exception and fail. A
test failure should be reserved for the cases where a device claims
support for an extension but then fails to execute the test correctly.

---------

Signed-off-by: Ahmed Hesham <ahmed.hesham@arm.com>
This commit is contained in:
Ahmed Hesham
2025-01-28 18:08:24 +00:00
committed by GitHub
parent c6cfb6800f
commit 73dd3b9af8
9 changed files with 70 additions and 38 deletions

View File

@@ -61,14 +61,15 @@ struct ConsistencyExternalBufferTest : public VulkanTestBase
#else
if (!is_extension_available(device, "cl_khr_external_memory_opaque_fd"))
{
throw std::runtime_error(
"Device does not support "
"cl_khr_external_memory_opaque_fd extension \n");
log_info("Device does not support "
"cl_khr_external_memory_opaque_fd extension \n");
return TEST_SKIPPED_ITSELF;
}
#endif
VulkanExternalMemoryHandleType vkExternalMemoryHandleType =
getSupportedVulkanExternalMemoryHandleTypeList()[0];
getSupportedVulkanExternalMemoryHandleTypeList(
vkDevice->getPhysicalDevice())[0];
VulkanBuffer vkDummyBuffer(*vkDevice, 4 * 1024,
vkExternalMemoryHandleType);
@@ -200,9 +201,9 @@ struct ConsistencyExternalImageTest : public VulkanTestBase
#else
if (!is_extension_available(device, "cl_khr_external_memory_opaque_fd"))
{
test_fail(
"Device does not support cl_khr_external_memory_opaque_fd "
"extension \n");
log_info("Device does not support cl_khr_external_memory_opaque_fd "
"extension \n");
return TEST_SKIPPED_ITSELF;
}
#endif
uint32_t width = 256;
@@ -212,7 +213,8 @@ struct ConsistencyExternalImageTest : public VulkanTestBase
cl_image_format img_format = { 0 };
VulkanExternalMemoryHandleType vkExternalMemoryHandleType =
getSupportedVulkanExternalMemoryHandleTypeList()[0];
getSupportedVulkanExternalMemoryHandleTypeList(
vkDevice->getPhysicalDevice())[0];
VulkanImageTiling vulkanImageTiling =
vkClExternalMemoryHandleTilingAssumption(
@@ -355,9 +357,9 @@ struct ConsistencyExternalSemaphoreTest : public VulkanTestBase
#else
if (!is_extension_available(device, "cl_khr_external_memory_opaque_fd"))
{
test_fail(
"Device does not support cl_khr_external_memory_opaque_fd "
"extension \n");
log_info("Device does not support cl_khr_external_memory_opaque_fd "
"extension \n");
return TEST_SKIPPED_ITSELF;
}
#endif
@@ -484,18 +486,18 @@ struct ConsistencyExternalSemaphoreTest : public VulkanTestBase
// Pass invalid semaphore object to wait
errNum = clEnqueueWaitSemaphoresKHRptr(queue, 1, NULL, NULL, 0,
NULL, NULL);
test_failure_error(
errNum, CL_INVALID_VALUE,
"clEnqueueWaitSemaphoresKHR fails with CL_INVALID_VALUE "
"when invalid semaphore object is passed");
test_failure_error(errNum, CL_INVALID_SEMAPHORE_KHR,
"clEnqueueWaitSemaphoresKHR fails with "
"CL_INVALID_SEMAPHORE_KHR "
"when invalid semaphore object is passed");
// Pass invalid semaphore object to signal
errNum = clEnqueueSignalSemaphoresKHRptr(queue, 1, NULL, NULL, 0,
NULL, NULL);
test_failure_error(
errNum, CL_INVALID_VALUE,
"clEnqueueSignalSemaphoresKHR fails with CL_INVALID_VALUE"
"when invalid semaphore object is passed");
test_failure_error(errNum, CL_INVALID_SEMAPHORE_KHR,
"clEnqueueSignalSemaphoresKHR fails with "
"CL_INVALID_SEMAPHORE_KHR"
"when invalid semaphore object is passed");
// Create two semaphore objects
clVk2Clsemaphore = clCreateSemaphoreWithPropertiesKHRptr(