Expand description
Virtual memory management for fine-grained GPU address space control.
This module provides abstractions for CUDA’s virtual memory management
API (cuMemAddressReserve, cuMemCreate, cuMemMap, etc.), which
allows separating the concepts of virtual address reservation and
physical memory allocation.
§Concepts
-
Virtual Address Range — A reservation of contiguous virtual addresses in the GPU address space. No physical memory is committed until explicitly mapped.
-
Physical Allocation — A chunk of physical GPU memory that can be mapped to one or more virtual address ranges.
-
Mapping — The association of a physical allocation with a region of a virtual address range.
§Use Cases
-
Sparse arrays — Reserve a large virtual range but only commit physical memory for the tiles/pages that are actually used.
-
Resizable buffers — Reserve a large virtual range up-front and map additional physical memory as the buffer grows, without changing the base address.
-
Multi-GPU memory — Map physical allocations from different devices into the same virtual address space.
§Status
The virtual memory driver functions are not yet loaded in
oxicuda-driver. All operations that would require driver calls
currently return CudaError::NotSupported. The data structures
are fully functional for planning and validation purposes.
§Example
use oxicuda_memory::virtual_memory::{
VirtualAddressRange, PhysicalAllocation, VirtualMemoryManager, AccessFlags,
};
// Reserve 1 GiB of virtual address space with 2 MiB alignment.
let va = VirtualMemoryManager::reserve(1 << 30, 1 << 21)?;
assert_eq!(va.size(), 1 << 30);
// The actual GPU calls are not yet available, so alloc/map/unmap
// return NotSupported.Structs§
- Mapping
Record - A record of a virtual-to-physical memory mapping.
- Physical
Allocation - A physical memory allocation on a specific GPU device.
- Virtual
Address Range - A reserved range of virtual addresses in the GPU address space.
- Virtual
Memory Manager - Manager for GPU virtual memory operations.
Enums§
- Access
Flags - Memory access permission flags for virtual memory mappings.