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

Clarify group synchronization behavior #499

Merged
merged 9 commits into from
Dec 7, 2023

Conversation

Pennycook
Copy link
Contributor

These changes build on #484 to clarify the expected synchronization behavior of group barriers and algorithms.

The wording proposed here deliberately does not specify how a SYCL implementation must satisfy certain guarantees. Previously, barriers were described in terms of fences and atomics, and we had discussed (offline) the possibility of defining algorithms similarly (or in terms of barriers). The approach taken by std::barrier in ISO C++ is much simpler, giving implementations the freedom to use any combination of synchronization operations that guarantee certain events to happen before other events.
For example, it should be legal to implement sycl::group_barrier using any of the following: std::atomic_thread_fence + relaxed std::atomic_ref, release atomics paired with acquire atomics, a call to std::barrier, or any implementation-defined (backend-specific) functions that provide the desired memory ordering semantics.

There's a lot of duplication here now, but there are two reasons for that:

  1. I wanted some feedback on the wording, and specifically whether we would like the "Effects" for each algorithm to mention the algorithm by name.

  2. I wanted to separate the review of the clarifications from any later formatting changes. The new table of overloads format that @gmlueck has been working on would allow us to combine some of these definitions.

Closes internal issue 576.

The previous description of group_barrier required implementations to
execute certain fences, which should be an implementation detail.

This commit adds a "Synchronization" section to group_barrier and describes
behavior in terms of a happens-before relationship. Implementations may
choose to implement the barrier using any synchronization operations which
satisfy this requirement.
State explicitly that:
- Group algorithms block until the algorithm executes.
- Group algorithms have similar happens-before implications to barriers.

Closes internal issue 576.
C++ just says "blocks" rather than "blocks this thread", so we can drop
"blocks this work-item".
Explains that a group function may define operation(s) that take place only
when all work-items have arried at the group function's synchronization point.

The intent is that group algorithms can then be considered a specific instance
of these group functions, where the operation(s) constitute the algorithm that
should be executed.
These were accidentally overlooked during the previous round of changes.
Co-authored-by: Greg Lueck <gregory.m.lueck@intel.com>
@gmlueck
Copy link
Contributor

gmlueck commented Dec 7, 2023

This needs one more reviewer. Can someone volunteer?

Copy link
Member

@keryell keryell left a comment

Choose a reason for hiding this comment

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

That looks good. Perhaps we could factorize somehow the basic synchronization description?

@Pennycook
Copy link
Contributor Author

That looks good. Perhaps we could factorize somehow the basic synchronization description?

I agree that there are probably some opportunities to reduce the amount of duplicated information.

I'd rather we do that in a follow-up PR, though, if everybody is okay with that. Ideally, I'd like us to agree that the specification for each overload is correct, and then we can look for opportunities to refactor things.

@gmlueck gmlueck merged commit fdc8a5e into KhronosGroup:SYCL-2020/master Dec 7, 2023
2 checks passed
@Pennycook Pennycook deleted the sychronization branch December 7, 2023 18:44
keryell pushed a commit that referenced this pull request Sep 10, 2024
Clarify group synchronization behavior
gmlueck added a commit that referenced this pull request Nov 7, 2024
Clarify group synchronization behavior

(cherry picked from commit fdc8a5e)
gmlueck added a commit that referenced this pull request Nov 7, 2024
Clarify group synchronization behavior

(cherry picked from commit fdc8a5e)
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.

4 participants