Mojo struct
SplitCounterSync
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 (
SplitCounterSync[pipeline_stages, block_rows, warp_rows, reads_per_warp_block].ProducerCounterArray): - βconsumer_counters (
SplitCounterSync[pipeline_stages, block_rows, warp_rows, reads_per_warp_block].ConsumerCounterArray):
Implemented traitsβ
AnyType,
Copyable,
ImplicitlyCopyable,
ImplicitlyDestructible,
Movable,
RegisterPassable,
SyncStrategy,
TrivialRegisterPassable
comptime membersβ
block_warpsβ
comptime block_warps = (block_rows // warp_rows)
ConsumerCounterArrayβ
comptime ConsumerCounterArray = SMemArray[Int32, SplitCounterSync[pipeline_stages, block_rows, warp_rows, reads_per_warp_block].total_tiles]
ProducerCounterArrayβ
comptime ProducerCounterArray = SMemArray[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!