pub struct MemoryPool { /* private fields */ }Expand description
A memory pool. Owned pools are destroyed on last-clone drop; borrowed
pools (returned by default_pool / current_pool) are not.
Implementations§
Source§impl MemoryPool
impl MemoryPool
Sourcepub unsafe fn from_borrowed(handle: cudaMemPool_t) -> Self
pub unsafe fn from_borrowed(handle: cudaMemPool_t) -> Self
pub fn as_raw(&self) -> cudaMemPool_t
Sourcepub fn set_release_threshold(&self, bytes: u64) -> Result<()>
pub fn set_release_threshold(&self, bytes: u64) -> Result<()>
Set the release threshold (bytes retained before the pool starts returning memory to the OS). Default is 0.
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 + kept-free).
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.
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.
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<*mut c_void>
pub fn alloc_async(&self, bytes: usize, stream: &Stream) -> Result<*mut c_void>
Allocate bytes bytes of device memory from this pool, ordered on
stream. Returns a raw device pointer — free via
crate::DeviceBuffer::free_async or by calling
Self::free_async on the raw pointer.
Sourcepub unsafe fn free_async(&self, ptr: *mut c_void, stream: &Stream) -> Result<()>
pub unsafe fn free_async(&self, ptr: *mut c_void, stream: &Stream) -> Result<()>
Free a device pointer previously returned by
Self::alloc_async (routes through cudaFreeAsync).
§Safety
ptr must be a live allocation from this (or another) pool.
Sourcepub unsafe fn export_pointer(
&self,
ptr: *mut c_void,
) -> Result<cudaMemPoolPtrExportData>
pub unsafe fn export_pointer( &self, ptr: *mut c_void, ) -> Result<cudaMemPoolPtrExportData>
Export a pointer in this pool for sharing with a peer process.
§Safety
ptr must be a live allocation from this pool.
Sourcepub fn import_pointer(
&self,
data: cudaMemPoolPtrExportData,
) -> Result<*mut c_void>
pub fn import_pointer( &self, data: cudaMemPoolPtrExportData, ) -> Result<*mut c_void>
Import an exported pointer into this pool.
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