Skip to main content

MappedBuffer

Struct MappedBuffer 

Source
pub struct MappedBuffer<T: DeviceRepr> { /* private fields */ }
Expand description

Typed storage in one native external-memory mapping.

Casts and initialized prefixes retain the original mapping and import independently of typed access.

Implementations§

Source§

impl<T: DeviceRepr> MappedBuffer<T>

Source

pub const fn as_ptr(&self) -> *const T

Returns a device pointer to the buffer’s typed storage without granting host accessibility.

Source

pub const fn as_mut_ptr(&mut self) -> *mut T

Returns a mutable device pointer without extending the allocation lifetime or granting access after this borrow.

Source

pub const fn len(&self) -> usize

Returns the number of typed storage elements exposed by this buffer.

Source

pub const fn is_empty(&self) -> bool

Returns whether this buffer exposes zero typed elements.

Source

pub fn byte_len(&self) -> usize

Returns the byte size of the exposed typed range, which can be shorter than the retained native mapping.

§Panics

Panics if the stored length violates the byte-size invariant checked during construction and casts.

Source

pub fn context(&self) -> &Arc<Context> ⓘ

Returns the CUDA context owning the retained external-memory mapping.

Source

pub fn allocation(&self) -> &Arc<MappedAllocation> ⓘ

Borrows the complete native mapping owner retained by this typed buffer.

Source

pub fn view(&self) -> DeviceView<'_, T>

Borrows this buffer as a typed device view.

Source

pub fn view_mut(&mut self) -> DeviceViewMut<'_, T>

Exclusively borrows this buffer as a mutable typed device view.

Source

pub fn cast<U: AnyBitPatternDeviceRepr>( self, ) -> StdResult<MappedBuffer<U>, Self>

Reinterprets initialized bytes while preserving the complete native mapping and imported owner.

§Errors

Returns an error holding self if the target type has zero size, the byte count is not a multiple of its size, or a nonempty mapping address is not aligned for it.

Source

pub fn into_uninit(self) -> MappedBuffer<MaybeUninit<T>>

Preserves the mapping and element count while discarding the initialized-value claim.

Source§

impl<T: DeviceRepr> MappedBuffer<MaybeUninit<T>>

Source

pub fn output(&mut self) -> DeviceOutputView<'_, T>

Exclusively borrows uninitialized storage as an output view without exposing initialized T values.

Source

pub fn cast_uninit<U: DeviceRepr>( self, ) -> StdResult<MappedBuffer<MaybeUninit<U>>, Self>

Reinterprets uninitialized storage without claiming initialized bytes.

§Errors

Returns an error holding self if the target type has zero size, the byte count is not a multiple of its size, or a nonempty mapping address is not aligned for it.

Source

pub unsafe fn assume_init(self) -> MappedBuffer<T>

Marks every element initialized after external or CUDA production.

§Safety

All elements must contain valid T values and all producers must complete or be ordered before every consumer. Synchronize foreign runtime accesses and retain exclusive access until production completes.

Source

pub unsafe fn assume_init_prefix(self, length: usize) -> Result<MappedBuffer<T>>

Exposes only a produced prefix, retaining the complete native mapping for deallocation.

§Safety

Prefix values must be valid and producer completion and foreign access must satisfy assume_init.

§Errors

Returns an error if length exceeds the buffer’s element count.

Trait Implementations§

Source§

impl<T: Debug + DeviceRepr> Debug for MappedBuffer<T>

Source§

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

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

impl<T: DeviceRepr> DeviceOutput<T> for MappedBuffer<T>

Source§

fn as_mut_ptr(&mut self) -> *mut T

Returns a pointer to the writable device output range. Read more
Source§

impl<T: DeviceRepr> DeviceOutput<T> for MappedBuffer<MaybeUninit<T>>

Source§

fn as_mut_ptr(&mut self) -> *mut T

Returns a pointer to the writable device output range. Read more
Source§

impl<T: DeviceRepr> DeviceRange<T> for MappedBuffer<T>

Source§

fn as_device_ptr(&self) -> *const T

Returns the device input pointer without asserting that its values are initialized. Read more
Source§

fn len(&self) -> usize

Returns the number of input elements.
Source§

fn context(&self) -> &Arc<Context> ⓘ

Returns the context associated with the input allocation.
Source§

fn is_empty(&self) -> bool

Returns whether the input range contains no elements.
Source§

fn byte_len(&self) -> Result<usize>

Returns the input range length in bytes. Read more
Source§

impl<T: DeviceRepr> DeviceRange<T> for MappedBuffer<MaybeUninit<T>>

Source§

fn len(&self) -> usize

Returns the number of input elements.
Source§

fn context(&self) -> &Arc<Context> ⓘ

Returns the context associated with the input allocation.
Source§

fn as_device_ptr(&self) -> *const T

Returns the device input pointer without asserting that its values are initialized. Read more
Source§

fn is_empty(&self) -> bool

Returns whether the input range contains no elements.
Source§

fn byte_len(&self) -> Result<usize>

Returns the input range length in bytes. Read more
Source§

impl<T: DeviceRepr> DeviceRegionProvider for MappedBuffer<T>

Source§

fn region(&self) -> DeviceRegion<'_>

Borrows the exact allocation range described by this provider’s pointers.
Source§

impl<T: DeviceRepr> DeviceSlice<T> for MappedBuffer<T>

Source§

impl<T: DeviceRepr> DeviceSliceMut<T> for MappedBuffer<T>

Source§

impl<T: DeviceRepr> PushKernelArg for &MappedBuffer<T>

Source§

fn push_to(self, params: &mut KernelParameters<'_>)

Appends this value in the kernel ABI representation selected by its implementation.
Source§

impl<T: DeviceRepr> PushKernelArg for &mut MappedBuffer<T>

Source§

fn push_to(self, params: &mut KernelParameters<'_>)

Appends this value in the kernel ABI representation selected by its implementation.
Source§

impl<T: DeviceRepr + Send> Send for MappedBuffer<T>

Source§

impl<T: DeviceRepr + Sync> Sync for MappedBuffer<T>

Auto Trait Implementations§

§

impl<T> !RefUnwindSafe for MappedBuffer<T>

§

impl<T> !UnwindSafe for MappedBuffer<T>

§

impl<T> Forget for MappedBuffer<T>

§

impl<T> Freeze for MappedBuffer<T>
where *mut T: Freeze,

§

impl<T> Move for MappedBuffer<T>

§

impl<T> Unpin for MappedBuffer<T>
where *mut T: Unpin,

§

impl<T> UnsafeUnpin for MappedBuffer<T>

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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.