Skip to main content

GpuMappedBuffer

Struct GpuMappedBuffer 

Source
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>

Source

pub unsafe fn from_host_visible_slice(slice: &'a mut [u8]) -> Self

Construct from a borrowed host-visible byte slice.

§Safety

The caller asserts:

  • slice aliases a device allocation created with host-visible host-shared usage bits by the concrete backend.
  • No other code reads or writes through slice while the returned handle is alive.
Source

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:

  • ptr points into a GPU allocation owned by owner.
  • The mapped region is len bytes long and host-visible.
  • No other code reads or writes through ptr while the returned handle is alive.
Source

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.

Source

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.

Source

pub fn len(&self) -> usize

Byte length of the mapped region.

Source

pub fn is_empty(&self) -> bool

Whether the region is empty.

Source

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.

Source

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_ptr points at a region returned by nvidia_p2p_get_pages (Linux nvidia-fs) or cuMemAlloc + cuPointerSetAttribute CU_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).

Trait Implementations§

Auto Trait Implementations§

§

impl<'a> Freeze for GpuMappedBuffer<'a>

§

impl<'a> RefUnwindSafe for GpuMappedBuffer<'a>

§

impl<'a> Unpin for GpuMappedBuffer<'a>

§

impl<'a> UnsafeUnpin for GpuMappedBuffer<'a>

§

impl<'a> !UnwindSafe for GpuMappedBuffer<'a>

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more