pub struct DeviceSlice<'a, T: DeviceRepr> { /* private fields */ }Expand description
Immutable view into a range of a DeviceBuffer.
Implementations§
Source§impl<'a, T: DeviceRepr> DeviceSlice<'a, T>
impl<'a, T: DeviceRepr> DeviceSlice<'a, T>
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn as_raw(&self) -> CUdeviceptr
Sourcepub unsafe fn from_raw_parts<'b>(
ptr: CUdeviceptr,
len: usize,
) -> DeviceSlice<'b, T>
pub unsafe fn from_raw_parts<'b>( ptr: CUdeviceptr, len: usize, ) -> DeviceSlice<'b, T>
Construct a DeviceSlice from a raw device pointer and element count.
The lower-level escape hatch backing
DeviceBuffer::view_as — use this when
the source buffer is not a baracuda DeviceBuffer (e.g. a
pointer received from a foreign CUDA library, or a byte-shaped
storage substrate that erases the original buffer type at the
boundary).
§Safety
The caller must guarantee:
ptrpoints to at leastlen * size_of::<T>()bytes of device memory in the calling thread’s current CUDA context.- The pointer is properly aligned for
T.cuMemAllocreturns 256-byte-aligned pointers, but sub-slicing with a non-multiple element offset can reduce alignment. - The pointed-to region remains live, with no concurrent
mutation through any other path, for the lifetime
'b. - The contents are a valid bit-pattern for
T(trivially true forT: DeviceReprsince allDeviceReprtypes have no invalid bit patterns).
Sourcepub fn slice(&self, range: Range<usize>) -> DeviceSlice<'_, T>
pub fn slice(&self, range: Range<usize>) -> DeviceSlice<'_, T>
Borrow a sub-range. Panics on out-of-bounds / inverted ranges.
Trait Implementations§
Source§impl<'a, T: Clone + DeviceRepr> Clone for DeviceSlice<'a, T>
impl<'a, T: Clone + DeviceRepr> Clone for DeviceSlice<'a, T>
Source§fn clone(&self) -> DeviceSlice<'a, T>
fn clone(&self) -> DeviceSlice<'a, T>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<'a, T: DeviceRepr> Debug for DeviceSlice<'a, T>
impl<'a, T: DeviceRepr> Debug for DeviceSlice<'a, T>
Source§impl<'a, T: DeviceRepr> DevicePtr<T> for DeviceSlice<'a, T>
impl<'a, T: DeviceRepr> DevicePtr<T> for DeviceSlice<'a, T>
Source§impl<'a, T: DeviceRepr> KernelArg for &DeviceSlice<'a, T>
impl<'a, T: DeviceRepr> KernelArg for &DeviceSlice<'a, T>
fn as_kernel_arg_ptr(&self) -> *mut c_void
impl<'a, T: Copy + DeviceRepr> Copy for DeviceSlice<'a, T>
Auto Trait Implementations§
impl<'a, T> Freeze for DeviceSlice<'a, T>
impl<'a, T> RefUnwindSafe for DeviceSlice<'a, T>where
T: RefUnwindSafe,
impl<'a, T> Send for DeviceSlice<'a, T>where
T: Sync,
impl<'a, T> Sync for DeviceSlice<'a, T>where
T: Sync,
impl<'a, T> Unpin for DeviceSlice<'a, T>
impl<'a, T> UnsafeUnpin for DeviceSlice<'a, T>
impl<'a, T> UnwindSafe for DeviceSlice<'a, T>where
T: RefUnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more