Skip to main content

DeviceView

Struct DeviceView 

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

Non-owning immutable view over CUDA-accessible device memory.

This type is Copy because it models a shared immutable borrow: duplicating the view duplicates only the pointer/length pair and does not create or free device memory. The lifetime ties the view to the allocation or owner that created it, but CUDA kernels may still observe mutations performed through other aliases according to CUDA stream ordering.

Implementations§

Source§

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

Source

pub const unsafe fn from_raw_parts(ptr: *const T, length: usize) -> Self

Creates a borrowed immutable device view from a raw pointer and length.

§Safety

ptr must be valid for length contiguous elements of T for the returned lifetime. If length is zero, ptr may be null; the stored view pointer is normalized to NonNull::dangling() because safe borrowed views should not expose null unless a vendor API explicitly requires it. The memory must remain alive and CUDA-accessible while the view is used.

Source

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

Source

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

Source

pub const fn len(&self) -> usize

Source

pub const fn is_empty(&self) -> bool

Source

pub fn slice<R: RangeBounds<usize>>(self, range: R) -> Result<Self>

Trait Implementations§

Source§

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

Source§

fn clone(&self) -> DeviceView<'a, T>

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> DeviceSlice<T> for DeviceView<'_, T>

Source§

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

Source§

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

Source§

impl<T: DeviceRepr> PushKernelArg for &DeviceView<'_, T>

Source§

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

Auto Trait Implementations§

§

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

§

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

§

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

§

impl<'a, T> RefUnwindSafe for DeviceView<'a, T>
where T: RefUnwindSafe,

§

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

§

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

§

impl<'a, T> UnwindSafe for DeviceView<'a, T>
where T: RefUnwindSafe,

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<B> ByteBuffer for B
where B: DeviceSlice<u8> + ?Sized,

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, B> DeviceBuffer<T> for B
where T: DeviceRepr, B: DeviceSlice<T> + ?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> 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.