Skip to main content

CudaView

Struct CudaView 

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

&[T] on a cuda device. An immutable sub-view into a CudaSlice created by CudaSlice::as_view()/CudaSlice::slice().

Implementations§

Source§

impl<T> CudaView<'_, T>

Source

pub fn len(&self) -> usize

The number of elements T in this view.

Source

pub fn is_empty(&self) -> bool

Source§

impl<'a, T> CudaView<'a, T>

Source

pub fn view_ptr(self, stream: &'a CudaStream) -> (CUdeviceptr, SyncOnDrop<'a>)

Identical behavior to DevicePtr::device_ptr(), but the lifetime on the returned SyncOnDrop, matches the lifetime of the view.

Source§

impl<'a, T> CudaView<'a, T>

Source

pub fn slice(&self, bounds: impl RangeBounds<usize>) -> Self

Creates a CudaView at the specified offset from the start of self.

Panics if range.start >= self.len.

§Example
let mut slice = stream.alloc_zeros::<u8>(100).unwrap();
let mut view = slice.slice(0..50);
let mut view2 = view.slice(0..25);
do_something(&view);
Source

pub fn try_slice(&self, bounds: impl RangeBounds<usize>) -> Option<Self>

Fallible version of CudaView::slice

Source

pub unsafe fn transmute<S>(&self, len: usize) -> Option<CudaView<'a, S>>

Reinterprets the slice of memory into a different type. len is the number of elements of the new type S that are expected. If not enough bytes are allocated in self for the view, then this returns None.

§Safety

This is unsafe because not the memory for the view may not be a valid interpretation for the type S.

Source

pub fn split_at(&self, mid: usize) -> (Self, Self)

Source

pub fn try_split_at(&self, mid: usize) -> Option<(Self, Self)>

Fallible version of CudaSlice::split_at.

Returns None if mid > self.len.

Source

pub fn chunks_exact( &self, chunk_size: usize, ) -> impl Iterator<Item = CudaView<'a, T>> + '_

Returns an iterarow over subviews of size chunk_size. Differs from std::slice::ChunksExact, in that it asserts that the chunk_size must divide evenly into the length, instead of returning a remainder.

Trait Implementations§

Source§

impl<'a, T: Debug> Debug for CudaView<'a, T>

Source§

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

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

impl<T> DevicePtr<T> for CudaView<'_, T>

Source§

fn device_ptr<'a>( &'a self, stream: &'a CudaStream, ) -> (CUdeviceptr, SyncOnDrop<'a>)

Retrieve the device pointer with the intent to read the device memory associated with it. Read more
Source§

impl<T> DeviceSlice<T> for CudaView<'_, T>

Source§

fn len(&self) -> usize

Source§

fn stream(&self) -> &Arc<CudaStream>

Source§

fn num_bytes(&self) -> usize

Source§

fn is_empty(&self) -> bool

Source§

impl<'a, 'b: 'a, 'c: 'b, T> PushKernelArg<&'b CudaView<'c, T>> for LaunchArgs<'a>

Source§

fn arg(&mut self, arg: &'b CudaView<'c, T>) -> &mut Self

Auto Trait Implementations§

§

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

§

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

§

impl<'a, T> Send for CudaView<'a, T>
where T: Sync,

§

impl<'a, T> Sync for CudaView<'a, T>
where T: Sync,

§

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

§

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

§

impl<'a, T> UnwindSafe for CudaView<'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<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, 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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V