pub struct GpuMappedBuffer<'a> { /* private fields */ }Expand description
GPU-visible memory region that io_uring is allowed to DMA into.
Compatibility constructors cover host-visible shared mappings. The BAR1 constructor covers the native GPUDirect path where NVMe DMA lands directly in GPU-owned memory.
Implementations§
Source§impl<'a> GpuMappedBuffer<'a>
impl<'a> GpuMappedBuffer<'a>
Sourcepub unsafe fn from_host_visible_slice(slice: &'a mut [u8]) -> Self
pub unsafe fn from_host_visible_slice(slice: &'a mut [u8]) -> Self
Construct from a borrowed host-visible byte slice.
§Safety
The caller asserts:
slicealiases a device allocation created with host-visible host-shared usage bits by the concrete backend.- No other code reads or writes through
slicewhile the returned handle is alive.
Sourcepub unsafe fn from_host_visible_owner<O: ?Sized>(
_owner: &'a mut O,
ptr: *mut u8,
len: usize,
) -> Self
pub unsafe fn from_host_visible_owner<O: ?Sized>( _owner: &'a mut O, ptr: *mut u8, len: usize, ) -> Self
Construct from a raw pointer + explicit owner anchor.
This is for GPU APIs that hand back a raw mapped pointer plus an
owning handle rather than a Rust slice. The borrow on owner
forces the mapped region to outlive every derived
AsyncUringStream.
§Safety
The caller asserts:
ptrpoints into a GPU allocation owned byowner.- The mapped region is
lenbytes long and host-visible. - No other code reads or writes through
ptrwhile the returned handle is alive.
Sourcepub unsafe fn duplicate(&self) -> Self
pub unsafe fn duplicate(&self) -> Self
Duplicate the mapped-buffer handle for the same underlying region.
§Safety
The caller must uphold the same aliasing and lifetime guarantees as
GpuMappedBuffer::from_host_visible_slice. This does not clone memory;
it creates another handle to the same mapped bytes.
Sourcepub fn sub_region(
&self,
offset: usize,
len: usize,
) -> Result<Self, PipelineError>
pub fn sub_region( &self, offset: usize, len: usize, ) -> Result<Self, PipelineError>
Carve out a sub-region of this mapped buffer.
This preserves the original constructor contract: the returned handle aliases the same host-visible GPU allocation and carries no ownership of its own.
§Errors
Returns PipelineError::QueueFull when offset + len
exceeds the mapped buffer bounds.
Sourcepub unsafe fn as_mut_slice(&mut self) -> &mut [u8] ⓘ
pub unsafe fn as_mut_slice(&mut self) -> &mut [u8] ⓘ
Borrow the mapped bytes as a mutable slice.
§Safety
The caller must ensure exclusive mutable access to the region for the lifetime of the returned slice.
Sourcepub unsafe fn from_bar1_peer_with_owner<O: ?Sized>(
_owner: &'a mut O,
peer_ptr: *mut u8,
len: usize,
) -> Self
pub unsafe fn from_bar1_peer_with_owner<O: ?Sized>( _owner: &'a mut O, peer_ptr: *mut u8, len: usize, ) -> Self
Construct from a PCIe peer-memory pointer GPUDirect Storage).
When paired with crate::PipelineError::NvmePassthroughDisabled
via the uring-cmd-nvme feature, this lets NVMe DMA writes
land directly in VRAM without crossing the host PCIe bridge.
§Safety
The caller asserts:
peer_ptrpoints at a region returned bynvidia_p2p_get_pages(Linux nvidia-fs) orcuMemAlloc+cuPointerSetAttributeCU_POINTER_ATTRIBUTE_SYNC_MEMOPS.- The GPU allocation outlives the returned handle.
- The io_uring kernel and NVMe driver both have DMA-mapping
capability (verified at runtime by checking
/proc/driver/nvidia-fs/stats).