Skip to content

Commit 686ccb3

Browse files
authored
Improve signal/wait doc (#478)
1 parent 4e2f2c9 commit 686ccb3

File tree

3 files changed

+28
-6
lines changed

3 files changed

+28
-6
lines changed

docs/api/index.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ runtime
7171
load
7272
store
7373
atomic_add
74+
signal
75+
wait
76+
stacktensor_like
7477
zeros
7578
full
7679
arange

docs/api/language.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,18 @@ See {func}`~helion.language.cumprod` for details.
186186

187187
## Synchronization
188188

189+
190+
### signal()
191+
192+
```{eval-rst}
193+
.. autofunction:: signal
194+
```
195+
189196
### wait()
190197

191-
See {func}`~helion.language.wait` for details.
198+
```{eval-rst}
199+
.. autofunction:: wait
200+
```
192201

193202
## Utilities
194203

helion/language/signal_wait.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,13 @@ def wait(
2929
scope: str = "gpu",
3030
hasSubsequentMemAccess: bool = True,
3131
) -> None:
32-
"""Wait until all entries of the signal_pad slice are equal to the signal value.
32+
"""
33+
Wait for global memory barriers.
34+
35+
Spins on global memory barriers until the signal values is observed on all barriers.
36+
3337
Args:
34-
signal_pad: The signal pad tensor / stack tensor to wait on
38+
signal_pad: Tensor of global memory barriers to wait on
3539
index: Indices to index into the signal_pad tensor
3640
signal: the value to wait for
3741
update: Atomically update the signal_pad tensor with this value once the signal is observed. (default: None)
@@ -179,16 +183,22 @@ def signal(
179183
scope: str = "gpu",
180184
hasPreviousMemAccess: bool = True,
181185
) -> torch.Tensor:
182-
"""Set the signal_pad slice to the signal value.
186+
"""
187+
Set global memory barriers.
188+
189+
Sets global memory barriers to the specified value.
190+
If wait_for is not None, it waits for the barriers to be cleared before setting.
191+
183192
Args:
184-
signal_pad: The signal pad tensor / stack tensor to signal
193+
signal_pad: Tensor of global memory barriers to set
185194
index: Indices to index into the signal_pad tensor
186195
signal: the value to send
187196
wait_for: The value to wait for before sending the signal.
188197
scope: The scope of the lock (default: 'gpu')
189198
hasPreviousMemAccess: Whether the signal is preceded by a memory access (default: True)
199+
190200
Returns:
191-
The old value of the signal_pad slice before the update.
201+
The old value of the global memory barriers before the update.
192202
"""
193203
raise exc.NotInsideKernel
194204

0 commit comments

Comments
 (0)