CachingAllocator
darkforest-cuda
module: allocator
since v0.1.1-alpha
Signature
rust
pub struct CachingAllocator { free_blocks: BTreeMap<usize, Vec<CudaPtr>>, active_allocations: HashMap<*mut c_void, usize> }
Overview
Sub-allocator for CUDA device memory that pools GPU buffers to prevent synchronous cudaMalloc stalls.
Invariants & Design Principles
- Invariant: Blocks rounded to 512-byte boundaries.
- Invariant: Thread-safe locking over allocation map.
- Invariant: Async release via cudaStreamQuery.
Usage Example
rust
let allocator = CachingAllocator::new(0);