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
impl VirtualMemoryManager
Sourcepub fn reserve(size: usize, alignment: usize) -> CudaResult<VirtualAddressRange>
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 ofalignment.alignment- Alignment requirement in bytes. Must be a power of two and non-zero.
§Errors
CudaError::InvalidValueifsizeis zero,alignmentis zero,alignmentis not a power of two, orsizeis not a multiple ofalignment.
Sourcepub fn release(_va: VirtualAddressRange) -> CudaResult<()>
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.
Sourcepub fn alloc_physical(
size: usize,
device_ordinal: i32,
) -> CudaResult<PhysicalAllocation>
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
CudaError::InvalidValueifsizeis zero.CudaError::NotSupportedbecause the driver functioncuMemCreateis not yet loaded.
Sourcepub fn free_physical(_phys: PhysicalAllocation) -> CudaResult<()>
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.
Sourcepub fn map(
va: &VirtualAddressRange,
phys: &PhysicalAllocation,
offset: usize,
) -> CudaResult<()>
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
CudaError::InvalidValueifoffsetis not aligned, or if the physical allocation would extend past the end of the virtual range.CudaError::NotSupportedbecause the driver functioncuMemMapis not yet loaded.
Sourcepub fn unmap(
va: &VirtualAddressRange,
offset: usize,
size: usize,
) -> CudaResult<()>
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
CudaError::InvalidValueif the offset+size exceeds the virtual range bounds.CudaError::NotSupportedbecause the driver functioncuMemUnmapis not yet loaded.
Sourcepub fn set_access(
_va: &VirtualAddressRange,
_device_ordinal: i32,
_flags: AccessFlags,
) -> CudaResult<()>
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.