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
SharedMemoryManager
struct SharedMemoryManager[SMBP: SharedMemoryBasePtr]
Manages bump allocation of tiles and arrays from a shared memory base pointer.
Allocates SMemTile, SMemTileArray, and SMemArray instances by
advancing an offset over a shared memory base pointer provided by the
SMBP parameter.
Parametersβ
- βSMBP (
SharedMemoryBasePtr): Shared memory base pointer provider implementingSharedMemoryBasePtr.
Fieldsβ
- βbase_ptr (
Pointer[Int8, MutUntrackedOrigin, address_space=AddressSpace.SHARED, _safe=False]): - βoffset (
Int):
Implemented traitsβ
comptime membersβ
Arrayβ
comptime Array[type: TrivialRegisterPassable, size: Int] = SMemArray[type, size]
Parametersβ
- βtype (
TrivialRegisterPassable): - βsize (
Int):
Tileβ
comptime Tile[dtype: DType, layout: Layout] = LayoutTensor[dtype, layout, MutAnyOrigin, address_space=AddressSpace.SHARED, alignment=SMBP.alignment]
Parametersβ
TileArrayβ
comptime TileArray[dtype: DType, layout: Layout, num_tiles: Int] = SMemTileArray[dtype, layout, num_tiles, SMBP.alignment]
Parametersβ
Methodsβ
__init__β
def __init__(out self)
Initialize the shared memory manager.
buildβ
def build[dtype: DType, layout: Layout, //, T: AnyStruct[LayoutTensor[dtype, layout, MutAnyOrigin, address_space=AddressSpace.SHARED, alignment=SMBP.alignment]]](mut self) -> T
Allocate a single tile.
Parameters:
- βdtype (
DType): Element type of the allocated tile. - βlayout (
Layout): Memory layout of the allocated tile. - βT (
AnyStruct[LayoutTensor[dtype, layout, MutAnyOrigin, address_space=AddressSpace.SHARED, alignment=SMBP.alignment]]): The allocatedSMemTiletype (inferred).
Returns:
T: Allocated tile.
def build[dtype: DType, layout: Layout, num_tiles: Int, //, T: AnyStruct[SMemTileArray[dtype, layout, num_tiles, SMBP.alignment]]](mut self) -> T
Allocate a tile array.
Parameters:
- βdtype (
DType): Element type of each tile in the array. - βlayout (
Layout): Memory layout of each tile in the array. - βnum_tiles (
Int): Number of tiles in the array. - βT (
AnyStruct[SMemTileArray[dtype, layout, num_tiles, SMBP.alignment]]): The allocatedSMemTileArraytype (inferred).
Returns:
T: Allocated tile array.
def build[type: TrivialRegisterPassable, size: Int, //, T: AnyStruct[SMemArray[type, size]]](mut self) -> T
Allocate a regular array.
Parameters:
- βtype (
TrivialRegisterPassable): Element type stored in the array. - βsize (
Int): Number of elements in the array. - βT (
AnyStruct[SMemArray[type, size]]): The allocatedSMemArraytype (inferred).
Returns:
T: Allocated array.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!