pub struct MemoryPool { /* private fields */ }Expand description
A CUDA memory pool. Dropping the handle calls cuMemPoolDestroy (the
default per-device pool is not owned by this type — see default_pool
vs MemoryPool::new).
Implementations§
Source§impl MemoryPool
impl MemoryPool
Sourcepub fn new(context: &Context, device: &Device) -> Result<Self>
pub fn new(context: &Context, device: &Device) -> Result<Self>
Create a fresh pool whose backing memory lives on device. The pool
is destroyed when the last MemoryPool clone drops.
Sourcepub unsafe fn from_borrowed(context: &Context, handle: CUmemoryPool) -> Self
pub unsafe fn from_borrowed(context: &Context, handle: CUmemoryPool) -> Self
Wrap a raw pool handle without taking ownership. Drop is a no-op.
§Safety
handle must be a valid CUmemoryPool. The caller guarantees it
outlives this wrapper.
Sourcepub fn as_raw(&self) -> CUmemoryPool
pub fn as_raw(&self) -> CUmemoryPool
Raw CUmemoryPool. Use with care.
Sourcepub fn set_release_threshold(&self, bytes: u64) -> Result<()>
pub fn set_release_threshold(&self, bytes: u64) -> Result<()>
u64 release threshold — bytes above which the pool starts returning
memory to the OS. Default is 0 (aggressive release).
pub fn release_threshold(&self) -> Result<u64>
Sourcepub fn used_bytes(&self) -> Result<u64>
pub fn used_bytes(&self) -> Result<u64>
Current bytes handed out to allocations.
Sourcepub fn reserved_bytes(&self) -> Result<u64>
pub fn reserved_bytes(&self) -> Result<u64>
Current bytes reserved for the pool (used + free-but-kept).
Sourcepub fn trim_to(&self, min_bytes_to_keep: usize) -> Result<()>
pub fn trim_to(&self, min_bytes_to_keep: usize) -> Result<()>
Release memory down to min_bytes_to_keep bytes.
Sourcepub fn set_access(&self, device: &Device, flags: AccessFlags) -> Result<()>
pub fn set_access(&self, device: &Device, flags: AccessFlags) -> Result<()>
Grant device the specified access to allocations from this pool.
Required for peer-access patterns.
Sourcepub fn access(&self, device: &Device) -> Result<AccessFlags>
pub fn access(&self, device: &Device) -> Result<AccessFlags>
Query device’s access flags for this pool.
Sourcepub fn alloc_async(&self, bytes: usize, stream: &Stream) -> Result<CUdeviceptr>
pub fn alloc_async(&self, bytes: usize, stream: &Stream) -> Result<CUdeviceptr>
Allocate bytes bytes of device memory from this pool, ordered on
stream. Free via crate::DeviceBuffer::free_async or by letting
the returned buffer drop (sync free).
Sourcepub fn export_pointer(&self, ptr: CUdeviceptr) -> Result<CUmemPoolPtrExportData>
pub fn export_pointer(&self, ptr: CUdeviceptr) -> Result<CUmemPoolPtrExportData>
Export an opaque blob that a peer process can import via
MemoryPool::import_pointer. Both ends must share the same pool
via its shareable-handle mechanism first (see
[MemoryPool::export_to_shareable_handle]).
Sourcepub fn import_pointer(
&self,
data: CUmemPoolPtrExportData,
) -> Result<CUdeviceptr>
pub fn import_pointer( &self, data: CUmemPoolPtrExportData, ) -> Result<CUdeviceptr>
Inverse of MemoryPool::export_pointer: resolve the exported blob
to a device pointer valid in the importing process.
Trait Implementations§
Source§impl Clone for MemoryPool
impl Clone for MemoryPool
Source§fn clone(&self) -> MemoryPool
fn clone(&self) -> MemoryPool
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more