MCPcopy Create free account
hub / github.com/Rust-GPU/rust-cuda / cuda_free_async

Function cuda_free_async

crates/cust/src/memory/malloc.rs:90–99  ·  view source on GitHub ↗

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>,
)

Source from the content-addressed store, hash-verified

88///
89/// The pointer must be valid.
90pub 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.

Callers 2

drop_asyncMethod · 0.85
drop_asyncMethod · 0.85

Calls 3

to_resultMethod · 0.45
as_rawMethod · 0.45
as_innerMethod · 0.45

Tested by

no test coverage detected