pub struct ManagedRef<T> { /* private fields */ }Expand description
Owning handle to a managed-memory region. Arc-cloned across
agents; the underlying allocation is freed when the last clone
drops.
Implementations§
Source§impl<T> ManagedRef<T>
impl<T> ManagedRef<T>
Source§impl<T: Copy> ManagedRef<T>
impl<T: Copy> ManagedRef<T>
Sourcepub fn as_slice(&self) -> &[T]
pub fn as_slice(&self) -> &[T]
Host-side immutable view of the managed memory.
SAFETY contract: managed memory is coherent host/device, but
reads from the host before the device has finished writing
produce undefined values. Caller must synchronize the
relevant device stream first (e.g. via
cudaDeviceSynchronize) when reading data the device wrote.
Returns an empty slice if the allocator has stopped.
Sourcepub fn as_mut_slice(&mut self) -> &mut [T]
pub fn as_mut_slice(&mut self) -> &mut [T]
Host-side mutable view of the managed memory.
Like Self::as_slice this is a host alias of device-visible
memory. The caller must hold a WriteToken (e.g. from
crate::memory::ManagedAllocatorActor or
SharedGpuStateCoordinator) to avoid concurrent device
writes while writing from the host.