CudaMemPool

Struct CudaMemPool 

Source
pub struct CudaMemPool { /* private fields */ }
Expand description

A CUDA memory caching allocator.

Maintains per-dtype free lists keyed by element count. Reuses buffers when possible, falling back to cudaMalloc on cache miss.

Implementations§

Source§

impl CudaMemPool

Source

pub fn new() -> Self

Create a new empty memory pool.

Source

pub fn alloc_f32( &self, dev: &Arc<CudaDevice>, n: usize, ) -> Result<CudaSlice<f32>, DriverError>

Allocate n elements of type f32, reusing a cached buffer if available. The returned buffer content is undefined (not zeroed).

Source

pub fn alloc_zeros_f32( &self, dev: &Arc<CudaDevice>, n: usize, ) -> Result<CudaSlice<f32>, DriverError>

Allocate n elements of f32 and zero them.

Source

pub fn alloc_f64( &self, dev: &Arc<CudaDevice>, n: usize, ) -> Result<CudaSlice<f64>, DriverError>

Allocate n elements of type f64.

Source

pub fn alloc_zeros_f64( &self, dev: &Arc<CudaDevice>, n: usize, ) -> Result<CudaSlice<f64>, DriverError>

Source

pub fn alloc_u16( &self, dev: &Arc<CudaDevice>, n: usize, ) -> Result<CudaSlice<u16>, DriverError>

Allocate n elements of type u16 (used for F16/BF16 storage).

Source

pub fn alloc_zeros_u16( &self, dev: &Arc<CudaDevice>, n: usize, ) -> Result<CudaSlice<u16>, DriverError>

Source

pub fn alloc_u8( &self, dev: &Arc<CudaDevice>, n: usize, ) -> Result<CudaSlice<u8>, DriverError>

Allocate n elements of type u8.

Source

pub fn alloc_zeros_u8( &self, dev: &Arc<CudaDevice>, n: usize, ) -> Result<CudaSlice<u8>, DriverError>

Source

pub fn alloc_u32( &self, dev: &Arc<CudaDevice>, n: usize, ) -> Result<CudaSlice<u32>, DriverError>

Allocate n elements of type u32.

Source

pub fn alloc_zeros_u32( &self, dev: &Arc<CudaDevice>, n: usize, ) -> Result<CudaSlice<u32>, DriverError>

Source

pub fn alloc_i64( &self, dev: &Arc<CudaDevice>, n: usize, ) -> Result<CudaSlice<i64>, DriverError>

Allocate n elements of type i64.

Source

pub fn alloc_zeros_i64( &self, dev: &Arc<CudaDevice>, n: usize, ) -> Result<CudaSlice<i64>, DriverError>

Source

pub fn reclaim_f32(&self, s: CudaSlice<f32>)

Source

pub fn reclaim_f64(&self, s: CudaSlice<f64>)

Source

pub fn reclaim_u16(&self, s: CudaSlice<u16>)

Source

pub fn reclaim_u8(&self, s: CudaSlice<u8>)

Source

pub fn reclaim_u32(&self, s: CudaSlice<u32>)

Source

pub fn reclaim_i64(&self, s: CudaSlice<i64>)

Source

pub fn reclaim_storage(&self, storage: CudaStorage)

Reclaim all buffers inside a CudaStorage, returning them to the pool.

Source

pub fn empty_cache(&self)

Release all cached buffers back to the CUDA driver. This actually frees GPU memory.

Source

pub fn stats(&self) -> PoolStats

Return a snapshot of pool statistics.

Source

pub fn reset_stats(&self)

Reset hit/miss counters.

Trait Implementations§

Source§

impl Default for CudaMemPool

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Send for CudaMemPool

Source§

impl Sync for CudaMemPool

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> 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, 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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V