cuda.core.experimental.DeviceMemoryResource#
- class cuda.core.experimental.DeviceMemoryResource(device_id: int)#
Create a device memory resource that uses the driver’s stream-ordered memory pool.
- Parameters:
device_id (int) – Device ordinal for which a memory resource is constructed. The mempool that is set to current on
device_id
is used. If no mempool is set to current yet, the driver would use the default mempool on the device.
Methods
- __init__(self, int device_id: int)#
- allocate(
- self,
- size_t size,
- stream: Stream = None,
Allocate a buffer of the requested size.
- Parameters:
- Returns:
The allocated buffer object, which is accessible on the device that this memory resource was created for.
- Return type:
- deallocate(
- self,
- ptr: DevicePointerT,
- size_t size,
- 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, an internal stream is used.
Attributes