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

SMemArray

struct SMemArray[type: TrivialRegisterPassable, size: Int]

Shared memory array of fixed size.

Parameters​

Fields​

  • ​ptr (SMemArray[type, size].ptr_type):

Implemented traits​

AnyType, Copyable, ImplicitlyCopyable, ImplicitlyDestructible, Movable, RegisterPassable, TrivialRegisterPassable

comptime members​

ptr_type​

comptime ptr_type = UnsafePointer[type, MutAnyOrigin, address_space=AddressSpace.SHARED]

Storage​

comptime Storage = InlineArray[type, size]

storage_size​

comptime storage_size = (size * size_of[type]())

Methods​

__init__​

__init__(unsafe_ptr: UnsafePointer[type, MutAnyOrigin, address_space=AddressSpace.SHARED]) -> Self

Initialize with shared memory pointer.

Args:

__init__(ref[AddressSpace._value] storage: InlineArray[type, size]) -> Self

Initialize from Storage.

__getitem__​

__getitem__[T: Intable](self, index: T) -> SMemArray[type, size].ptr_type

Get a pointer to the element at index.

Args:

  • ​index (T): Element index.

Returns:

SMemArray[type, size].ptr_type: Pointer to element.

len​

static len() -> Int

Get array length in bytes.

Returns:

Int: Total size in bytes.

stack_allocation​

static stack_allocation[alignment: Int = align_of[type]()]() -> Self