For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /max/get-started.md).
Mojo trait
PipelineBackend
Hardware backend for ProducerConsumerPipeline slot signaling.
A backend owns the per-slot full/empty signal storage and implements the
four primitive operations the pipeline needs: wait on a signal, raise a
signal, and their non-blocking try_* variants. It also exposes a per-slot
Handle that callers use for substrate-specific extras (for example, setting
the expected TMA transaction size on NVIDIA).
Conforming types must be TrivialRegisterPassable so the pipeline stays a
register-passed value, matching every existing call site.
Implemented traitsβ
AnyType,
Copyable,
ImplicitlyCopyable,
ImplicitlyDeletable,
Movable,
RegisterPassable,
TrivialRegisterPassable
comptime membersβ
BarrierStorageβ
comptime BarrierStorage
Handleβ
comptime Handle
Required methodsβ
__init__β
def __init__[num_stages: Int](ptr: Pointer[Self.BarrierStorage, MutUntrackedOrigin, address_space=AddressSpace.SHARED, _safe=False]) -> Self
Construct from the base pointer of the backing storage array.
Parameters:
- βnum_stages (
Int): The number of pipeline stages (ring depth). Must matchSelf.num_stages.
Args:
- βptr (
Pointer[_Self.BarrierStorage, MutUntrackedOrigin, address_space=AddressSpace.SHARED, _safe=False]): Pointer to the first ofstorage_elems(num_stages)elements.
Returns:
_Self
def __init__(out self, *, copy: Self)
Create a new instance of the value by copying an existing one.
Args:
- βcopy (
_Self): The value to copy.
Returns:
_Self
def __init__(out self, *, deinit move: Self)
Create a new instance of the value by moving the value of another.
Args:
- βmove (
_Self): The value to move.
Returns:
_Self
storage_elemsβ
static def storage_elems[num_stages: Int]() -> Int
Return the number of BarrierStorage elements to reserve in SMEM.
Parameters:
- βnum_stages (
Int): The number of pipeline stages. Must matchSelf.num_stages.
Returns:
Int: The element count for the backing shared-memory array.
init_barriersβ
def init_barriers[num_stages: Int](self, producer_arrive_count: Int32, consumer_arrive_count: Int32)
Initialize all full/empty signals for the ring.
Must be called by a single thread before the pipeline is used.
Parameters:
- βnum_stages (
Int): The number of pipeline stages (ring depth). Must matchSelf.num_stages.
Args:
wait_fullβ
def wait_full[ticks: Optional[UInt32] = None](self, stage: UInt32, phase: UInt32)
Block until the producer has filled stage on the given lap.
Parameters:
- βticks (
Optional[UInt32]): Optional hardware-suspend ceiling (ns). Honored by backends whose hardware supports it (NVIDIA); ignored otherwise.
Args:
wait_emptyβ
def wait_empty[ticks: Optional[UInt32] = None](self, stage: UInt32, phase: UInt32)
Block until the consumer has drained stage on the given lap.
Parameters:
- βticks (
Optional[UInt32]): Optional hardware-suspend ceiling (ns). Honored by backends whose hardware supports it (NVIDIA); ignored otherwise.
Args:
try_fullβ
def try_full(self, stage: UInt32, phase: UInt32) -> Bool
Return whether the producer has filled stage (non-blocking).
Args:
- βstage (
UInt32): The slot index in the ring. - βphase (
UInt32): The monotonic lap number for this slot.
Returns:
Bool: True if the slot is full for this lap, False otherwise.
try_emptyβ
def try_empty(self, stage: UInt32, phase: UInt32) -> Bool
Return whether the consumer has drained stage (non-blocking).
Args:
- βstage (
UInt32): The slot index in the ring. - βphase (
UInt32): The monotonic lap number for this slot.
Returns:
Bool: True if the slot is empty for this lap, False otherwise.
arrive_fullβ
def arrive_full(self, stage: UInt32)
Raise the full signal for stage (producer side).
Args:
- βstage (
UInt32): The slot index in the ring.
arrive_emptyβ
def arrive_empty(self, stage: UInt32)
Raise the empty signal for stage (consumer side).
Args:
- βstage (
UInt32): The slot index in the ring.
full_handleβ
def full_handle(self, stage: UInt32) -> Self.Handle
Return the full signal handle for stage.
Args:
- βstage (
UInt32): The slot index in the ring.
Returns:
_Self.Handle: The backend-specific handle to the slot's full signal.
empty_handleβ
def empty_handle(self, stage: UInt32) -> Self.Handle
Return the empty signal handle for stage.
Args:
- βstage (
UInt32): The slot index in the ring.
Returns:
_Self.Handle: The backend-specific handle to the slot's empty signal.
Provided methodsβ
copyβ
def copy(self) -> Self
Explicitly construct a copy of self, a convenience method for Self(copy=self) when the type is inconvenient to write out.
Overriding this method is not allowed.
Returns:
_Self: A copy of this value.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!