Skip to main content

MemoryPool

Struct MemoryPool 

Source
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

Source

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.

Source

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.

Source

pub fn as_raw(&self) -> CUmemoryPool

Raw CUmemoryPool. Use with care.

Source

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).

Source

pub fn release_threshold(&self) -> Result<u64>

Source

pub fn used_bytes(&self) -> Result<u64>

Current bytes handed out to allocations.

Source

pub fn reserved_bytes(&self) -> Result<u64>

Current bytes reserved for the pool (used + free-but-kept).

Source

pub fn trim_to(&self, min_bytes_to_keep: usize) -> Result<()>

Release memory down to min_bytes_to_keep bytes.

Source

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.

Source

pub fn access(&self, device: &Device) -> Result<AccessFlags>

Query device’s access flags for this pool.

Source

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).

Source

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]).

Source

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

Source§

fn clone(&self) -> MemoryPool

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for MemoryPool

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.