pub struct GpuBuffer<T> { /* private fields */ }Expand description
A typed buffer in GPU device memory, wrapping cudarc’s CudaSlice<T>.
Created via KaioDevice::alloc_from or KaioDevice::alloc_zeros.
§Memory management
GpuBuffer does not implement Drop manually — cudarc’s
CudaSlice handles device memory deallocation automatically when
the buffer is dropped. The CudaSlice holds an Arc<CudaContext>
internally, ensuring the CUDA context outlives the allocation.
Implementations§
Source§impl<T> GpuBuffer<T>
impl<T> GpuBuffer<T>
Source§impl<T: DeviceRepr + Default + Clone + Unpin> GpuBuffer<T>
impl<T: DeviceRepr + Default + Clone + Unpin> GpuBuffer<T>
Sourcepub fn to_host(&self, device: &KaioDevice) -> Result<Vec<T>>
pub fn to_host(&self, device: &KaioDevice) -> Result<Vec<T>>
Transfer buffer contents from device to host.
Requires a reference to the KaioDevice that created this buffer
(for stream access). The device is borrowed, not consumed.
§Example
ⓘ
let device = KaioDevice::new(0)?;
let buf = device.alloc_from(&[1.0f32, 2.0, 3.0])?;
let host_data = buf.to_host(&device)?;
assert_eq!(host_data, vec![1.0, 2.0, 3.0]);Auto Trait Implementations§
impl<T> Freeze for GpuBuffer<T>
impl<T> RefUnwindSafe for GpuBuffer<T>where
T: RefUnwindSafe,
impl<T> Send for GpuBuffer<T>
impl<T> Sync for GpuBuffer<T>
impl<T> Unpin for GpuBuffer<T>
impl<T> UnsafeUnpin for GpuBuffer<T>
impl<T> UnwindSafe for GpuBuffer<T>where
T: RefUnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more