pub struct ManagedMemory { /* private fields */ }Expand description
Backend-aware unified memory that routes allocation through the active backend
When a GPU backend is available, this allocates memory that is accessible from both host and device via the backend’s memory management. Falls back to host-only allocation when no GPU backend is present.
Implementations§
Source§impl ManagedMemory
impl ManagedMemory
Sourcepub fn new(size: usize) -> Result<Self>
pub fn new(size: usize) -> Result<Self>
Allocate managed memory (tries backend, falls back to host)
Sourcepub fn is_backend_registered(&self) -> bool
pub fn is_backend_registered(&self) -> bool
Check if memory is registered with a GPU backend
Sourcepub fn as_unified(&self) -> &UnifiedMemory
pub fn as_unified(&self) -> &UnifiedMemory
Get the underlying unified memory
Sourcepub fn as_unified_mut(&mut self) -> &mut UnifiedMemory
pub fn as_unified_mut(&mut self) -> &mut UnifiedMemory
Get a mutable reference to the underlying unified memory
Sourcepub fn copy_from_slice(&mut self, data: &[u8]) -> Result<()>
pub fn copy_from_slice(&mut self, data: &[u8]) -> Result<()>
Copy from host slice
Sourcepub fn copy_to_slice(&self, data: &mut [u8]) -> Result<()>
pub fn copy_to_slice(&self, data: &mut [u8]) -> Result<()>
Copy to host slice
Sourcepub fn prefetch_to_device(&self) -> Result<()>
pub fn prefetch_to_device(&self) -> Result<()>
Prefetch to the device (hint for the runtime; no-op in CPU mode)
Sourcepub fn prefetch_to_host(&self) -> Result<()>
pub fn prefetch_to_host(&self) -> Result<()>
Prefetch to the host (hint for the runtime; no-op in CPU mode)
Auto Trait Implementations§
impl Freeze for ManagedMemory
impl RefUnwindSafe for ManagedMemory
impl Send for ManagedMemory
impl Sync for ManagedMemory
impl Unpin for ManagedMemory
impl UnsafeUnpin for ManagedMemory
impl UnwindSafe for ManagedMemory
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