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 function

run_producer

def run_producer[dtype: DType, layout: Layout, block_rows: Int, block_cols: Int, warp_rows: Int, warp_cols: Int, producer_warps: Int, pipeline_stages: Int, k_tile_size: Int, simd_width: Int, warps_processed_per_producer: Int, tile_count: Int, swizzle: Optional[Swizzle]](matrix: LayoutTensor[dtype, layout, MutAnyOrigin, address_space=AddressSpace.GLOBAL], mut ring_buffer: RingBuffer, warp_id: Int, block_idx_dim: Int)

Generic producer function for loading matrix tiles from global to shared memory.

Parameters:

  • ​dtype (DType): Element type of the matrix being loaded.
  • ​layout (Layout): Memory layout of the matrix in global memory.
  • ​block_rows (Int): Number of rows in a block tile (BM for matrix A, BN for matrix B).
  • ​block_cols (Int): Number of columns in a block tile (BK).
  • ​warp_rows (Int): Number of rows per warp tile (WM for matrix A, WN for matrix B).
  • ​warp_cols (Int): Number of columns per warp tile (WK).
  • ​producer_warps (Int): Number of warps assigned to producing this matrix.
  • ​pipeline_stages (Int): Number of pipeline stages in the ring buffer used to overlap loads and compute.
  • ​k_tile_size (Int): Width of a single K tile loaded per inner-block row.
  • ​simd_width (Int): SIMD vector width of the matrix element type.
  • ​warps_processed_per_producer (Int): Number of warp tiles each producer warp iterates over.
  • ​tile_count (Int): Total number of K tiles to load along the K dimension.
  • ​swizzle (Optional[Swizzle]): Optional swizzle pattern applied to shared memory to avoid bank conflicts.

Args:

  • ​matrix (LayoutTensor[dtype, layout, MutAnyOrigin, address_space=AddressSpace.GLOBAL]): Global memory tensor of the matrix to load tiles from.
  • ​ring_buffer (RingBuffer): Ring buffer coordinating producer-consumer synchronization across pipeline stages.
  • ​warp_id (Int): Warp identifier of this producer warp within its producer group.
  • ​block_idx_dim (Int): Block index along the matrix's leading dimension, selecting which block of tiles this block loads.

Was this page helpful?