pub struct ManagedMemoryHints { /* private fields */ }Expand description
Builder-style API for applying memory hints to a unified memory region.
Wraps a raw pointer + byte size and exposes methods that issue the
appropriate mem_advise / mem_prefetch driver calls.
§Construction
Use for_buffer for raw pointers or
from_unified for UnifiedBuffer references.
Implementations§
Source§impl ManagedMemoryHints
impl ManagedMemoryHints
Sourcepub fn for_buffer(ptr: u64, byte_size: usize) -> CudaResult<Self>
pub fn for_buffer(ptr: u64, byte_size: usize) -> CudaResult<Self>
Creates a ManagedMemoryHints from a raw device pointer and byte size.
§Errors
Returns CudaError::InvalidValue if byte_size is zero.
Sourcepub fn from_unified<T: Copy>(buf: &UnifiedBuffer<T>) -> CudaResult<Self>
pub fn from_unified<T: Copy>(buf: &UnifiedBuffer<T>) -> CudaResult<Self>
Creates a ManagedMemoryHints from a UnifiedBuffer reference.
The pointer and byte size are extracted from the buffer.
§Errors
Returns CudaError::InvalidValue if the buffer reports zero bytes
(should not happen for a validly constructed buffer).
Sourcepub fn set_read_mostly(&self, device: &Device) -> CudaResult<()>
pub fn set_read_mostly(&self, device: &Device) -> CudaResult<()>
Marks the region as read-mostly on device, enabling read replicas.
Sourcepub fn unset_read_mostly(&self, device: &Device) -> CudaResult<()>
pub fn unset_read_mostly(&self, device: &Device) -> CudaResult<()>
Removes the read-mostly hint for device.
Sourcepub fn set_preferred_location(&self, device: &Device) -> CudaResult<()>
pub fn set_preferred_location(&self, device: &Device) -> CudaResult<()>
Sets the preferred location to device for this region.
Sourcepub fn unset_preferred_location(&self, device: &Device) -> CudaResult<()>
pub fn unset_preferred_location(&self, device: &Device) -> CudaResult<()>
Removes the preferred-location hint for device.
Sourcepub fn set_accessed_by(&self, device: &Device) -> CudaResult<()>
pub fn set_accessed_by(&self, device: &Device) -> CudaResult<()>
Indicates that device will access this memory region.
Sourcepub fn unset_accessed_by(&self, device: &Device) -> CudaResult<()>
pub fn unset_accessed_by(&self, device: &Device) -> CudaResult<()>
Removes the accessed-by hint for device.
Sourcepub fn prefetch_to(&self, device: &Device, stream: &Stream) -> CudaResult<()>
pub fn prefetch_to(&self, device: &Device, stream: &Stream) -> CudaResult<()>
Prefetches the entire region to device on stream.
Sourcepub fn prefetch_range(
&self,
offset_bytes: usize,
count_bytes: usize,
device: &Device,
stream: &Stream,
) -> CudaResult<()>
pub fn prefetch_range( &self, offset_bytes: usize, count_bytes: usize, device: &Device, stream: &Stream, ) -> CudaResult<()>
Prefetches a sub-range of the region to device.
§Parameters
offset_bytes— byte offset from the start of the region.count_bytes— number of bytes to prefetch.
§Errors
Returns CudaError::InvalidValue if the range
[offset_bytes, offset_bytes + count_bytes) exceeds the buffer, or
if count_bytes is zero.
Sourcepub fn apply_policy(
&self,
policy: &MigrationPolicy,
device: &Device,
) -> CudaResult<()>
pub fn apply_policy( &self, policy: &MigrationPolicy, device: &Device, ) -> CudaResult<()>
Applies a MigrationPolicy to this memory region.
For MigrationPolicy::Default this is a no-op.
For other variants the corresponding advice hint(s) are issued.
Trait Implementations§
Source§impl Clone for ManagedMemoryHints
impl Clone for ManagedMemoryHints
Source§fn clone(&self) -> ManagedMemoryHints
fn clone(&self) -> ManagedMemoryHints
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more