This repository was archived by the owner on Mar 21, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +49
-2
lines changed
docs/extended_api/synchronization_primitives Expand file tree Collapse file tree 2 files changed +49
-2
lines changed Original file line number Diff line number Diff line change @@ -21,8 +21,9 @@ It has the same interface and semantics as [`cuda::std::barrier`], with the
2121
2222## Barrier Operations
2323
24- | [ ` cuda::barrier::init ` ] | Initialize a ` cuda::barrier ` . ` (friend function) ` |
25- | [ ` cuda::device::barrier_native_handle ` ] | Get the native handle to a ` cuda::barrier ` . ` (function template) ` |
24+ | [ ` cuda::barrier::init ` ] | Initialize a ` cuda::barrier ` . ` (friend function) ` |
25+ | [ ` cuda::device::barrier_native_handle ` ] | Get the native handle to a ` cuda::barrier ` . ` (function template) ` |
26+ | [ ` cuda::barrier::wait_parity/try_wait_parity ` ] | Wait on a ` specific ` phase of the barrier |
2627
2728## NVCC ` __shared__ ` Initialization Warnings
2829
@@ -98,6 +99,7 @@ __global__ void example_kernel() {
9899
99100[ `cuda::barrier::init` ] : ./barrier/init.md
100101[ `cuda::device::barrier_native_handle` ] : ./barrier/barrier_native_handle.md
102+ [ `cuda::barrier::wait_parity/try_wait_parity` ] : ./barrier/wait_parity.md
101103
102104[ `cuda::std::barrier` ] : https://en.cppreference.com/w/cpp/thread/barrier
103105
Original file line number Diff line number Diff line change 1+ ---
2+ grand_parent : Extended API
3+ parent : Barriers
4+ ---
5+
6+ # ` cuda::barrier::wait_parity ` and ` cuda::barrier::try_wait_parity `
7+
8+ Defined in header ` <cuda/std/barrier> ` :
9+
10+ ``` cuda
11+ __host__ __device__ void cuda::std::barrier::wait_parity(bool phase);
12+ __host__ __device__ bool cuda::std::barrier::try_wait_parity(bool phase);
13+ ```
14+
15+ ` barrier::wait_parity ` stalls execution while the barrier is not at the specified phase.
16+ ` barrier::try_wait_parity ` queries the the state of the barrier against the specified phase.
17+
18+ ## Return Value
19+
20+ ` barrier::try_wait_parity ` returns a boolean representing whether the barrier is at the given phase
21+
22+ <!-- TODO: Create an example when trunk is live on godbolt
23+ ## Example
24+
25+ ```cuda
26+ #include <cuda/barrier>
27+
28+ __global__ void example_kernel(cuda::barrier<cuda::thread_scope_block>& bar) {
29+ bar.wait_parity(false);
30+ }
31+ ```
32+ -->
33+
34+ [ See it on Godbolt] ( https://godbolt.org/z/dr4798Y76 ) {: .btn }
35+
36+
37+ [ `cuda::thread_scope` ] : ./thread_scopes.md
38+
39+ [ thread.barrier.class paragraph 12 ] : https://eel.is/c++draft/thread.barrier.class#12
40+
41+ [ coalesced threads ] : https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#coalesced-group-cg
42+
43+ [ `concurrentManagedAccess` property ] : https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaDeviceProp.html#structcudaDeviceProp_116f9619ccc85e93bc456b8c69c80e78b
44+ [ `hostNativeAtomicSupported` property ] : https://docs.nvidia.com/cuda/cuda-runtime-api/structcudaDeviceProp.html#structcudaDeviceProp_1ef82fd7d1d0413c7d6f33287e5b6306f
45+
You can’t perform that action at this time.
0 commit comments