Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix errors in test_vulkan #2183

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Conversation

ahesham-arm
Copy link
Contributor

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 if any of the semaphore objects specified by sema_objects is not valid.

  1. 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.

  2. 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.

externalMemoryHandleTypeList.push_back(
VULKAN_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD);
if (physical_device.hasExtension(
VK_KHR_EXTERNAL_MEMORY_CAPABILITIES_EXTENSION_NAME))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From Ben: Is this the right extension name to check for?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer we wait on merging this, it introduces a segfault for us. We would like to debug

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not the correct place to check for this extension. We already request it in vulkan_wrapper.cpp: line 146. This leads to a crash for us because VK_KHR_EXTERNAL_MEMORY_CAPABILITES_EXTENISION_NAME is not detected, and getSupportedVulkanExternalMemoryHandleTypeList() returns a 0 length list. When getSupportedVulkanExternalMemoryHandleTypeList()[0] is called, a crash is the result.

Copy link
Contributor Author

@ahesham-arm ahesham-arm Jan 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@joshqti You're right. Additionally, from the VK_KHR_external_memory_capabilities section in the Vulkan specification:

Promotion to Vulkan 1.1
All functionality in this extension is included in core Vulkan 1.1, with the KHR suffix omitted. The
original type, enum, and command names are still available as aliases of the core functionality.

We use Vulkan 1.1, so we should not need to check this extension anyway.

That being said, we should have checks for the usage pattern that we intend with this type of memory, in our case it is export (from Vulkan), i.e. check that VK_EXTERNAL_MEMORY_FEATURE_EXPORTABLE_BIT is set for external memory that has the handle type: VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR.

I have updated the pull request to reflect this. Please let me know if you disagree and if you are continuing to see segmentation faults with this patch applied.

Add `CL_INVALID_SEMAPHORE_KHR` to the error string helper function.

Signed-off-by: Ahmed Hesham <[email protected]>
Calling `clEnqueue{Wait,Signal}SemaphoresKHR` with an invalid
semaphore should return `CL_INVALID_SEMAPHORE_KHR` and not
`CL_INVALID_VALUE`.

Signed-off-by: Ahmed Hesham <[email protected]>
@fredlee12001
Copy link

I believe test_consistency_external_image needs the similar change to skip the test if extension not supported.

@ahesham-arm
Copy link
Contributor Author

I believe test_consistency_external_image needs the similar change to skip the test if extension not supported.
@fredlee12001 Good catch, thank you! This must have been missed in the recent merge conflict resolution.

Updated both test_consistency_external_image and test_consistency_external_semaphore to match the behaviour of test_consistency_external_buffer, i.e. skip the test if the extension is not supported (don't throw or fail the test).

Check that the device supports exporting memory with a handle type
`VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR` before adding an
entry to the list of supported Vulkan external memory handle types.

Signed-off-by: Ahmed Hesham <[email protected]>
If the device does not support the required extension, skip the test,
instead of throwing an exception and failing.

Signed-off-by: Ahmed Hesham <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants