Mojo struct
SingleCounterSync
struct SingleCounterSync[pipeline_stages: Int, block_rows: Int, warp_rows: Int, reads_per_warp_block: Int]
Single counter synchronization strategy.
Uses one atomic counter per tile that tracks both producer and consumer progress. This is simpler but has higher contention as all warps compete for the same counter.
Phase progression:
- Each phase advances by (writes_per_warp_block + reads_per_warp_block)
- Producers wait for phase N, increment counter by 1
- Consumers wait for phase N+1, increment counter by 1
Fieldsβ
- βsync_counter (
SingleCounterSync[pipeline_stages, block_rows, warp_rows, reads_per_warp_block].SyncCounterArray):
Implemented traitsβ
AnyType,
Copyable,
ImplicitlyCopyable,
ImplicitlyDestructible,
Movable,
RegisterPassable,
SyncStrategy,
TrivialRegisterPassable
comptime membersβ
block_warpsβ
comptime block_warps = (block_rows // warp_rows)
SyncCounterArrayβ
comptime SyncCounterArray = SMemArray[Int32, SingleCounterSync[pipeline_stages, block_rows, warp_rows, reads_per_warp_block].total_tiles]
total_tilesβ
comptime total_tiles = (SingleCounterSync[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 sync counter.
get_staged_idxβ
wait_producer_acquireβ
wait_producer_acquire(self, tile_idx: Int, stage: Int, phase: Int32)
signal_producer_releaseβ
signal_producer_release(mut self, tile_idx: Int, stage: Int)
wait_consumer_acquireβ
wait_consumer_acquire(self, tile_idx: Int, stage: Int, phase: Int32)
signal_consumer_releaseβ
signal_consumer_release(mut self, tile_idx: Int, stage: Int)
get_producer_phase_incrementβ
get_consumer_phase_incrementβ
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!