Unsafe wrapper around `cuMemFreeAsync` which queues a memory allocation free operation on a stream. Retains all of the unsafe semantics of [`cuda_free`] with the extra requirement that the memory must not be used after it is dropped. Therefore, proper stream ordering semantics must be respected. # Safety The pointer must be valid.
(
stream: &Stream,
p: DevicePointer<T>,
)
| 88 | /// |
| 89 | /// The pointer must be valid. |
| 90 | pub unsafe fn cuda_free_async<T: DeviceCopy>( |
| 91 | stream: &Stream, |
| 92 | p: DevicePointer<T>, |
| 93 | ) -> CudaResult<()> { |
| 94 | if mem::size_of::<T>() == 0 { |
| 95 | return Err(CudaError::InvalidMemoryAllocation); |
| 96 | } |
| 97 | |
| 98 | cuda::cuMemFreeAsync(p.as_raw(), stream.as_inner()).to_result() |
| 99 | } |
| 100 | |
| 101 | /// Unsafe wrapper around the `cuMemAllocManaged` function, which allocates some unified memory and |
| 102 | /// returns a [`UnifiedPointer`](struct.UnifiedPointer.html) pointing to it. The memory is not cleared. |
no test coverage detected