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

Method uninitialized_async

crates/cust/src/memory/device/device_buffer.rs:73–83  ·  view source on GitHub ↗

Allocates device memory asynchronously on a stream, without initializing it. This doesn't actually allocate if `T` is zero sized. # Safety The allocated memory retains all of the unsafety of [`DeviceBuffer::uninitialized`], with the additional consideration that the memory cannot be used until it is actually allocated on the stream. This means proper stream ordering semantics must be followed,

(size: usize, stream: &Stream)

Source from the content-addressed store, hash-verified

71 ///
72 /// You can synchronize the stream to ensure the memory allocation operation is complete.
73 pub unsafe fn uninitialized_async(size: usize, stream: &Stream) -> CudaResult<Self> {
74 let ptr = if size > 0 && size_of::<T>() > 0 {
75 cuda_malloc_async(stream, size)?
76 } else {
77 DevicePointer::null()
78 };
79 Ok(DeviceBuffer {
80 buf: ptr,
81 len: size,
82 })
83 }
84
85 /// Enqueues an operation to free the memory backed by this [`DeviceBuffer`] on a
86 /// particular stream. The stream will free the allocation as soon as it reaches

Callers

nothing calls this directly

Calls 1

cuda_malloc_asyncFunction · 0.85

Tested by

no test coverage detected