Expand description
§OxiCUDA Memory
Type-safe GPU memory management with Rust ownership semantics.
oxicuda-memory provides safe, RAII-based wrappers around CUDA memory
allocation and transfer operations. Every buffer type owns its GPU (or
pinned-host) allocation and automatically frees it on Drop, preventing
leaks without requiring manual cleanup.
§Buffer types
| Type | Location | Description |
|---|---|---|
DeviceBuffer<T> | Device (VRAM) | Primary GPU-side buffer |
DeviceSlice<T> | Device (VRAM) | Borrowed sub-range of a device buffer |
PinnedBuffer<T> | Host (pinned) | Page-locked host memory for fast DMA |
UnifiedBuffer<T> | Unified/managed | Accessible from both host and device |
MappedBuffer<T> (stub) | Host-mapped | Zero-copy host memory (future) |
MemoryPool (stub, pool feat) | Device pool | Stream-ordered allocation (CUDA 11.2+) |
§Freestanding copy helpers
The copy module exposes explicit transfer functions that mirror the
CUDA driver cuMemcpy* family, with compile-time type safety and
runtime length validation.
§Safety philosophy
All public APIs return oxicuda_driver::error::CudaResult rather than panicking. Size
mismatches, zero-length allocations, and out-of-bounds slices are
reported as oxicuda_driver::error::CudaError::InvalidValue. Drop implementations log
errors via tracing::warn instead of panicking.
§Feature flags
| Feature | Description |
|---|---|
pool | Enable stream-ordered memory pool (CUDA 11.2+) |
gpu-tests | Enable integration tests that require a real GPU |
Re-exports§
pub use bandwidth_profiler::BandwidthBenchmarkConfig;pub use bandwidth_profiler::BandwidthMeasurement;pub use bandwidth_profiler::BandwidthProfiler;pub use bandwidth_profiler::BandwidthSummary;pub use bandwidth_profiler::DirectionSummary;pub use bandwidth_profiler::TransferDirection;pub use bandwidth_profiler::bandwidth_utilization;pub use bandwidth_profiler::describe_bandwidth;pub use bandwidth_profiler::estimate_transfer_time;pub use bandwidth_profiler::format_bytes;pub use bandwidth_profiler::theoretical_peak_bandwidth;pub use buffer_view::BufferView;pub use buffer_view::BufferViewMut;pub use copy_2d3d::Memcpy2DParams;pub use copy_2d3d::Memcpy3DParams;pub use device_buffer::DeviceBuffer;pub use device_buffer::DeviceSlice;pub use host_buffer::PinnedBuffer;pub use host_registered::RegisterFlags;pub use host_registered::RegisteredMemory;pub use host_registered::RegisteredMemoryType;pub use host_registered::RegisteredPointerInfo;pub use host_registered::query_registered_pointer_info;pub use host_registered::register;pub use host_registered::register_slice;pub use host_registered::register_vec;pub use managed_hints::ManagedMemoryHints;pub use managed_hints::MigrationPolicy;pub use managed_hints::PrefetchPlan;pub use memory_info::MemAdvice;pub use memory_info::MemoryInfo;pub use memory_info::mem_advise;pub use memory_info::mem_prefetch;pub use memory_info::memory_info;pub use unified::UnifiedBuffer;pub use virtual_memory::AccessFlags;pub use virtual_memory::PhysicalAllocation;pub use virtual_memory::VirtualAddressRange;pub use virtual_memory::VirtualMemoryManager;pub use zero_copy::MappedBuffer;pub use aligned::AlignedBuffer;pub use aligned::Alignment;pub use aligned::AlignmentInfo;pub use aligned::check_alignment;pub use aligned::coalesce_alignment;pub use aligned::optimal_alignment_for_type;pub use aligned::round_up_to_alignment;pub use aligned::validate_alignment;pub use pool_stats::AllocationHistogram;pub use pool_stats::FragmentationMetrics;pub use pool_stats::PoolReport;pub use pool_stats::PoolStatsTracker;
Modules§
- aligned
- Aligned GPU memory allocation for optimal access patterns.
- bandwidth_
profiler - Memory bandwidth profiling and throughput measurement.
- buffer_
view - Type-safe buffer reinterpretation for device memory.
- copy
- Explicit memory copy operations between host and device.
- copy_
2d3d - 2D and 3D memory copy operations for pitched and volumetric data.
- device_
buffer - Type-safe device (GPU VRAM) memory buffer.
- features
- Compile-time feature availability.
- host_
buffer - Pinned (page-locked) host memory buffer.
- host_
registered - Host-registered memory for DMA access.
- managed_
hints - Ergonomic managed memory hints API.
- memory_
info - GPU memory usage queries and unified memory hints.
- peer_
copy - Peer-to-peer (P2P) memory copy operations for multi-GPU workloads.
- pool_
stats - Enhanced memory pool statistics and allocation tracking.
- prelude
- Convenient glob import for common OxiCUDA Memory types.
- unified
- Unified (managed) memory buffer.
- virtual_
memory - Virtual memory management for fine-grained GPU address space control.
- zero_
copy - Zero-copy (host-mapped) memory.