Skip to main content

Module host_registered

Module host_registered 

Source
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 here

Structs§

RegisterFlags
Bitflags controlling how cuMemHostRegister registers host memory.
RegisteredMemory
RAII handle for host memory registered with the CUDA driver.
RegisteredPointerInfo
Information about a pointer registered with the CUDA driver.

Enums§

RegisteredMemoryType
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.