Skip to main content

DeviceView

Struct DeviceView 

Source
pub struct DeviceView<'a, T: DeviceRepr> { /* private fields */ }
Expand description

An immutable borrow of typed CUDA storage, including its allocation identity.

Implementations§

Source§

impl<'a, T: DeviceRepr> DeviceView<'a, T>

Source

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

Consumes the typed borrow into allocation metadata without granting new access.

Source

pub unsafe fn from_raw_parts( region: DeviceRegion<'a>, length: usize, ) -> Result<Self>

Borrows a region containing length values of T.

§Safety

The region must contain valid T values for the returned lifetime. Access through other aliases must respect this shared borrow and CUDA ordering.

§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 DeviceMemory<T>) -> Self

Borrows every initialized element of a device allocation without copying data.

Source

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

Borrows any typed provider that also retains allocation metadata.

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 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) -> &'a Arc<Context> ⓘ

Returns the context associated with the viewed allocation.

Source

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

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

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 slice<R: RangeBounds<usize>>(self, range: R) -> Result<Self>

Returns a view of an element subrange, preserving allocation identity and readiness.

§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 cast<U: AnyBitPatternDeviceRepr>(self) -> Result<DeviceView<'a, U>>

Reinterprets initialized bytes as values accepting every bit pattern.

§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<DeviceView<'a, U>>

Reinterprets a region with a caller-established initialization contract.

§Safety

Every destination element must be initialized and valid for U. Alignment and byte length are checked by this method.

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

Trait Implementations§

Source§

impl<'a, T: Clone + DeviceRepr> Clone for DeviceView<'a, T>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a, T: Copy + DeviceRepr> Copy for DeviceView<'a, T>

Source§

impl<'a, T: Debug + DeviceRepr> Debug for DeviceView<'a, T>

Source§

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

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

impl<T: DeviceRepr> DeviceRange<T> for DeviceView<'_, 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 DeviceView<'_, T>

Source§

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

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

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

Source§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

impl<'a, T> UnsafeUnpin for DeviceView<'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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.