Skip to main content

MemoryPool

Struct MemoryPool 

Source
pub struct MemoryPool { /* private fields */ }

Implementations§

Source§

impl MemoryPool

Source

pub fn create(props: MemoryPoolProps) -> Result<Self>

Creates a CUDA memory pool. props determines the properties of the pool such as the backing device and IPC capabilities.

To create a memory pool for host memory not targeting a specific NUMA node, applications must set MemoryPoolProps::location to MemoryLocationKind::Host. MemoryLocation::id is ignored for such pools. Pools created with MemoryLocationKind::Host are not IPC-capable and MemoryPoolProps::handle_type must be MemoryAllocationHandleType::None; any other value returns crate::error::Status::InvalidValue. To create a memory pool targeting a specific host NUMA node, applications must set MemoryLocation::kind to MemoryLocationKind::Numa and MemoryLocation::id must specify the NUMA ID of the host memory node. Specifying MemoryLocationKind::NumaCurrent as MemoryLocation::kind returns crate::error::Status::InvalidValue. By default, the pool’s memory is accessible from the device where it is allocated. Pools created with MemoryLocationKind::Numa or MemoryLocationKind::Host are accessible from the host CPU by default. Applications can control the maximum size of the pool by specifying a non-zero value for MemoryPoolProps::max_size. A value of 0 uses a system-dependent maximum pool size.

Callers that intend to use MemoryAllocationHandleType::Fabric based memory sharing must ensure: (1) the nvidia-caps-imex-channels character device is created by the driver and is listed under /proc/devices; (2) at least one IMEX channel file is accessible to the process.

When exporter and importer CUDA processes have been granted access to the same IMEX channel, they can securely share memory.

The IMEX channel security model works per operating-system account. All processes for an account can share memory if that account has access to a valid IMEX channel. When isolation between accounts is desired, each account needs a separate IMEX channel.

These channel files exist in /dev/nvidia-caps-imex-channels/channel* and can be created using standard OS native calls like mknod on Linux.

To create a managed memory pool, applications must set MemoryPoolProps::alloc_type to MemoryAllocationType::Managed. MemoryPoolProps::handle_type must also be MemoryAllocationHandleType::None because IPC is not supported. For managed memory pools, MemoryPoolProps::location is treated as the preferred location for all allocations created from the pool. An application can also set MemoryLocationKind::Invalid to indicate no preferred location. MemoryPoolProps::max_size must be set to zero for managed memory pools. MemoryPoolProps::usage must be zero because decompression for managed memory is not supported. For managed memory pools, all devices on the system must have non-zero concurrentManagedAccess. If not, this call returns crate::error::Status::NotSupported.

Specifying MemoryAllocationHandleType::None creates a memory pool that does not support IPC.

§Errors

Returns an error if props describes an unsupported pool, CUDA cannot create the pool, or CUDA returns a null memory-pool handle.

Source

pub fn set_attribute( &mut self, attribute: MemoryPoolAttribute, value: MemoryPoolAttributeValue, ) -> Result<()>

Supported attributes are:

Source

pub fn attribute( &self, attribute: MemoryPoolAttribute, ) -> Result<MemoryPoolAttributeValue>

Supported attributes are:

§Errors

Returns an error if CUDA Driver cannot report the requested pool attribute.

Source

pub fn set_access( &mut self, access_descs: &[MemoryAccessDescriptor], ) -> Result<()>

Controls visibility of pools between devices.

§Errors

Returns an error if CUDA Driver rejects the access descriptors.

Source

pub fn access(&self, location: MemoryLocation) -> Result<MemoryAccessFlag>

Returns the accessibility of the pool’s memory from the specified location.

§Errors

Returns an error if CUDA Driver cannot report access from location.

Source

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

Releases memory back to the OS until the pool contains fewer than min_bytes_to_keep reserved bytes, or there is no more memory that the allocator can safely release. The allocator cannot release OS allocations that back outstanding asynchronous allocations. The OS allocations may happen at different granularity from the caller’s allocations.

  • Allocations that have not been freed count as outstanding.
  • Allocations that have been asynchronously freed but whose completion has not been observed on the host, for example by synchronization, can count as outstanding.
§Errors

Returns an error if CUDA cannot trim the pool.

Source

pub const fn as_raw(&self) -> CUmemoryPool

Trait Implementations§

Source§

impl Debug for MemoryPool

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Drop for MemoryPool

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. 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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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.