Skip to main content

Mojo trait

DeviceBuffer

Implemented traits

AnyType

Methods

copy_to

copy_to(self: _Self, dev: Device, name: Optional[String]) -> _Self

Copies the contents of self into DeviceBuffer allocated on dev. Note: this function allocates memory on dev.

Args:

  • dev (Device): The Device on which to allocate the new DeviceBuffer.
  • name (Optional[String]): Optional name of the new DeviceBuffer.

Returns:

Newly allocated DeviceBuffer containing a copy of self's contents.

Raises:

If the DeviceBuffer is backed by the same Device object as dev.

copy_into

copy_into(self: _Self, inout dst_memory: _Self)

Copies the contents of self into a preallocated DeviceBuffer.

Args:

  • dst_memory (_Self): The destination DeviceBuffer of the copy.

move_to

move_to(owned self: _Self, dev: Device) -> _Self

Returns self if already allocated on dev, otherwise copy the contents of self to dev.

Args:

  • dev (Device): The Device of the returned buffer.

Returns:

A DeviceBuffer located in dev's address space.

unsafe_ptr

unsafe_ptr(self: _Self) -> UnsafePointer[SIMD[uint8, 1]]

Returns a pointer to the DeviceBuffer's storage in device memory.

device

device(self: _Self) -> Device

Returns the Device on which the DeviceBuffer was allocated.

bytecount

bytecount(self: _Self) -> Int

Returns the size of the DeviceBuffer in bytes.