pub unsafe fn cuda_free<T: DeviceCopy>(ptr: DevicePointer<T>) -> CudaResult<()>
Expand description
Free memory allocated with cuda_malloc
.
Errors
If freeing memory fails, returns the CUDA error value. If the given pointer is null, returns InvalidValue.
Safety
The given pointer must have been allocated with cuda_malloc
, or null.
The caller is responsible for ensuring that no other pointers to the deallocated buffer exist.
Examples
use cust::memory::*;
unsafe {
let device_buffer = cuda_malloc::<u64>(5).unwrap();
// Free allocated memory.
cuda_free(device_buffer).unwrap();
}