Skip to main content

ManagedMemoryHints

Struct ManagedMemoryHints 

Source
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

Source

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.

Source

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).

Source

pub fn ptr(&self) -> u64

Returns the device pointer this hint set targets.

Source

pub fn byte_size(&self) -> usize

Returns the byte size of the targeted region.

Source

pub fn set_read_mostly(&self, device: &Device) -> CudaResult<()>

Marks the region as read-mostly on device, enabling read replicas.

Source

pub fn unset_read_mostly(&self, device: &Device) -> CudaResult<()>

Removes the read-mostly hint for device.

Source

pub fn set_preferred_location(&self, device: &Device) -> CudaResult<()>

Sets the preferred location to device for this region.

Source

pub fn unset_preferred_location(&self, device: &Device) -> CudaResult<()>

Removes the preferred-location hint for device.

Source

pub fn set_accessed_by(&self, device: &Device) -> CudaResult<()>

Indicates that device will access this memory region.

Source

pub fn unset_accessed_by(&self, device: &Device) -> CudaResult<()>

Removes the accessed-by hint for device.

Source

pub fn prefetch_to(&self, device: &Device, stream: &Stream) -> CudaResult<()>

Prefetches the entire region to device on stream.

Source

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.

Source

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

Source§

fn clone(&self) -> ManagedMemoryHints

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ManagedMemoryHints

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more