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 module

smem_types

Shared memory type aliases for LayoutTensor-based GPU kernels.

This module defines the core SMEM type aliases used across SM90, SM100, and other GPU kernel implementations. They depend only on layout and stdlib, making them safe to import without pulling in higher-level kernel packages.

Types:

  • SMemTile: Shared memory tile (LayoutTensor alias)
  • RegTile: Register tile (LayoutTensor alias)
  • SMemBarrier: Pointer to shared memory barrier
  • PipelineBarrier: Array of pipeline barriers
  • SMemTileIter: Iterator over shared memory tiles
  • SMemTileArray: Array of shared memory tiles
  • SMemArray: Generic shared memory array
  • SMemPtr: Typed pointer into shared memory
  • eval: Compile-time expression evaluator

comptime values​

eval​

comptime eval[T: AnyType, //, val: T] = val

Helper alias to force evaluation of expressions at compile time.

Parameters​

  • ​T (AnyType):
  • ​val (T):

PipelineBarrier​

comptime PipelineBarrier[num_pipeline_stages: Int] = SMemArray[SharedMemBarrier, num_pipeline_stages]

Type alias for shared memory pipeline barrier array.

Parameters​

  • ​num_pipeline_stages (Int):

RegTile​

comptime RegTile[_dtype: DType, layout: Layout, /, *, element_layout: Layout = Layout(IntTuple(1), IntTuple(1)), layout_int_type: DType = _get_layout_type(layout, AddressSpace.LOCAL), linear_idx_type: DType = _get_index_type(layout, AddressSpace.LOCAL), masked: Bool = False, alignment: Int = align_of[_dtype]()] = LayoutTensor[_dtype, layout, MutAnyOrigin, address_space=AddressSpace.LOCAL, element_layout=element_layout, layout_int_type=layout_int_type, linear_idx_type=linear_idx_type, masked=masked, alignment=alignment]

Type alias for register (local memory) tile tensors.

Parameters​

  • ​_dtype (DType):
  • ​layout (Layout):
  • ​element_layout (Layout):
  • ​layout_int_type (DType):
  • ​linear_idx_type (DType):
  • ​masked (Bool):
  • ​alignment (Int):

SMemBarrier​

comptime SMemBarrier = UnsafePointer[SharedMemBarrier, MutAnyOrigin, address_space=AddressSpace.SHARED]

Type alias for shared memory barrier pointer.

SMemPtr​

comptime SMemPtr[type: AnyType] = UnsafePointer[type, MutAnyOrigin, address_space=AddressSpace.SHARED]

Parameters​

SMemTile​

comptime SMemTile[_dtype: DType, layout: Layout, /, *, element_layout: Layout = Layout(IntTuple(1), IntTuple(1)), layout_int_type: DType = _get_layout_type(layout, AddressSpace.SHARED), linear_idx_type: DType = _get_index_type(layout, AddressSpace.SHARED), masked: Bool = False, alignment: Int = align_of[_dtype]()] = LayoutTensor[_dtype, layout, MutAnyOrigin, address_space=AddressSpace.SHARED, element_layout=element_layout, layout_int_type=layout_int_type, linear_idx_type=linear_idx_type, masked=masked, alignment=alignment]

Type alias for shared memory tile tensors.

Parameters​

  • ​_dtype (DType):
  • ​layout (Layout):
  • ​element_layout (Layout):
  • ​layout_int_type (DType):
  • ​linear_idx_type (DType):
  • ​masked (Bool):
  • ​alignment (Int):

SMemTileIter​

comptime SMemTileIter[dtype: DType, layout: Layout] = LayoutTensorIter[dtype, layout, MutAnyOrigin, address_space=AddressSpace.SHARED, alignment=128]

Parameters​

Structs​