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>
impl<T: DeviceRepr> MappedBuffer<T>
Sourcepub const fn as_ptr(&self) -> *const T
pub const fn as_ptr(&self) -> *const T
Returns a device pointer to the buffer’s typed storage without granting host accessibility.
Sourcepub const fn as_mut_ptr(&mut self) -> *mut T
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.
Sourcepub const fn len(&self) -> usize
pub const fn len(&self) -> usize
Returns the number of typed storage elements exposed by this buffer.
Sourcepub fn byte_len(&self) -> usize
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.
Sourcepub fn context(&self) -> &Arc<Context> ⓘ
pub fn context(&self) -> &Arc<Context> ⓘ
Returns the CUDA context owning the retained external-memory mapping.
Sourcepub fn allocation(&self) -> &Arc<MappedAllocation> ⓘ
pub fn allocation(&self) -> &Arc<MappedAllocation> ⓘ
Borrows the complete native mapping owner retained by this typed buffer.
Sourcepub fn view(&self) -> DeviceView<'_, T>
pub fn view(&self) -> DeviceView<'_, T>
Borrows this buffer as a typed device view.
Sourcepub fn view_mut(&mut self) -> DeviceViewMut<'_, T>
pub fn view_mut(&mut self) -> DeviceViewMut<'_, T>
Exclusively borrows this buffer as a mutable typed device view.
Sourcepub fn cast<U: AnyBitPatternDeviceRepr>(
self,
) -> StdResult<MappedBuffer<U>, Self>where
T: NoUninitDeviceRepr,
pub fn cast<U: AnyBitPatternDeviceRepr>(
self,
) -> StdResult<MappedBuffer<U>, Self>where
T: NoUninitDeviceRepr,
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.
Sourcepub fn into_uninit(self) -> MappedBuffer<MaybeUninit<T>>
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>>
impl<T: DeviceRepr> MappedBuffer<MaybeUninit<T>>
Sourcepub fn output(&mut self) -> DeviceOutputView<'_, T>
pub fn output(&mut self) -> DeviceOutputView<'_, T>
Exclusively borrows uninitialized storage as an output view without exposing initialized T values.
Sourcepub fn cast_uninit<U: DeviceRepr>(
self,
) -> StdResult<MappedBuffer<MaybeUninit<U>>, Self>
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.
Sourcepub unsafe fn assume_init(self) -> MappedBuffer<T>
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.