Skip to main content

VirtualMemoryManager

Struct VirtualMemoryManager 

Source
pub struct VirtualMemoryManager;
Expand description

Manager for GPU virtual memory operations.

Provides methods for reserving virtual address ranges, allocating physical memory, mapping/unmapping, and setting access permissions.

§Status

The underlying CUDA virtual memory driver functions (cuMemAddressReserve, cuMemCreate, cuMemMap, cuMemUnmap, cuMemSetAccess) are not yet loaded in oxicuda-driver. All methods that would require driver calls return CudaError::NotSupported.

The reserve method creates a local placeholder object for planning purposes.

Implementations§

Source§

impl VirtualMemoryManager

Source

pub fn reserve(size: usize, alignment: usize) -> CudaResult<VirtualAddressRange>

Reserves a range of virtual addresses in the GPU address space.

The reserved range is not backed by physical memory until map is called.

§Parameters
  • size - Size of the virtual range to reserve in bytes. Must be a multiple of alignment.
  • alignment - Alignment requirement in bytes. Must be a power of two and non-zero.
§Errors
  • CudaError::InvalidValue if size is zero, alignment is zero, alignment is not a power of two, or size is not a multiple of alignment.
Source

pub fn release(_va: VirtualAddressRange) -> CudaResult<()>

Releases a previously reserved virtual address range.

After this call, the virtual addresses are no longer reserved and may be reused by future reservations.

§Errors

Returns CudaError::NotSupported because the driver function cuMemAddressFree is not yet loaded.

Source

pub fn alloc_physical( size: usize, device_ordinal: i32, ) -> CudaResult<PhysicalAllocation>

Allocates physical memory on the specified device.

The allocated memory is not accessible until mapped into a virtual address range via map.

§Parameters
  • size - Size of the allocation in bytes. Must be non-zero.
  • device_ordinal - Ordinal of the device to allocate on.
§Errors
Source

pub fn free_physical(_phys: PhysicalAllocation) -> CudaResult<()>

Frees a physical memory allocation.

The allocation must not be currently mapped to any virtual range.

§Errors

Returns CudaError::NotSupported because the driver function cuMemRelease is not yet loaded.

Source

pub fn map( va: &VirtualAddressRange, phys: &PhysicalAllocation, offset: usize, ) -> CudaResult<()>

Maps a physical allocation to a region of a virtual address range.

After mapping, GPU kernels can access the virtual addresses and reads/writes will be routed to the physical memory.

§Parameters
  • va - The virtual address range to map into.
  • phys - The physical allocation to map.
  • offset - Byte offset within the virtual range at which to start the mapping. Must be aligned to the VA’s alignment.
§Errors
Source

pub fn unmap( va: &VirtualAddressRange, offset: usize, size: usize, ) -> CudaResult<()>

Unmaps a region of a virtual address range.

After unmapping, accesses to the affected virtual addresses will fault. The physical memory is not freed — it can be remapped elsewhere.

§Parameters
  • va - The virtual address range to unmap from.
  • offset - Byte offset within the range where unmapping starts.
  • size - Number of bytes to unmap.
§Errors
Source

pub fn set_access( _va: &VirtualAddressRange, _device_ordinal: i32, _flags: AccessFlags, ) -> CudaResult<()>

Sets access permissions for a virtual address range on a device.

This controls whether the specified device can read and/or write to the mapped virtual addresses.

§Parameters
  • va - The virtual address range to set permissions on.
  • device_ordinal - The device to grant/deny access for.
  • flags - The access permission flags.
§Errors

Returns CudaError::NotSupported because the driver function cuMemSetAccess is not yet loaded.

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> 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, 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