For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /get-started.md).
Mojo struct
AmdCounterBackend
struct AmdCounterBackend[producer_arrivals: Int32, consumer_arrivals: Int32]
PipelineBackend using shared-memory atomic counters.
Mirrors NvidiaMbarBackend's layout: 2 * num_stages Int64 counters as
full[0..num_stages) then empty[0..num_stages). full is bumped by the
producer (consumer waits on it); empty is bumped by the consumer (producer
waits on it). Counters are monotonic; the wait threshold is derived from the
pipeline's monotonic phase — no parity bit.
The arrive counts are compile-time parameters (not fields) because the
pipeline is register-passed and copied per thread: a field written by one
thread in init_barriers would not be visible to other warps. On AMD these
counts are comptime-known anyway (producer warps per slot / consumer warps
per slot).
NOTE: the data-before-signal s_waitcnt lgkmcnt(0) fence is the CALLER's
responsibility — it cannot live here.
Fields
- full (
AmdCounterPtr): - empty (
AmdCounterPtr):
Implemented traits
AnyType,
Copyable,
Deinitable,
ImplicitlyCopyable,
Movable,
PipelineBackend,
RegisterPassable,
TrivialRegisterPassable
comptime members
BarrierStorage
comptime BarrierStorage = Int64
Handle
comptime Handle = AmdCounterPtr
Methods
__init__
def __init__[num_stages: Int](ptr: Pointer[Int64, MutUntrackedOrigin, address_space=AddressSpace.SHARED]) -> Self
storage_elems
init_barriers
def init_barriers[num_stages: Int](self, producer_arrive_count: Int32, consumer_arrive_count: Int32)
wait_full
def wait_full[ticks: Optional[UInt32] = None](self, stage: UInt32, phase: UInt32)
wait_empty
def wait_empty[ticks: Optional[UInt32] = None](self, stage: UInt32, phase: UInt32)
try_full
try_empty
arrive_full
def arrive_full(self, stage: UInt32)
arrive_empty
def arrive_empty(self, stage: UInt32)
full_handle
def full_handle(self, stage: UInt32) -> Self.Handle
Returns:
Self.Handle
empty_handle
def empty_handle(self, stage: UInt32) -> Self.Handle
Returns:
Self.Handle