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

SHMEMBuffer

struct SHMEMBuffer[dtype: DType]

Implemented traits​

AnyType, DevicePassable, ImplicitlyDestructible, Sized

comptime members​

device_type​

comptime device_type = UnsafePointer[Scalar[dtype], MutAnyOrigin]

Methods​

__del__​

__del__(deinit self)

get_type_name​

static get_type_name() -> String

Returns:

String

__len__​

__len__(self) -> Int

Returns:

Int

unsafe_ptr​

unsafe_ptr(self) -> UnsafePointer[Scalar[dtype], MutAnyOrigin]

Returns:

UnsafePointer[Scalar[dtype], MutAnyOrigin]

enqueue_copy_to​

enqueue_copy_to(self, dst_ptr: UnsafePointer[Scalar[dtype], MutAnyOrigin])

Enqueues an asynchronous copy from this buffer to host memory.

This method schedules a memory copy operation from this device buffer to the specified host memory location. The operation is asynchronous and will be executed in the stream associated with this buffer's context.

Args:

enqueue_copy_to(self, dst: HostBuffer[dtype])

Enqueues an asynchronous copy from this buffer to host memory.

This method schedules a memory copy operation from this device buffer to the specified host memory location. The operation is asynchronous and will be executed in the stream associated with this buffer's context.

Args:

Raises:

If the copy operation fails.

enqueue_copy_from​

enqueue_copy_from(self, src_ptr: UnsafePointer[Scalar[dtype], MutAnyOrigin])

Enqueues an asynchronous copy from host memory to this buffer.

This method schedules a memory copy operation from the specified host memory location to this device buffer. The operation is asynchronous and will be executed in the stream associated with this buffer's context.

Args:

Raises:

If the copy operation fails.

enqueue_copy_from(self, src: HostBuffer[dtype])

Enqueues an asynchronous copy from host memory to this buffer.

This method schedules a memory copy operation from the specified host memory location to this device buffer. The operation is asynchronous and will be executed in the stream associated with this buffer's context.

Args:

Raises:

If the copy operation fails.