pub struct DeviceViewMut<'a, T: DeviceRepr> { /* private fields */ }Expand description
An exclusive borrow of typed CUDA storage.
Implementations§
Source§impl<'a, T: DeviceRepr> DeviceViewMut<'a, T>
impl<'a, T: DeviceRepr> DeviceViewMut<'a, T>
Sourcepub fn into_region(self) -> DeviceRegion<'a>
pub fn into_region(self) -> DeviceRegion<'a>
Consumes the typed borrow into allocation metadata without granting access.
Sourcepub unsafe fn from_raw_parts(
region: DeviceRegion<'a>,
length: usize,
) -> Result<Self>
pub unsafe fn from_raw_parts( region: DeviceRegion<'a>, length: usize, ) -> Result<Self>
Exclusively borrows a region containing length values of T.
§Safety
The region must contain valid T values and remain exclusively borrowed for the returned lifetime, including all GPU work using this view.
§Errors
Returns an error if length * size_of::<T>() overflows or differs from the region’s byte length, or a nonempty region has a zero-sized element type or insufficient alignment.
Sourcepub fn from_memory(memory: &'a mut DeviceMemory<T>) -> Self
pub fn from_memory(memory: &'a mut DeviceMemory<T>) -> Self
Exclusively borrows every initialized element of a device allocation without copying data.
Sourcepub fn from_buffer<B: DeviceSliceMut<T> + ?Sized>(buffer: &'a mut B) -> Self
pub fn from_buffer<B: DeviceSliceMut<T> + ?Sized>(buffer: &'a mut B) -> Self
Exclusively borrows an initialized typed provider without copying data.
Sourcepub fn reborrow(&mut self) -> DeviceViewMut<'_, T>
pub fn reborrow(&mut self) -> DeviceViewMut<'_, T>
Borrows this mutable view again for a shorter exclusive lifetime.
Sourcepub fn as_ptr(&self) -> *const T
pub fn as_ptr(&self) -> *const T
Returns the CUDA-accessible element pointer.
An empty view returns an aligned dangling pointer. This pointer does not grant host access.
Sourcepub fn as_mut_ptr(&mut self) -> *mut T
pub fn as_mut_ptr(&mut self) -> *mut T
Returns the exclusively borrowed CUDA-accessible element pointer.
This pointer does not grant host access or synchronize pending work.
Sourcepub fn context(&self) -> &Arc<Context> ⓘ
pub fn context(&self) -> &Arc<Context> ⓘ
Returns the context associated with the viewed allocation.
Sourcepub fn region(&self) -> DeviceRegion<'_>
pub fn region(&self) -> DeviceRegion<'_>
Returns the view’s exact byte range and allocation identity.
Sourcepub fn copy_from_host(&mut self, source: &[T]) -> Result<()>
pub fn copy_from_host(&mut self, source: &[T]) -> Result<()>
Copies a host slice into the entire view and waits for completion.
§Errors
Returns an error for unequal element counts or byte-size overflow. Also propagates access-tracking, readiness synchronization, context binding, stream-capture, CUDA copy, and stream synchronization errors. A nonempty synchronous transfer is rejected during stream capture.
Sourcepub fn copy_from_device<B: DeviceSlice<T> + ?Sized>(
&mut self,
source: &B,
) -> Result<()>
pub fn copy_from_device<B: DeviceSlice<T> + ?Sized>( &mut self, source: &B, ) -> Result<()>
Copies a disjoint device range into the entire view and waits for completion.
§Errors
Returns an error if the ranges have different contexts or element counts, overlap in the same allocation, or their byte size overflows. Also propagates access-tracking, readiness synchronization, context binding, stream-capture, CUDA copy, and stream synchronization errors. A nonempty synchronous transfer is rejected during stream capture.
Sourcepub fn copy_to_host(&self, destination: &mut [T]) -> Result<()>where
T: AnyBitPatternDeviceRepr,
pub fn copy_to_host(&self, destination: &mut [T]) -> Result<()>where
T: AnyBitPatternDeviceRepr,
Copies every viewed element into a host slice and waits for completion.
§Errors
Returns an error for unequal element counts or byte-size overflow. Also propagates access-tracking, readiness synchronization, context binding, stream-capture, CUDA copy, and stream synchronization errors. A nonempty synchronous transfer is rejected during stream capture.
Sourcepub fn copy_to_host_vec(&self) -> Result<Vec<T>>where
T: AnyBitPatternDeviceRepr,
pub fn copy_to_host_vec(&self) -> Result<Vec<T>>where
T: AnyBitPatternDeviceRepr,
Copies every viewed element into a new host vector and waits for completion.
§Errors
Propagates byte-size overflow, access-tracking, readiness synchronization, context-binding, stream-capture, CUDA copy, and stream synchronization errors. A nonempty synchronous transfer is rejected during stream capture.
Sourcepub fn as_view(&self) -> DeviceView<'_, T>
pub fn as_view(&self) -> DeviceView<'_, T>
Borrows this view for reading without extending the lifetime of the mutable borrow.
Sourcepub fn slice<R: RangeBounds<usize>>(
&self,
range: R,
) -> Result<DeviceView<'_, T>>
pub fn slice<R: RangeBounds<usize>>( &self, range: R, ) -> Result<DeviceView<'_, T>>
Borrows an initialized element subrange for reading.
§Errors
Returns an error if the element range is reversed, exceeds this range’s bounds, or an inclusive bound cannot be converted without overflow.
Sourcepub fn slice_mut<R: RangeBounds<usize>>(
&mut self,
range: R,
) -> Result<DeviceViewMut<'_, T>>
pub fn slice_mut<R: RangeBounds<usize>>( &mut self, range: R, ) -> Result<DeviceViewMut<'_, T>>
Exclusively borrows an initialized element subrange.
§Errors
Returns an error if the element range is reversed, exceeds this range’s bounds, or an inclusive bound cannot be converted without overflow.
Sourcepub fn split_at_mut(
&mut self,
mid: usize,
) -> Result<(DeviceViewMut<'_, T>, DeviceViewMut<'_, T>)>
pub fn split_at_mut( &mut self, mid: usize, ) -> Result<(DeviceViewMut<'_, T>, DeviceViewMut<'_, T>)>
Borrows two disjoint mutable views, split at element index mid.
§Errors
Returns an error if mid exceeds the view’s element count.
Sourcepub fn cast<U: AnyBitPatternDeviceRepr + NoUninitDeviceRepr>(
self,
) -> Result<DeviceViewMut<'a, U>>where
T: AnyBitPatternDeviceRepr + NoUninitDeviceRepr,
pub fn cast<U: AnyBitPatternDeviceRepr + NoUninitDeviceRepr>(
self,
) -> Result<DeviceViewMut<'a, U>>where
T: AnyBitPatternDeviceRepr + NoUninitDeviceRepr,
Reinterprets a mutable borrow while preserving both element types’ validity.
§Errors
Returns an error if U is zero-sized, the region’s byte length is not divisible by size_of::<U>(), or a nonempty region is not aligned for U.
Sourcepub unsafe fn cast_unchecked<U: DeviceRepr>(
self,
) -> Result<DeviceViewMut<'a, U>>
pub unsafe fn cast_unchecked<U: DeviceRepr>( self, ) -> Result<DeviceViewMut<'a, U>>
Reinterprets a mutable borrow under a caller-established validity contract.
§Safety
Every destination element must be initialized and valid for U.
Writes through the returned view must leave valid T values when the borrow ends.
§Errors
Returns an error if U is zero-sized, the region’s byte length is not divisible by size_of::<U>(), or a nonempty region is not aligned for U.
Source§impl<'a, T: DeviceRepr> DeviceViewMut<'a, MaybeUninit<T>>
impl<'a, T: DeviceRepr> DeviceViewMut<'a, MaybeUninit<T>>
Sourcepub fn output(&mut self) -> DeviceOutputView<'_, T>
pub fn output(&mut self) -> DeviceOutputView<'_, T>
Borrows this uninitialized range as a write-only output of T values.
Sourcepub unsafe fn assume_init(self) -> DeviceViewMut<'a, T>
pub unsafe fn assume_init(self) -> DeviceViewMut<'a, T>
Exposes elements initialized by a producer through this exclusive view.
§Safety
Every element must contain a valid T value. Producing writes must be ordered before all consumers, and must complete before host readback.