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__(device_id: int)¶
Initialize the memory resource.
Subclasses may use additional arguments to configure the resource.
- allocate(size: int, stream: Stream = None) Buffer ¶
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(ptr: CUdeviceptr | int | None, size: int, 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