Skip to main content

Module virtual_memory

Module virtual_memory 

Source
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 CUDA virtual-memory management entry points (cuMemAddressReserve, cuMemCreate, cuMemMap, cuMemUnmap, cuMemSetAccess, cuMemRelease, cuMemAddressFree) are now wired through oxicuda-driver. Operations forward to the driver when it is available; on platforms without a CUDA driver (such as macOS), oxicuda_driver::loader::try_driver returns CudaError::NotInitialized. When the driver loads but a particular VMM symbol is missing (older drivers), the corresponding method returns CudaError::NotSupported.

§Example

use oxicuda_memory::virtual_memory::VirtualMemoryManager;

// 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);

Structs§

MappingRecord
A record of a virtual-to-physical memory mapping.
PhysicalAllocation
A physical memory allocation on a specific GPU device.
VirtualAddressRange
A reserved range of virtual addresses in the GPU address space.
VirtualMemoryManager
Manager for GPU virtual memory operations.

Enums§

AccessFlags
Memory access permission flags for virtual memory mappings.