cuda.core.experimental._memory.Buffer¶
- class cuda.core.experimental._memory.Buffer(ptr, size, mr: MemoryResource = None)¶
Represent a handle to allocated memory.
This generic object provides a unified representation for how different memory resources are to give access to their memory allocations.
Support for data interchange mechanisms are provided by establishing both the DLPack and the Python-level buffer protocols.
- Parameters:
ptr (Any) – Allocated buffer handle object
size (Any) – Memory size of the buffer
mr (
MemoryResource
, optional) – Memory resource associated with the buffer
Methods
- __init__(ptr, size, mr: MemoryResource = None)¶
- close(stream=None)¶
Deallocate this buffer asynchronously on the given stream.
This buffer is released back to their memory resource asynchronously on the given stream.
- Parameters:
stream (Any, optional) – The stream object with a __cuda_stream__ protocol to use for asynchronous deallocation. Defaults to using the default stream.
- copy_from(src: Buffer, *, stream)¶
Copy from the src buffer to this buffer asynchronously on the given stream.
- Parameters:
src (
Buffer
) – Source buffer to copy data fromstream (Any) – Keyword argument specifying the stream for the asynchronous copy
- copy_to(dst: Buffer = None, *, stream) Buffer ¶
Copy from this buffer to the dst buffer asynchronously on the given stream.
Copies the data from this buffer to the provided dst buffer. If the dst buffer is not provided, then a new buffer is first allocated using the associated memory resource before the copy.
- Parameters:
dst (
Buffer
) – Source buffer to copy data fromstream (Any) – Keyword argument specifying the stream for the asynchronous copy
Attributes
- device_id¶
Return the device ordinal of this buffer.
- handle¶
Return the buffer handle object.
- is_device_accessible¶
Return True if this buffer can be accessed by the GPU, otherwise False.
- is_host_accessible¶
Return True if this buffer can be accessed by the CPU, otherwise False.
- memory_resource¶
Return the memory resource associated with this buffer.
- size¶
Return the memory size of this buffer.