dpctl.memory.MemoryUSMDevice

class dpctl.memory.MemoryUSMDevice(nbytes, alignment=0, queue=None, copy=False)

allocates nbytes of USM device memory.

Non-positive alignments are not used (malloc_device is used instead). For the queue=None case the dpctl.SyclQueue() is used to allocate memory.

MemoryUSMDevice(usm_obj) constructor create instance from usm_obj expected to implement __sycl_usm_array_interface__ protocol and exposing a contiguous block of USM device allocation. Use copy=True to perform a copy if USM type of the allocation represented by the argument is other than ‘device’.

Attributes:

nbytes

Extent of this USM buffer in bytes.

reference_obj

Reference to the Python object owning this USM buffer.

size

Extent of this USM buffer in bytes.

sycl_context

dpctl.SyclContext the USM pointer is bound to.

sycl_device

dpctl.SyclDevice the USM pointer is bound to.

sycl_queue

dpctl.SyclQueue with dpctl.SyclContext the USM allocation is bound to and dpctl.SyclDevice it was allocated on.

Public methods:

copy_from_device

Copy SYCL memory underlying the argument object into the memory of the instance

copy_from_host

Copy content of Python buffer provided by obj to instance memory.

copy_to_host

Copy content of instance's memory into memory of obj, or allocate NumPy array of obj is None.

get_usm_type([syclobj])

Returns the type of USM allocation using Sycl context carried by syclobj keyword argument.

memset

Populates this USM allocation with given value.

tobytes

Constructs bytes object populated with copy of USM memory.

Attributes

MemoryUSMDevice._context

dpctl.SyclContext the USM pointer is bound to.

MemoryUSMDevice._pointer

USM pointer at the start of this buffer represented in Python integer.

MemoryUSMDevice._queue

dpctl.SyclQueue with dpctl.SyclContext the USM allocation is bound to and dpctl.SyclDevice it was allocated on.

MemoryUSMDevice.nbytes

Extent of this USM buffer in bytes.

MemoryUSMDevice.reference_obj

Reference to the Python object owning this USM buffer.

MemoryUSMDevice.size

Extent of this USM buffer in bytes.

MemoryUSMDevice.sycl_context

dpctl.SyclContext the USM pointer is bound to.

MemoryUSMDevice.sycl_device

dpctl.SyclDevice the USM pointer is bound to.

MemoryUSMDevice.sycl_queue

dpctl.SyclQueue with dpctl.SyclContext the USM allocation is bound to and dpctl.SyclDevice it was allocated on.

Public methods

dpctl.memory.MemoryUSMDevice.copy_from_device()

Copy SYCL memory underlying the argument object into the memory of the instance

dpctl.memory.MemoryUSMDevice.copy_from_host()

Copy content of Python buffer provided by obj to instance memory.

dpctl.memory.MemoryUSMDevice.copy_to_host()

Copy content of instance’s memory into memory of obj, or allocate NumPy array of obj is None.

dpctl.memory.MemoryUSMDevice.get_usm_type(syclobj=None)

Returns the type of USM allocation using Sycl context carried by syclobj keyword argument. Value of None is understood to query against self.sycl_context - the context used to create the allocation.

dpctl.memory.MemoryUSMDevice.memset()

Populates this USM allocation with given value.

dpctl.memory.MemoryUSMDevice.tobytes()

Constructs bytes object populated with copy of USM memory.