pub struct IpcMemoryHandle(/* private fields */);Expand description
An opaque CUDA IPC memory export token that can be copied between processes.
This token does not retain the exporting allocation or an imported mapping.
Implementations§
Source§impl IpcMemoryHandle
impl IpcMemoryHandle
Sourcepub const unsafe fn from_raw(handle: cudaIpcMemHandle_t) -> Self
pub const unsafe fn from_raw(handle: cudaIpcMemHandle_t) -> Self
Wraps an exported native IPC memory token without opening a mapping.
§Safety
Any subsequent mapping must use an unchanged token exported by CUDA for a live IPC-capable allocation. Keep that allocation live until every imported mapping has been closed and prevent conflicting accesses across processes.
Sourcepub const fn zeroed() -> Self
pub const fn zeroed() -> Self
Creates a zero-filled placeholder token.
The result does not identify an exported memory resource.
Sourcepub const fn as_raw(&self) -> cudaIpcMemHandle_t
pub const fn as_raw(&self) -> cudaIpcMemHandle_t
Returns a copy of the native IPC memory token without importing or retaining its resource.
Sourcepub fn create_mapping<T>(
self,
flags: IpcMemoryFlags,
) -> Result<OpenedIpcMemory<T>>
pub fn create_mapping<T>( self, flags: IpcMemoryFlags, ) -> Result<OpenedIpcMemory<T>>
Maps memory exported from another process with DeviceMemory::ipc_handle into the current device address space.
For contexts on different devices, IpcMemoryHandle::create_mapping can attempt to enable peer access between the devices as if Context::enable_peer_access had been called.
This behavior is controlled by IpcMemoryFlags::LAZY_ENABLE_PEER_ACCESS.
Device::can_access_peer can determine if a mapping is possible.
IpcMemoryHandle::create_mapping can open handles to devices that may not be visible in the current process.
Imported memory handles from each device in a given process may only be opened by one context per device per other process.
If the memory handle has already been opened by the current context, the reference count on the handle is incremented by 1 and the existing device pointer is returned.
Memory returned from IpcMemoryHandle::create_mapping must be freed with OpenedIpcMemory::close.
Calling DeviceMemory::free on an exported memory region before calling OpenedIpcMemory::close in the importing context results in undefined behavior.
IPC is restricted to devices with support for unified addressing on Linux and Windows operating systems.
IPC on Windows is supported for compatibility, but is not recommended because it has a performance cost.
Check device IPC support through the device properties exposed by this crate, for example DeviceProperties::ipc_event_supported.
Additional CUDA diagnostics:
- This call may also return
crate::error::Status::NotInitialized,crate::error::Status::CallRequiresNewerDriver, orcrate::error::Status::NoDeviceif it initializes internal CUDA runtime state. - Callbacks must not call CUDA functions; see
Stream::add_callback.crate::error::Status::NotPermittedmay, but is not guaranteed to, be returned as a diagnostic in that case. - No guarantees are made about the address returned. In particular, multiple processes may not receive the same address for the same handle.
§Errors
Returns an error if CUDA Runtime cannot open the IPC handle, if the current device cannot access the allocation, or if CUDA returns a null mapped pointer.
Trait Implementations§
Source§impl Clone for IpcMemoryHandle
impl Clone for IpcMemoryHandle
impl Copy for IpcMemoryHandle
Source§impl Debug for IpcMemoryHandle
impl Debug for IpcMemoryHandle
impl Eq for IpcMemoryHandle
Source§impl Hash for IpcMemoryHandle
impl Hash for IpcMemoryHandle
Source§impl PartialEq for IpcMemoryHandle
impl PartialEq for IpcMemoryHandle
impl StructuralPartialEq for IpcMemoryHandle
Auto Trait Implementations§
impl Forget for IpcMemoryHandle
impl Freeze for IpcMemoryHandle
impl Move for IpcMemoryHandle
impl RefUnwindSafe for IpcMemoryHandle
impl Send for IpcMemoryHandle
impl Sync for IpcMemoryHandle
impl Unpin for IpcMemoryHandle
impl UnsafeUnpin for IpcMemoryHandle
impl UnwindSafe for IpcMemoryHandle
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.