CudaMemoryBuffer#
- public class CudaMemoryBuffer extends BaseDeviceMemoryBuffer#
This class represents data allocated using
cudaMallocdirectly instead of the default RMM memory resource.Closing this object will effectively release the memory held by the buffer. Note that because of reference counting if a buffer is sliced it may not actually result in the memory being released.
Constructor Summary
CudaMemoryBuffer(long address, long lengthInBytes, Cuda.Stream stream)Wrap an existing CUDA allocation in a device memory buffer.
Method Summary
Allocate memory for use on the GPU.
Allocate memory for use on the GPU.
Slice off a part of the device buffer.
Fields inherited from class
ai.rapids.cudf.MemoryBuffer:address,cleaner,closed,id,length,refCountMethods inherited from class
ai.rapids.cudf.MemoryBuffer:addressOutOfBoundsCheck,close,copyFromMemoryBuffer,copyFromMemoryBufferAsync,getAddress,getEventHandler,getLength,getRefCount,incRefCount,noWarnLeakExpected,setEventHandler,toStringMethods inherited from class
ai.rapids.cudf.BaseDeviceMemoryBuffer:copyFromDeviceBufferAsync,copyFromHostBuffer,copyFromHostBufferAsync,sliceWithCopyConstructors
- public CudaMemoryBuffer(
- long address,
- long lengthInBytes,
- Cuda.Stream stream
Wrap an existing CUDA allocation in a device memory buffer.
The CUDA allocation will be freed when the resulting device memory buffer instance frees its memory resource (i.e.: when its reference count goes to zero).
- Parameters:
address – device address of the CUDA memory allocation
lengthInBytes – length of the CUDA allocation in bytes
stream – CUDA stream to use for synchronization when freeing the allocation
Methods
- public final CudaMemoryBuffer slice(long offset, long len)#
Slice off a part of the device buffer.
Note that this is a zero copy operation and all slices must be closed along with the original buffer before the memory is released to RMM. So use this with some caution.
- Parameters:
offset – where to start the slice at.
len – how many bytes to slice
- Returns:
a device buffer that will need to be closed independently from this buffer.
Static Methods
- public static CudaMemoryBuffer allocate(long bytes)#
Allocate memory for use on the GPU.
You must close it when done.
- Parameters:
bytes – size in bytes to allocate
- Returns:
the buffer
- public static CudaMemoryBuffer allocate(
- long bytes,
- Cuda.Stream stream
Allocate memory for use on the GPU.
You must close it when done.
- Parameters:
bytes – size in bytes to allocate
stream – The stream in which to synchronize this command
- Returns:
the buffer