Mojo struct
SingleCounterSync
@register_passable(trivial)
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 (
SMemArrayType[Int32, SingleCounterSync[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)
SyncCounterArray
comptime SyncCounterArray = SMemArrayType[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!