Mojo struct
Signal
@register_passable(trivial)
struct Signal[max_num_blocks: Int]
A synchronization primitive for coordinating GPU thread blocks across multiple devices.
This struct provides counter-based synchronization between thread blocks on different GPUs. It maintains two sets of counters:
- self_counter: Used by blocks on the current GPU to signal their progress
- peer_counter: Used to track progress of blocks on other GPUs
Note: The counters use unsigned integers that may overflow, but this is safe since unsigned integer overflow has well-defined behavior.
Parameters
- max_num_blocks (
Int
): The maximum number of thread blocks that will synchronize.
Fields
- self_counter (
StaticTuple[StaticTuple[SIMD[uint32, 1], 8], max_num_blocks]
): A 3D array of counters with shape (2, max_num_blocks, MAX_GPUS). Contains two sets of counters to handle two synchronization points safely. The dual counter design prevents race conditions where a peer block arrives at the second sync point before the current block passes the first sync point. - peer_counter (
StaticTuple[StaticTuple[StaticTuple[SIMD[uint32, 1], 8], max_num_blocks], 2]
):
Implemented traits
AnyType
,
Copyable
,
ExplicitlyCopyable
,
Movable
,
UnknownDestructibility
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!