Expand description
Host-registered memory for DMA access.
RegisteredMemory<T> wraps cuMemHostRegister / cuMemHostUnregister
to register existing host allocations with the CUDA driver, enabling DMA
transfers without an intermediate staging copy.
Unlike PinnedBuffer, which allocates new
page-locked memory, RegisteredMemory works with memory that has
already been allocated (e.g. a Vec<T>, a slice from a memory-mapped
file, etc.).
§Lifetime
The caller must ensure the underlying allocation outlives the
RegisteredMemory handle. The handle borrows (but does NOT own) the
memory. On Drop, only cuMemHostUnregister is called — the
original allocation is untouched.
§Example
let mut data = vec![0.0f32; 1024];
let reg = register_vec(&mut data, RegisterFlags::DEFAULT)?;
assert_eq!(reg.len(), 1024);
// `data` is now DMA-accessible; use `reg.device_ptr()` on the GPU side.
drop(reg); // cuMemHostUnregister is called hereStructs§
- Register
Flags - Bitflags controlling how
cuMemHostRegisterregisters host memory. - Registered
Memory - RAII handle for host memory registered with the CUDA driver.
- Registered
Pointer Info - Information about a pointer registered with the CUDA driver.
Enums§
- Registered
Memory Type - The type of memory backing a registered pointer.
Functions§
- query_
registered_ pointer_ info - Queries the CUDA driver for information about a registered pointer.
- register
- Registers an existing host memory range with the CUDA driver for DMA.
- register_
slice - Convenience: registers a mutable slice with the CUDA driver.
- register_
vec - Convenience: registers a
Vec<T>with the CUDA driver.