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

SMemTileArray

struct SMemTileArray[dtype: DType, layout: Layout, num_tiles: Int, alignment: Int]

Array of tiles in shared memory.

Parameters​

  • ​dtype (DType): Tile data type.
  • ​layout (Layout): Tile layout configuration.
  • ​num_tiles (Int): Number of tiles.
  • ​alignment (Int): Memory alignment.

Fields​

  • ​ptr (UnsafePointer[Scalar[dtype], MutUntrackedOrigin, address_space=AddressSpace.SHARED]):

Implemented traits​

AnyType, Copyable, ImplicitlyCopyable, ImplicitlyDeletable, Movable, RegisterPassable, TrivialRegisterPassable

comptime members​

num_elements​

comptime num_elements = (layout.size() * num_tiles)

Storage​

comptime Storage = InlineArray[Scalar[dtype], Int((mul layout.size(), num_tiles))]

storage_size​

comptime storage_size = (Int((mul layout.size(), num_tiles)) * size_of[dtype]())

Tile​

comptime Tile = LayoutTensor[dtype, layout, MutAnyOrigin, address_space=AddressSpace.SHARED, alignment=alignment]

Methods​

__init__​

def __init__(ref[AddressSpace._value] storage: InlineArray[Scalar[dtype], Int((mul layout.size(), num_tiles))]) -> Self

Initialize with Storage.

Args:

def __init__(unsafe_ptr: UnsafePointer[Scalar[dtype], address_space=AddressSpace.SHARED]) -> Self

Initialize with shared memory pointer.

Args:

__getitem__​

def __getitem__[T: Intable](self, index: T) -> Self.Tile

Get tile at index.

Args:

  • ​index (T): Tile index.

Returns:

Self.Tile: Tile at index.

slice​

def slice[length: Int](self, start: Int) -> SMemTileArray[dtype, layout, length, alignment]

Returns:

SMemTileArray[dtype, layout, length, alignment]

stack_allocation​

static def stack_allocation() -> Self