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

Update semaphore synchronisation used in Vulkan interop tests #2243

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

Conversation

gorazd-sumkovski-arm
Copy link
Contributor

No description provided.

Remove the `CREATE_OPENCL_SEMAPHORE` macro and use derived class
instantiations of the `clExternalSemaphore` class, rather than base
pointers to derived class objects.

Remove the default argument for `queryParamName` in
`check_external_semaphore_handle_type()`.

Move `check_external_semaphore_handle_type()` checks to constructors of
`clExternalImportableSemaphore` and `clExternalExportableSemaphore`,
rather than manually making the check before creating an external semaphore.

Signed-off-by: Gorazd Sumkovski <[email protected]>
Since sync_fd semaphores have copy transference,
`clExternalExportableSemaphore::signal()` exports the payload after
enqueuing a signal. However the queue must be finished to execute the
signal before the export.

Also fix an event dependency deadlock in `buffer_multiple_queue` by
adding a finish on `cmd_queue1` to resolve the dependencies.

Signed-off-by: Gorazd Sumkovski <[email protected]>
@@ -1146,6 +1152,14 @@ int clExternalExportableSemaphore::signal(cl_command_queue cmd_queue)

if (m_externalHandleType == VULKAN_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD)
{
// Finish the queue to signal the semaphore
err = clFinish(cmd_queue);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you explain why this is needed?

Copy link
Contributor

Choose a reason for hiding this comment

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

This shouldn't be needed. The OpenCL spec states that after clEnqueueSignalSemaphoreKHR returns, it is safe to wait. The implication is that it is also safe to import into vulkan, the finish is not necessary here, and defeats the purpose of semaphores.

// cmd_queue1 needs to be finished now because
// cmd_queue2 depends on first_launch which is
// completed in cmd_queue1.
err = clFinish(cmd_queue1);
Copy link
Contributor

Choose a reason for hiding this comment

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

I do not think this finish is required, semaphores can operate asynchronously. I could be convinced a flush may be needed, but I don't think finish is correct.

This change adds a lot of clFinishes. I think this makes the test synchronous and incorrect.

@kpet
Copy link
Contributor

kpet commented Feb 25, 2025

Discussed in 2025/02/25: Qcom like the refactoring but are questioning the addition of many calls to clFinish. Could we split the PR into two (pushing the addition of calls to clFinish to the second PR)?

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.

4 participants