Skip to main content

apply_migration_policy

Function apply_migration_policy 

Source
pub fn apply_migration_policy(
    ptr: u64,
    byte_size: usize,
    policy: &MigrationPolicy,
    device: &Device,
) -> CudaResult<()>
Expand description

Applies a MigrationPolicy to a raw unified memory region.

This is a convenience function that translates the high-level policy into the appropriate mem_advise calls.

§Parameters

  • ptr — device pointer to the managed allocation.
  • byte_size — size of the region in bytes.
  • policy — the migration policy to apply.
  • device — the device to which hints are directed for MigrationPolicy::ReadMostly. Ignored by MigrationPolicy::PreferHost (which always targets the CPU) and by MigrationPolicy::PreferDevice (which resolves its own ordinal via Device::get instead, so the advice always targets the ordinal the caller declared in the policy rather than whatever device happens to be).

§Errors

Forwards any error from the underlying driver call, including CudaError::InvalidDevice if MigrationPolicy::PreferDevice’s ordinal does not name a valid device. Returns CudaError::InvalidValue if byte_size is zero (when policy is not Default).