Skip to main content

Crate oxicuda_memory

Crate oxicuda_memory 

Source
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

TypeLocationDescription
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/managedAccessible from both host and device
MappedBuffer<T> (stub)Host-mappedZero-copy host memory (future)
MemoryPool (stub, pool feat)Device poolStream-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

FeatureDescription
poolEnable stream-ordered memory pool (CUDA 11.2+)
gpu-testsEnable 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.