pub struct ManagedMemory<T: DeviceRepr> { /* private fields */ }Implementations§
Source§impl<T: DeviceRepr> ManagedMemory<T>
impl<T: DeviceRepr> ManagedMemory<T>
Sourcepub fn create(length: usize, attach_flags: MemoryAttachFlags) -> Result<Self>
pub fn create(length: usize, attach_flags: MemoryAttachFlags) -> Result<Self>
Allocates typed CUDA managed memory and records its initial attach mode.
§Errors
Returns an error if the requested byte size overflows, CUDA cannot allocate managed memory, or a non-empty zero-sized allocation is requested.
pub fn zeroes(length: usize, attach_flags: MemoryAttachFlags) -> Result<Self>where
T: ZeroableDeviceRepr,
Sourcepub unsafe fn from_raw_parts(
ptr: *mut T,
length: usize,
attach_flags: MemoryAttachFlags,
) -> Self
pub unsafe fn from_raw_parts( ptr: *mut T, length: usize, attach_flags: MemoryAttachFlags, ) -> Self
Takes ownership of an existing managed allocation.
§Safety
ptr must be null for an empty allocation or point to length live
elements allocated by a CUDA allocation function compatible with
DeviceMemory::free. length * size_of::<T>() must fit in usize.
No other owner may free the pointer while the returned value is alive.
pub fn into_raw_parts(self) -> (*mut T, usize, MemoryAttachFlags)
pub const fn len(&self) -> usize
pub const fn is_empty(&self) -> bool
pub fn byte_len(&self) -> usize
pub const fn attach_flags(&self) -> MemoryAttachFlags
pub const fn as_ptr(&self) -> *const T
pub const fn as_mut_ptr(&mut self) -> *mut T
pub fn view(&self) -> DeviceView<'_, T>
pub fn view_mut(&mut self) -> DeviceViewMut<'_, T>
Sourcepub unsafe fn as_host_slice(&self) -> &[T]
pub unsafe fn as_host_slice(&self) -> &[T]
Returns a host slice over this managed allocation.
§Safety
The caller must ensure no GPU work or other CPU reference can concurrently mutate the same memory for the returned lifetime, and that the allocation is accessible from the host at the point of access.
Sourcepub unsafe fn as_host_slice_mut(&mut self) -> &mut [T]
pub unsafe fn as_host_slice_mut(&mut self) -> &mut [T]
Returns a mutable host slice over this managed allocation.
§Safety
The caller must ensure no GPU work or other CPU reference can concurrently access the same memory for the returned lifetime, and that the allocation is accessible from the host at the point of access.