This repository has been archived by the owner on Mar 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 187
Documentation changes for wait_parity/try_wait_parity #190
Open
wmaxey
wants to merge
2
commits into
main
Choose a base branch
from
docs/barrier-parity
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
docs/extended_api/synchronization_primitives/barrier/wait_parity.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
--- | ||
grand_parent: Extended API | ||
parent: Barriers | ||
--- | ||
|
||
# `cuda::barrier::wait_parity` and `cuda::barrier::try_wait_parity` | ||
|
||
Defined in header `<cuda/std/barrier>`: | ||
|
||
```cuda | ||
__host__ __device__ void cuda::std::barrier::wait_parity(bool phase); | ||
__host__ __device__ bool cuda::std::barrier::try_wait_parity(bool phase); | ||
``` | ||
|
||
`barrier::wait_parity` stalls execution while the barrier is not at the specified parity. | ||
`barrier::try_wait_parity` returns true if the parity of the barrier matches the given parity. | ||
|
||
## Return Value | ||
|
||
`barrier::try_wait_parity` returns a boolean representing whether the barrier is at the given phase | ||
|
||
<!-- TODO: Create an example when trunk is live on godbolt | ||
## Example | ||
|
||
```cuda | ||
#include <cuda/barrier> | ||
|
||
__global__ void example_kernel(cuda::barrier<cuda::thread_scope_block>& bar) { | ||
bar.wait_parity(false); | ||
} | ||
``` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be good to have an example that shows how to use these APIs to accomplish something minimally useful. It might not be clear to the user what these APIs are for, what the parity of the barrier is initially, how to get the parity of a phase, etc. |
||
--> | ||
|
||
[See it on Godbolt](https://godbolt.org/z/dr4798Y76){: .btn } | ||
|
||
|
||
[`cuda::thread_scope`]: ./thread_scopes.md | ||
|
||
[thread.barrier.class paragraph 12]: https://eel.is/c++draft/thread.barrier.class#12 | ||
|
||
[coalesced threads]: https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#coalesced-group-cg | ||
|
||
[`concurrentManagedAccess` property]: https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaDeviceProp.html#structcudaDeviceProp_116f9619ccc85e93bc456b8c69c80e78b | ||
[`hostNativeAtomicSupported` property]: https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaDeviceProp.html#structcudaDeviceProp_1ef82fd7d1d0413c7d6f33287e5b6306f | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
atomic::wait(value)
"waits until the value is no longervalue
".Here,
wait_parity(value)
"waits until the value becomesvalue
" which is the opposite.Is this intended? Seems subtly different.
@wmaxey ? @ogiroux ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should swap it to match atomic wait. Also make sense as we are waiting for phase to change