pub struct DeviceBuffer<T: DeviceRepr> { /* private fields */ }Expand description
Owned, typed allocation of device memory (Runtime API).
Implementations§
Source§impl<T: DeviceRepr> DeviceBuffer<T>
impl<T: DeviceRepr> DeviceBuffer<T>
Sourcepub fn new(len: usize) -> Result<Self>
pub fn new(len: usize) -> Result<Self>
Allocate an uninitialized buffer of len elements on the current device.
Sourcepub fn from_slice(src: &[T]) -> Result<Self>
pub fn from_slice(src: &[T]) -> Result<Self>
Allocate and synchronously copy src from host memory.
Sourcepub fn copy_from_host(&self, src: &[T]) -> Result<()>
pub fn copy_from_host(&self, src: &[T]) -> Result<()>
Synchronous H2D copy.
Sourcepub fn copy_to_host(&self, dst: &mut [T]) -> Result<()>
pub fn copy_to_host(&self, dst: &mut [T]) -> Result<()>
Synchronous D2H copy.
Sourcepub fn copy_from_host_async(&self, src: &[T], stream: &Stream) -> Result<()>
pub fn copy_from_host_async(&self, src: &[T], stream: &Stream) -> Result<()>
Asynchronous H2D copy on stream.
Sourcepub fn copy_to_host_async(&self, dst: &mut [T], stream: &Stream) -> Result<()>
pub fn copy_to_host_async(&self, dst: &mut [T], stream: &Stream) -> Result<()>
Asynchronous D2H copy on stream.
Sourcepub fn as_device_ptr(&self) -> u64
pub fn as_device_ptr(&self) -> u64
Raw device pointer as the u64 value kernels expect. Convenience
wrapper around as_raw.
Source§impl<T: DeviceRepr> DeviceBuffer<T>
impl<T: DeviceRepr> DeviceBuffer<T>
Sourcepub fn new_async(len: usize, stream: &Stream) -> Result<Self>
pub fn new_async(len: usize, stream: &Stream) -> Result<Self>
Asynchronously allocate len elements on stream from the device’s
default memory pool (CUDA 11.2+).
Sourcepub fn free_async(self, stream: &Stream) -> Result<()>
pub fn free_async(self, stream: &Stream) -> Result<()>
Free this buffer asynchronously on stream. Consumes self so
the sync Drop does not also free.
Trait Implementations§
Source§impl<T: DeviceRepr> Debug for DeviceBuffer<T>
impl<T: DeviceRepr> Debug for DeviceBuffer<T>
Source§impl<T: DeviceRepr> Drop for DeviceBuffer<T>
impl<T: DeviceRepr> Drop for DeviceBuffer<T>
impl<T: DeviceRepr + Send> Send for DeviceBuffer<T>
Auto Trait Implementations§
impl<T> Freeze for DeviceBuffer<T>
impl<T> RefUnwindSafe for DeviceBuffer<T>where
T: RefUnwindSafe,
impl<T> !Sync for DeviceBuffer<T>
impl<T> Unpin for DeviceBuffer<T>where
T: Unpin,
impl<T> UnsafeUnpin for DeviceBuffer<T>
impl<T> UnwindSafe for DeviceBuffer<T>where
T: UnwindSafe,
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