Skip to content

[SYCL] Fix a thread pool data race during shutdown #15535

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

Merged
merged 2 commits into from
Sep 27, 2024

Conversation

sergey-semenov
Copy link
Contributor

The flag that kills the threads waiting for work was an atomic bool, but that is not enough: any modification of a condition must be made under the mutex associated with that condition variable. Otherwise, the bool value flip and the call to notify might happen after the condition check in the other thread, but before it starts waiting for notifications.

The flag that kills the threads waiting for work was an atomic bool,
but that is not enough: any modification of a condition must be made
under the mutex associated with that condition variable. Otherwise,
the bool value flip and the call to notify might happen after the
condition check in the other thread, but before it starts waiting for
notifications.
Copy link
Contributor

@steffenlarsen steffenlarsen left a comment

Choose a reason for hiding this comment

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

This looks reasonable. Should we consider using std::counting_semaphore when we switch to C++20 in the future?

@againull againull merged commit 8fc9aa5 into intel:sycl Sep 27, 2024
12 checks passed
AlexeySachkov pushed a commit to AlexeySachkov/llvm that referenced this pull request Nov 27, 2024
The flag that kills the threads waiting for work was an atomic bool, but
that is not enough: any modification of a condition must be made under
the mutex associated with that condition variable. Otherwise, the bool
value flip and the call to notify might happen after the condition check
in the other thread, but before it starts waiting for notifications.
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.

3 participants