Expand description
Type-safe device (GPU VRAM) memory buffer.
DeviceBuffer<T> owns a contiguous allocation of T elements in device
memory. It supports synchronous and asynchronous copies to/from host
memory, device-to-device copies, and zero-initialisation via cuMemsetD8.
The buffer is parameterised over T: Copy so that only plain-old-data
types can be stored — no heap pointers that would be meaningless on the
GPU.
§Ownership
The allocation is freed automatically when the buffer is dropped. If
cuMemFree_v2 fails during Drop, the error is logged via
tracing::warn rather than panicking.
§Example
let mut buf = DeviceBuffer::<f32>::alloc(1024)?;
let host_data = vec![1.0_f32; 1024];
buf.copy_from_host(&host_data)?;
let mut result = vec![0.0_f32; 1024];
buf.copy_to_host(&mut result)?;
assert_eq!(result, host_data);Structs§
- Device
Buffer - A contiguous buffer of
Telements allocated in GPU device memory. - Device
Slice - A borrowed, non-owning view into a sub-range of a
DeviceBuffer.