cuda.core.experimental.MemoryResource#
- class cuda.core.experimental.MemoryResource#
Abstract base class for memory resources that manage allocation and deallocation of buffers.
Subclasses must implement methods for allocating and deallocation, as well as properties associated with this memory resource from which all allocated buffers will inherit. (Since all
Bufferinstances allocated and returned by theallocate()method would hold a reference to self, the buffer properties are retrieved simply by looking up the underlying memory resource’s respective property.)Methods
- __init__()#
- abstract allocate(
- self,
- size_t size,
- Stream stream: Stream = None,
Allocate a buffer of the requested size.
- Parameters:
- Returns:
The allocated buffer object, which can be used for device or host operations depending on the resource’s properties.
- Return type:
- abstract deallocate(
- self,
- ptr: DevicePointerT,
- size_t size,
- Stream stream: Stream = None,
Deallocate a buffer previously allocated by this resource.
- Parameters:
ptr (
DevicePointerT) – The pointer or handle to the buffer to deallocate.size (int) – The size of the buffer to deallocate, in bytes.
stream (Stream, optional) – The stream on which to perform the deallocation asynchronously. If None, it is up to each memory resource implementation to decide and document the behavior.