Mojo struct
SplitCounterSync
@register_passable(trivial)
struct SplitCounterSync[pipeline_stages: Int, block_rows: Int, warp_rows: Int, reads_per_warp_block: Int]
Split counter synchronization strategy.
Uses separate producer and consumer counters per tile to reduce atomic contention. Producers only write to producer counters, consumers only write to consumer counters.
Phase progression:
- Producer phase advances by reads_per_warp_block (waits for N consumers)
- Consumer phase advances by writes_per_warp_block (waits for 1 producer)
- This asymmetry reflects the 1-producer-to-N-consumers relationship
Fields
- producer_counters (
SMemArrayType[Int32, SplitCounterSync[pipeline_stages, block_rows, warp_rows, reads_per_warp_block].total_tiles]): - consumer_counters (
SMemArrayType[Int32, SplitCounterSync[pipeline_stages, block_rows, warp_rows, reads_per_warp_block].total_tiles]):
Implemented traits
AnyType,
Copyable,
ImplicitlyCopyable,
Movable,
SyncStrategy,
UnknownDestructibility
Aliases
__copyinit__is_trivial
comptime __copyinit__is_trivial = True
__del__is_trivial
comptime __del__is_trivial = True
__moveinit__is_trivial
comptime __moveinit__is_trivial = True
block_warps
comptime block_warps = (block_rows // warp_rows)
ConsumerCounterArray
comptime ConsumerCounterArray = SMemArrayType[Int32, SplitCounterSync[pipeline_stages, block_rows, warp_rows, reads_per_warp_block].total_tiles]
ProducerCounterArray
comptime ProducerCounterArray = SMemArrayType[Int32, SplitCounterSync[pipeline_stages, block_rows, warp_rows, reads_per_warp_block].total_tiles]
total_tiles
comptime total_tiles = (SplitCounterSync[pipeline_stages, block_rows, warp_rows, reads_per_warp_block].block_warps * pipeline_stages)
writes_per_warp_block
comptime writes_per_warp_block = 1
Methods
__init__
__init__() -> Self
Initialize with internally allocated producer and consumer counters.
get_staged_idx
wait_producer_acquire
wait_producer_acquire(self, tile_idx: Int, stage: Int, phase: Int32)
Producer waits on consumer counter.
signal_producer_release
signal_producer_release(mut self, tile_idx: Int, stage: Int)
Producer increments producer counter.
wait_consumer_acquire
wait_consumer_acquire(self, tile_idx: Int, stage: Int, phase: Int32)
Consumer waits on producer counter.
signal_consumer_release
signal_consumer_release(mut self, tile_idx: Int, stage: Int)
Consumer increments consumer counter by 1.
get_producer_phase_increment
get_producer_phase_increment(self) -> Int32
Producer phase advances by reads_per_warp_block.
Returns:
get_consumer_phase_increment
get_consumer_phase_increment(self) -> Int32
Consumer phase advances by writes_per_warp_block.
Returns:
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!