pub struct LockedBox<T: DeviceCopy> { /* private fields */ }
Expand description
Page-locked box in host memory.
Page-locked memory
Modern OSes have the ability to page out memory pages to storage areas such as the disk to reduce RAM usage. However, this causes issues with certain things such as asynchronous memory copies because the memory may get paged out to disk while the driver is staging a DMA transfer. For this reason, CUDA provides functions for allocating page-locked memory that is pinned to RAM.
This memory is generally only used as a staging buffer for memory copies to the GPU. Significant use of pinned memory can reduce overall performance as the OS is forced to page out more memory to disk.
Implementations
sourceimpl<T: DeviceCopy> LockedBox<T>
impl<T: DeviceCopy> LockedBox<T>
sourcepub unsafe fn uninitialized() -> CudaResult<Self>
pub unsafe fn uninitialized() -> CudaResult<Self>
sourcepub fn new(val: &T) -> CudaResult<Self>
pub fn new(val: &T) -> CudaResult<Self>
sourcepub fn into_raw(self) -> *mut T
pub fn into_raw(self) -> *mut T
Consumes this box, returning the underlying allocation pointer. The
backing memory will not be freed, it is up to the user to free it with either
cuda_free_locked
or LockedBox::from_raw
.
sourcepub unsafe fn from_raw(ptr: *mut T) -> Self
pub unsafe fn from_raw(ptr: *mut T) -> Self
Creates a LockedBox
from a raw pointer, taking ownership of the data backed behind
the pointer.
Safety
The pointer must be a valid pinned memory allocation as obtained from LockedBox::into_raw
or cuda_malloc_locked
.
Trait Implementations
sourceimpl<T: Debug + DeviceCopy> Debug for LockedBox<T>
impl<T: Debug + DeviceCopy> Debug for LockedBox<T>
sourceimpl<T: DeviceCopy> Deref for LockedBox<T>
impl<T: DeviceCopy> Deref for LockedBox<T>
sourceimpl<T: DeviceCopy> DerefMut for LockedBox<T>
impl<T: DeviceCopy> DerefMut for LockedBox<T>
sourceimpl<T: DeviceCopy> Drop for LockedBox<T>
impl<T: DeviceCopy> Drop for LockedBox<T>
impl<T: Send + DeviceCopy> Send for LockedBox<T>
impl<T: Sync + DeviceCopy> Sync for LockedBox<T>
Auto Trait Implementations
impl<T> RefUnwindSafe for LockedBox<T> where
T: RefUnwindSafe,
impl<T> Unpin for LockedBox<T>
impl<T> UnwindSafe for LockedBox<T> where
T: RefUnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more