IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /max/get-started.md). For the complete documentation index, see llms.txt.
Skip to main content
For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /max/get-started.md).

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, ImplicitlyDeletable, 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__​

def __init__() -> Self

Initialize with internally allocated sync counter.

get_staged_idx​

def get_staged_idx(self, tile_idx: Int, stage: Int) -> Int

Returns:

Int

wait_producer_acquire​

def wait_producer_acquire(self, tile_idx: Int, stage: Int, phase: Int32)

signal_producer_release​

def signal_producer_release(mut self, tile_idx: Int, stage: Int)

wait_consumer_acquire​

def wait_consumer_acquire(self, tile_idx: Int, stage: Int, phase: Int32)

signal_consumer_release​

def signal_consumer_release(mut self, tile_idx: Int, stage: Int)

get_producer_phase_increment​

def get_producer_phase_increment(self) -> Int32

Returns:

Int32

get_consumer_phase_increment​

def get_consumer_phase_increment(self) -> Int32

Returns:

Int32