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>
impl<'a, T: DeviceRepr> DeviceView<'a, T>
Sourcepub const unsafe fn from_raw_parts(ptr: *const T, length: usize) -> Self
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.
pub fn from_memory(memory: &'a DeviceMemory<T>) -> Self
pub const fn as_ptr(&self) -> *const T
pub const fn len(&self) -> usize
pub const fn is_empty(&self) -> bool
pub fn slice<R: RangeBounds<usize>>(self, range: R) -> Result<Self>
Trait Implementations§
Source§impl<'a, T: Clone + DeviceRepr> Clone for DeviceView<'a, T>
impl<'a, T: Clone + DeviceRepr> Clone for DeviceView<'a, T>
Source§fn clone(&self) -> DeviceView<'a, T>
fn clone(&self) -> DeviceView<'a, T>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more