IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /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. /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, Deinitable, ImplicitlyCopyable, Movable, RegisterPassable, TrivialRegisterPassable

comptime members

ptr_type

comptime ptr_type = Pointer[type, MutUntrackedOrigin, address_space=AddressSpace.SHARED]

Storage

comptime Storage = Array[type, size]

storage_size

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

Methods

__init__

def __init__(unsafe_ptr: Pointer[type, MutUntrackedOrigin, address_space=AddressSpace.SHARED]) -> Self

Initialize with shared memory pointer.

Args:

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

Initialize from Storage.

__getitem__

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

Get a pointer to the element at index.

Args:

  • index (T): Element index.

Returns:

Self.ptr_type: Pointer to element.

len

static def len() -> Int

Get array length in bytes.

Returns:

Int: Total size in bytes.

stack_allocation

static def stack_allocation[alignment: Int = Int((get_alignof type, _current_target()))]() -> Self