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

[runtime][hip][cuda] Fix waiting on a semaphore on the host #17073

Merged

Conversation

sogartar
Copy link
Contributor

When waiting on a semaphore we first attempt to wait on a timepoint event on the dispatch stream.
This is not correct as the semaphore is signaled in a callback on the host stream when signaling that an action is complete.
This callback happens after the dispatch stream event, so the semaphore value may not be update yet.

The fix is to directly wait on the host semaphore and not on the dispatch stream event.

Also add a test that catches this failure.

When waiting on a semaphore we first attempt to wait on a timepoint event on
the dispatch stream.
This is not correct as the semaphore is signaled in a callback on the host
stream when signaling that an action is complete.
This callback happens after the dispatch stream event, so the semaphore value
may not be update yet.

The fix is to directly wait on the host semaphore and not on the dispatch
stream event.

Also add a test that catches this failure.
Copy link
Contributor

@antiagainst antiagainst left a comment

Choose a reason for hiding this comment

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

Awesome, thanks for fixing this! This was meant to be an optimization (#14876) becuase it was faster to wait the device event, at least on cuda. But yeah; it's problematic..

// The signaling relationship is
// command_buffer1 -> semaphore1 -> command_buffer2 -> semaphore2

// Create second command_buffer1.
Copy link
Contributor

Choose a reason for hiding this comment

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

.. first ..

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@sogartar sogartar enabled auto-merge (squash) April 17, 2024 18:02
@sogartar sogartar merged commit cd282de into iree-org:main Apr 17, 2024
53 checks passed
LLITCHEV pushed a commit to LLITCHEV/iree that referenced this pull request Jul 30, 2024
…#17073)

When waiting on a semaphore we first attempt to wait on a timepoint
event on the dispatch stream.
This is not correct as the semaphore is signaled in a callback on the
host stream when signaling that an action is complete.
This callback happens after the dispatch stream event, so the semaphore
value may not be update yet.

The fix is to directly wait on the host semaphore and not on the
dispatch stream event.

Also add a test that catches this failure.

Signed-off-by: Lubo Litchev <lubol@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants