Skip to main content

DeviceViewMut

Struct DeviceViewMut 

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

Source

pub fn into_region(self) -> DeviceRegion<'a>

Consumes the typed borrow into allocation metadata without granting access.

Source

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.

Source

pub fn from_memory(memory: &'a mut DeviceMemory<T>) -> Self

Exclusively borrows every initialized element of a device allocation without copying data.

Source

pub fn from_buffer<B: DeviceSliceMut<T> + ?Sized>(buffer: &'a mut B) -> Self

Exclusively borrows an initialized typed provider without copying data.

Source

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

Borrows this mutable view again for a shorter exclusive lifetime.

Source

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.

Source

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.

Source

pub const fn len(&self) -> usize

Returns the number of elements in the view.

Source

pub const fn is_empty(&self) -> bool

Returns whether the view contains no elements.

Source

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

Returns the context associated with the viewed allocation.

Source

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

Returns the view’s exact byte range and allocation identity.

Source

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.

Source

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.

Source

pub fn copy_to_host(&self, destination: &mut [T]) -> Result<()>

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.

Source

pub fn copy_to_host_vec(&self) -> Result<Vec<T>>

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.

Source

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

Borrows this view for reading without extending the lifetime of the mutable borrow.

Source

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.

Source

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.

Source

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.

Source

pub fn cast<U: AnyBitPatternDeviceRepr + NoUninitDeviceRepr>( self, ) -> Result<DeviceViewMut<'a, U>>

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.

Source

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

Source

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

Borrows this uninitialized range as a write-only output of T values.

Source

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.

Trait Implementations§

Source§

impl<'a, T: Debug + DeviceRepr> Debug for DeviceViewMut<'a, 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 DeviceViewMut<'_, 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 DeviceViewMut<'_, 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 DeviceViewMut<'_, 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> DeviceRange<T> for DeviceViewMut<'_, 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> DeviceRegionProvider for DeviceViewMut<'_, T>

Source§

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

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

impl<T: DeviceRepr> DeviceSlice<T> for DeviceViewMut<'_, T>

Source§

impl<T: DeviceRepr> DeviceSliceMut<T> for DeviceViewMut<'_, T>

Source§

impl<T: DeviceRepr> PushKernelArg for &DeviceViewMut<'_, 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 DeviceViewMut<'_, T>

Source§

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

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

Auto Trait Implementations§

§

impl<'a, T> !RefUnwindSafe for DeviceViewMut<'a, T>

§

impl<'a, T> !Send for DeviceViewMut<'a, T>

§

impl<'a, T> !Sync for DeviceViewMut<'a, T>

§

impl<'a, T> !UnwindSafe for DeviceViewMut<'a, T>

§

impl<'a, T> Forget for DeviceViewMut<'a, T>

§

impl<'a, T> Freeze for DeviceViewMut<'a, T>

§

impl<'a, T> Move for DeviceViewMut<'a, T>

§

impl<'a, T> Unpin for DeviceViewMut<'a, T>

§

impl<'a, T> UnsafeUnpin for DeviceViewMut<'a, 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.