pub struct DeviceMemory<T> { /* private fields */ }Expand description
Represents a region of owned CUDA device memory for elements of type T.
The last owner of the allocation frees it with cudaFree, or, for a stream-ordered allocation, enqueues cudaFreeAsync on its stream.
Implementations§
Source§impl<T> DeviceMemory<T>
impl<T> DeviceMemory<T>
Sourcepub fn copy_from_host(&mut self, host_slice: &[T]) -> Result<()>where
T: DeviceRepr,
pub fn copy_from_host(&mut self, host_slice: &[T]) -> Result<()>where
T: DeviceRepr,
Copies host values and waits until the device range contains the uploaded values.
§Errors
Returns an error for unequal element counts or byte-size overflow. Also propagates access-tracking, readiness synchronization, context-binding, stream-capture, CUDA copy, and stream synchronization errors. A nonempty synchronous transfer is rejected during stream capture.
Sourcepub fn copy_from_pinned<B>(&mut self, src: &B) -> Result<()>
pub fn copy_from_pinned<B>(&mut self, src: &B) -> Result<()>
Copies from page-locked host memory into this device allocation.
The source length must match this allocation’s length.
This is the pinned-memory-specific counterpart to DeviceMemory::copy_from_host.
§Errors
Returns an error if the lengths differ, byte-size arithmetic overflows, or CUDA rejects the host-to-device copy.
Sourcepub fn copy_from_pinned_scoped<'env, B>(
&'env mut self,
src: &'env B,
stream: &StreamScope<'_, 'env>,
) -> Result<()>
pub fn copy_from_pinned_scoped<'env, B>( &'env mut self, src: &'env B, stream: &StreamScope<'_, 'env>, ) -> Result<()>
Enqueues a copy from page-locked host memory into this device allocation.
The StreamScope ties the source and destination lifetimes to the queued copy.
§Errors
Returns an error if the lengths differ, byte-size arithmetic overflows, or CUDA cannot enqueue the host-to-device copy.
Sourcepub fn copy_from_host_scoped<'env>(
&'env mut self,
host_slice: &'env [T],
stream: &StreamScope<'_, 'env>,
) -> Result<()>where
T: DeviceRepr,
pub fn copy_from_host_scoped<'env>(
&'env mut self,
host_slice: &'env [T],
stream: &StreamScope<'_, 'env>,
) -> Result<()>where
T: DeviceRepr,
Enqueues a host-to-device copy of the entire allocation in a stream scope.
The scope retains both borrows until the transfer completes.
§Errors
Returns an error if the element counts differ, the byte count overflows, or the scope’s stream belongs to another context. Also propagates context-binding, scope submission, and CUDA copy errors.
Sourcepub unsafe fn copy_from_host_async(
&mut self,
host_slice: &[T],
stream: &Stream,
) -> Result<()>
pub unsafe fn copy_from_host_async( &mut self, host_slice: &[T], stream: &Stream, ) -> Result<()>
Enqueues a copy of host_slice into this allocation on stream.
§Safety
The caller must ensure self and host_slice both remain valid until stream has completed the transfer.
§Errors
Returns an error if the host and device element counts differ, the stream belongs to another context, or the byte count overflows. Also propagates context-binding, producer-ordering, and CUDA asynchronous copy errors.
Sourcepub fn copy_to_host(&self, host_slice: &mut [T]) -> Result<()>where
T: AnyBitPatternDeviceRepr,
pub fn copy_to_host(&self, host_slice: &mut [T]) -> Result<()>where
T: AnyBitPatternDeviceRepr,
Copies all device elements into an equally sized host slice and waits for completion.
§Errors
Returns an error for unequal element counts or byte-size overflow. Also propagates access-tracking, readiness synchronization, context-binding, stream-capture, CUDA copy, and stream synchronization errors. A nonempty synchronous transfer is rejected during stream capture.
Sourcepub unsafe fn copy_to_host_unchecked(&self, host_slice: &mut [T]) -> Result<()>where
T: DeviceRepr,
pub unsafe fn copy_to_host_unchecked(&self, host_slice: &mut [T]) -> Result<()>where
T: DeviceRepr,
Copies device values to host storage under a kernel-specific validity contract.
§Safety
Every source element must be initialized and contain a valid value of T.
T must be transferable without duplicating ownership or host references.
§Errors
Returns an error if host and device element counts differ or the byte count overflows. Also propagates access-tracking, readiness synchronization, context-binding, stream-capture, CUDA copy, and stream synchronization errors. A nonempty synchronous transfer is rejected during stream capture.
Sourcepub fn copy_to_pinned<B>(&self, dst: &mut B) -> Result<()>
pub fn copy_to_pinned<B>(&self, dst: &mut B) -> Result<()>
Copies this device allocation into page-locked host memory.
The destination length must match this allocation’s length.
This is the pinned-memory-specific counterpart to DeviceMemory::copy_to_host.
§Errors
Returns an error if the lengths differ, byte-size arithmetic overflows, or CUDA rejects the device-to-host copy.
Sourcepub fn copy_to_pinned_scoped<'env, B>(
&'env self,
dst: &'env mut B,
stream: &StreamScope<'_, 'env>,
) -> Result<()>
pub fn copy_to_pinned_scoped<'env, B>( &'env self, dst: &'env mut B, stream: &StreamScope<'_, 'env>, ) -> Result<()>
Enqueues a copy from this device allocation into page-locked host memory.
The StreamScope ties the source and destination lifetimes to the queued copy.
§Errors
Returns an error if the lengths differ, byte-size arithmetic overflows, or CUDA cannot enqueue the device-to-host copy.
Sourcepub fn copy_to_host_scoped<'env>(
&'env self,
host_slice: &'env mut [T],
stream: &StreamScope<'_, 'env>,
) -> Result<()>where
T: AnyBitPatternDeviceRepr,
pub fn copy_to_host_scoped<'env>(
&'env self,
host_slice: &'env mut [T],
stream: &StreamScope<'_, 'env>,
) -> Result<()>where
T: AnyBitPatternDeviceRepr,
Enqueues a device-to-host copy of the entire allocation in a stream scope.
The scope retains the source and exclusive destination borrows until the transfer completes.
§Errors
Returns an error if the element counts differ, the byte count overflows, or the scope’s stream belongs to another context. Also propagates context-binding, scope submission, and CUDA copy errors.
Sourcepub unsafe fn copy_to_host_async(
&self,
host_slice: &mut [T],
stream: &Stream,
) -> Result<()>
pub unsafe fn copy_to_host_async( &self, host_slice: &mut [T], stream: &Stream, ) -> Result<()>
Enqueues a copy of this allocation into host_slice on stream.
§Safety
The caller must ensure self and host_slice both remain valid until stream has completed the transfer.
Every source element must be initialized and valid for T, without Rust ownership or host references.
§Errors
Returns an error if the host and device element counts differ, the stream belongs to another context, or the byte count overflows. Also propagates context-binding, producer-ordering, and CUDA asynchronous copy errors.
Sourcepub fn copy_to_host_vec(&self) -> Result<Vec<T>>where
T: AnyBitPatternDeviceRepr,
pub fn copy_to_host_vec(&self) -> Result<Vec<T>>where
T: AnyBitPatternDeviceRepr,
Copies all device elements into a new host vector and waits for completion.
§Errors
Propagates byte-size overflow, access-tracking, readiness synchronization, context-binding, stream-capture, CUDA copy, and stream synchronization errors. A nonempty synchronous transfer is rejected during stream capture.
Sourcepub unsafe fn copy_to_host_vec_unchecked(&self) -> Result<Vec<T>>
pub unsafe fn copy_to_host_vec_unchecked(&self) -> Result<Vec<T>>
Copies initialized device values into a host vector under a kernel-specific validity contract.
§Safety
Every source element must contain a valid value of T.
T must be transferable without duplicating ownership or host references.
§Errors
Propagates byte-size, access-tracking, readiness synchronization, context-binding, stream-capture, CUDA copy, and stream synchronization errors. A nonempty synchronous transfer is rejected during stream capture.
Sourcepub fn copy_from_device<S>(&mut self, source: &S) -> Result<()>
pub fn copy_from_device<S>(&mut self, source: &S) -> Result<()>
Copies a disjoint device range into this allocation and waits for completion.
§Errors
Returns an error if contexts or element counts differ, the ranges overlap within one allocation, or the byte count overflows. Also propagates access-tracking, readiness synchronization, context-binding, stream-capture, CUDA copy, and stream synchronization errors. A nonempty synchronous transfer is rejected during stream capture.
Sourcepub fn copy_from_device_scoped<'env>(
&'env mut self,
src: &'env Self,
stream: &StreamScope<'_, 'env>,
) -> Result<()>
pub fn copy_from_device_scoped<'env>( &'env mut self, src: &'env Self, stream: &StreamScope<'_, 'env>, ) -> Result<()>
Enqueues a device-to-device copy of the entire allocation in a stream scope.
The scope retains both borrows until the transfer completes.
§Errors
Returns an error if source and destination contexts or element counts differ, the byte count overflows, or the scope’s stream belongs to another context. Also propagates context-binding, scope submission, and CUDA copy errors.
Sourcepub unsafe fn copy_from_device_async(
&mut self,
src: &Self,
stream: &Stream,
) -> Result<()>
pub unsafe fn copy_from_device_async( &mut self, src: &Self, stream: &Stream, ) -> Result<()>
Enqueues a copy of src into this allocation on stream.
§Safety
The caller must ensure self and src both remain valid until stream has completed the transfer.
§Errors
Returns an error if source and destination contexts or element counts differ, the stream belongs to another context, or the byte count overflows. Also propagates context-binding, producer-ordering, and CUDA asynchronous copy errors.
Source§impl<T> DeviceMemory<T>
Associated utility functions.
impl<T> DeviceMemory<T>
Associated utility functions.
Sourcepub unsafe fn alloc(context: &Context, count: usize) -> Result<*mut T>
pub unsafe fn alloc(context: &Context, count: usize) -> Result<*mut T>
Allocates uninitialized linear device memory for count elements and returns its pointer.
The memory is aligned for any element type and is not cleared.
An allocation failure returns crate::error::Status::OutOfMemory.
A zero-byte request returns a null pointer without calling CUDA.
§Safety
The returned pointer is uninitialized device memory.
The caller must use it only for count elements of T and eventually free it with a compatible CUDA free function.
§Errors
Returns an error if context cannot be bound, the requested byte size overflows, CUDA cannot allocate device memory, a previous asynchronous launch reports an error, or CUDA reports runtime initialization diagnostics such as crate::error::Status::NotInitialized, crate::error::Status::CallRequiresNewerDriver, or crate::error::Status::NoDevice.
Sourcepub unsafe fn alloc_managed(
context: &Context,
count: usize,
flags: MemoryAttachFlags,
) -> Result<*mut T>
pub unsafe fn alloc_managed( context: &Context, count: usize, flags: MemoryAttachFlags, ) -> Result<*mut T>
Allocates CUDA managed memory for count elements.
flags controls the initial stream attachment behavior for the managed allocation.
§Safety
The returned pointer is managed CUDA memory. The caller must eventually free it with a CUDA-compatible device free and must synchronize host and device access according to CUDA managed-memory rules.
§Errors
Returns an error if context cannot be bound, the requested byte size overflows, CUDA cannot allocate managed memory, or count is non-zero for a zero-sized T.
Sourcepub unsafe fn free(context: &Context, ptr: *mut T) -> Result<()>
pub unsafe fn free(context: &Context, ptr: *mut T) -> Result<()>
Frees the device allocation at ptr.
This does not synchronize when the pointer came from the stream-ordered allocator, such as DeviceMemory::alloc_async.
For best performance and memory reuse, free such memory with DeviceMemory::free_async instead.
For all other pointers, this call may synchronize implicitly.
If ptr is null, no operation is performed.
§Safety
ptr must be null or a live allocation of context returned by a CUDA device allocation function, and not freed before.
All work that accesses it must have completed, no work may access it afterwards, and no allocation owner may free it again.
§Errors
Returns an error if context cannot be bound, CUDA cannot free ptr, a previous asynchronous launch reports an error, or CUDA reports runtime initialization diagnostics.
Sourcepub unsafe fn alloc_pitched(
context: &Context,
width: usize,
height: usize,
) -> Result<(*mut T, usize)>
pub unsafe fn alloc_pitched( context: &Context, width: usize, height: usize, ) -> Result<(*mut T, usize)>
Allocates 2D pitched device memory and returns the base pointer and row pitch in bytes.
width is measured in elements of T, while the returned pitch is measured in bytes.
CUDA may pad each row so that row-to-row addressing satisfies device alignment requirements.
§Safety
The returned pointer is uninitialized device memory.
The caller must use it only as a width by height pitched allocation with the returned pitch and eventually free it with a CUDA-compatible device free.
§Errors
Returns an error if context cannot be bound, the requested byte size overflows, T is a non-empty zero-sized allocation, CUDA cannot allocate pitched memory, or CUDA returns a null allocation for a non-empty request.
Sourcepub unsafe fn alloc_pitched_3d(
context: &Context,
width: usize,
height: usize,
depth: usize,
) -> Result<cudaPitchedPtr>
pub unsafe fn alloc_pitched_3d( context: &Context, width: usize, height: usize, depth: usize, ) -> Result<cudaPitchedPtr>
Allocates 3D pitched device memory and returns CUDA’s pitched pointer descriptor.
width is measured in elements of T.
CUDA’s cudaPitchedPtr::pitch and xsize fields are measured in bytes for linear memory, and ysize records the logical height.
§Safety
The returned allocation is uninitialized device memory.
The caller must treat it as a width by height by depth pitched allocation and free the base pointer with a CUDA-compatible device free.
§Errors
Returns an error if context cannot be bound, the requested byte volume overflows, T is a non-empty zero-sized allocation, CUDA cannot allocate pitched memory, or CUDA returns a null allocation for a non-empty request.
Sourcepub unsafe fn copy(
context: &Context,
dst: *mut T,
src: *const T,
count: usize,
kind: MemoryCopyKind,
) -> Result<()>
pub unsafe fn copy( context: &Context, dst: *mut T, src: *const T, count: usize, kind: MemoryCopyKind, ) -> Result<()>
Copies count elements from src to dst.
The transfer direction is specified by MemoryCopyKind.
MemoryCopyKind::Default is recommended when unified virtual addressing is available, in which case the transfer direction is inferred from the pointer values.
Calling DeviceMemory::copy with dst and src pointers that do not match the direction of the copy results in undefined behavior.
The copy is synchronous with respect to the host for most pointer combinations.
Each range must be entirely registered with CUDA or, for pageable host transfers, not registered at all.
A range spanning registered and unregistered allocations returns crate::error::Status::InvalidValue.
§Safety
Device operands must belong to context or be accessible from it.
src and dst must be valid for count elements of T according to kind, and the source and destination regions must not overlap unless CUDA permits that transfer.
§Errors
Returns an error if context cannot be bound, the requested byte count overflows, CUDA rejects the pointer combination or copy kind, a previous asynchronous launch reports an error, or CUDA reports runtime initialization diagnostics.
Sourcepub unsafe fn copy_2d(
context: &Context,
dst: *mut T,
dst_pitch: usize,
src: *const T,
src_pitch: usize,
width: usize,
height: usize,
kind: MemoryCopyKind,
) -> Result<()>
pub unsafe fn copy_2d( context: &Context, dst: *mut T, dst_pitch: usize, src: *const T, src_pitch: usize, width: usize, height: usize, kind: MemoryCopyKind, ) -> Result<()>
Copies a typed 2D rectangle between pitched host or device memory regions.
width and height are measured in elements and rows.
dst_pitch and src_pitch are byte strides between adjacent rows.
§Safety
Device operands must belong to context or be accessible from it.
dst and src must be valid for the described rectangle according to kind.
The source and destination regions must not overlap unless CUDA permits that transfer.
§Errors
Returns an error if context cannot be bound, the requested byte rectangle overflows, either pitch is smaller than the copied row width, CUDA rejects the pointer combination or copy kind, or a previous asynchronous launch reports an error.
Sourcepub unsafe fn copy_2d_async(
dst: *mut T,
dst_pitch: usize,
src: *const T,
src_pitch: usize,
width: usize,
height: usize,
kind: MemoryCopyKind,
stream: &Stream,
) -> Result<()>
pub unsafe fn copy_2d_async( dst: *mut T, dst_pitch: usize, src: *const T, src_pitch: usize, width: usize, height: usize, kind: MemoryCopyKind, stream: &Stream, ) -> Result<()>
Enqueues a typed 2D rectangle copy on stream.
width and height are measured in elements and rows.
Pitches are byte strides between adjacent rows.
§Safety
dst and src must remain valid for the described rectangle until stream reaches the enqueued copy.
The pointer combination must match kind.
§Errors
Returns an error if the stream context cannot be bound, the requested byte rectangle overflows, either pitch is smaller than the copied row width, CUDA cannot enqueue the copy, or a previous asynchronous launch reports an error.
Sourcepub unsafe fn copy_3d(
context: &Context,
dst: cudaPitchedPtr,
src: cudaPitchedPtr,
width: usize,
height: usize,
depth: usize,
kind: MemoryCopyKind,
) -> Result<()>
pub unsafe fn copy_3d( context: &Context, dst: cudaPitchedPtr, src: cudaPitchedPtr, width: usize, height: usize, depth: usize, kind: MemoryCopyKind, ) -> Result<()>
Copies a typed 3D extent between CUDA pitched pointer operands.
width, height, and depth are measured in elements, rows, and slices.
CUDA receives an extent whose width is converted to bytes.
§Safety
Device operands must belong to context or be accessible from it.
dst and src must describe live host or device memory large enough for the requested extent according to kind.
The source and destination regions must not overlap unless CUDA permits that transfer.
§Errors
Returns an error if context cannot be bound, the requested byte volume overflows, either pitch is smaller than the copied row width, CUDA rejects the copy parameters, or a previous asynchronous launch reports an error.
Sourcepub unsafe fn copy_3d_async(
dst: cudaPitchedPtr,
src: cudaPitchedPtr,
width: usize,
height: usize,
depth: usize,
kind: MemoryCopyKind,
stream: &Stream,
) -> Result<()>
pub unsafe fn copy_3d_async( dst: cudaPitchedPtr, src: cudaPitchedPtr, width: usize, height: usize, depth: usize, kind: MemoryCopyKind, stream: &Stream, ) -> Result<()>
Enqueues a typed 3D extent copy on stream.
width, height, and depth are measured in elements, rows, and slices.
CUDA receives an extent whose width is converted to bytes.
§Safety
dst and src must remain valid for the described extent until stream reaches the enqueued copy.
The pointer combination must match kind.
§Errors
Returns an error if the stream context cannot be bound, the requested byte volume overflows, either pitch is smaller than the copied row width, CUDA cannot enqueue the copy, or a previous asynchronous launch reports an error.
Sourcepub unsafe fn set(
context: &Context,
dst: *mut T,
value: u8,
count: usize,
) -> Result<()>
pub unsafe fn set( context: &Context, dst: *mut T, value: u8, count: usize, ) -> Result<()>
Fills count elements at dst with the constant byte pattern value.
This call is asynchronous with respect to the host unless ptr refers to pinned host memory.
See the CUDA memset synchronization rules for when this operation blocks the host.
§Safety
Device operands must belong to context or be accessible from it.
dst must be valid for writes of count * size_of::<T>() bytes and must refer to memory that CUDA can memset.
§Errors
Returns an error if context cannot be bound, the requested byte count overflows, CUDA rejects the pointer or size, a previous asynchronous launch reports an error, or CUDA reports runtime initialization diagnostics.
Sourcepub unsafe fn set_2d(
context: &Context,
dst: *mut T,
pitch: usize,
value: u8,
width: usize,
height: usize,
) -> Result<()>
pub unsafe fn set_2d( context: &Context, dst: *mut T, pitch: usize, value: u8, width: usize, height: usize, ) -> Result<()>
Fills a typed 2D pitched memory region with a byte value.
width and height are measured in elements and rows.
pitch is the byte stride between adjacent rows.
§Safety
Device operands must belong to context or be accessible from it.
dst must be valid for writes over the described pitched rectangle and must refer to memory CUDA can memset.
§Errors
Returns an error if context cannot be bound, the requested byte rectangle overflows, pitch is smaller than the row width, CUDA rejects the memory region, or a previous asynchronous launch reports an error.
Sourcepub unsafe fn set_3d(
context: &Context,
dst: cudaPitchedPtr,
value: u8,
width: usize,
height: usize,
depth: usize,
) -> Result<()>
pub unsafe fn set_3d( context: &Context, dst: cudaPitchedPtr, value: u8, width: usize, height: usize, depth: usize, ) -> Result<()>
Fills a typed 3D pitched memory region with a byte value.
width, height, and depth are measured in elements, rows, and slices.
CUDA receives an extent whose width is converted to bytes.
§Safety
Device operands must belong to context or be accessible from it.
dst must describe live memory large enough for the requested extent and must refer to memory CUDA can memset.
§Errors
Returns an error if context cannot be bound, the requested byte volume overflows, dst.pitch is smaller than the row width, CUDA rejects the memory region, or a previous asynchronous launch reports an error.
Sourcepub fn memory_info(context: &Context) -> Result<(usize, usize)>
pub fn memory_info(context: &Context) -> Result<(usize, usize)>
Returns the free and total device memory, in bytes, seen from context.
CUDA is not guaranteed to be able to allocate all of the memory that the OS reports as free.
In a multi-tenant situation, the free-memory estimate is prone to a race condition: an allocation or free by another process or thread between estimation and reporting can make the reported free value differ from actual free memory.
The integrated GPU on Tegra shares memory with CPU and other component of the SoC.
The free and total values returned by this call exclude the SWAP memory space maintained by the OS on some platforms.
The OS may move some of the memory pages into swap area as the GPU or CPU allocate or access memory.
See Tegra app note on how to calculate total and free memory on Tegra.
§Errors
Returns an error if context cannot be bound, CUDA cannot query memory information, a previous asynchronous launch reports an error, or CUDA reports runtime initialization diagnostics.
Sourcepub fn pointer_attributes(ptr: *const T) -> Result<PointerAttributes>
pub fn pointer_attributes(ptr: *const T) -> Result<PointerAttributes>
Returns the attributes of ptr.
If ptr was not allocated in, mapped by, or registered with a context that supports unified addressing, crate::error::Status::InvalidValue is returned.
In CUDA 11.0 and later, passing a host pointer reports MemoryType::Unregistered in PointerAttributes::memory_type.
-
PointerAttributes::memory_typeidentifies the type of memory. It can beMemoryType::Unregisteredfor unregistered host memory,MemoryType::Hostfor registered host memory,MemoryType::Devicefor device memory, orMemoryType::Managedfor managed memory. -
PointerAttributes::deviceis the device against whichptrwas allocated. Ifptrhas memory typeMemoryType::Device, this identifies the device on which the memory physically resides. Ifptrhas memory typeMemoryType::Host, this identifies the device that was current when the allocation was made, and if that device is deinitialized then this allocation will vanish with that device’s state. -
PointerAttributes::device_pointeris the device pointer alias through which the memory referred to byptrmay be accessed on the current device. If the memory referred to byptrcannot be accessed directly by the current device then this is null. -
PointerAttributes::host_pointeris the host pointer alias through which the memory referred to byptrmay be accessed on the host. If the memory referred to byptrcannot be accessed directly by the host then this is null.
§Errors
Returns an error if CUDA cannot query attributes for ptr, ptr is not known to a unified-addressing context, or CUDA reports runtime initialization diagnostics.
Sourcepub unsafe fn alloc_async(count: usize, stream: &Stream) -> Result<*mut T>
pub unsafe fn alloc_async(count: usize, stream: &Stream) -> Result<*mut T>
Enqueues a stream-ordered device allocation on stream.
§Safety
The returned pointer is uninitialized device memory whose lifetime is ordered by stream.
The caller must ensure all accesses are stream ordered correctly and free it with DeviceMemory::free_async or a compatible CUDA free after all accesses complete.
§Errors
Returns an error if the stream context cannot be bound, the requested byte size overflows, CUDA cannot enqueue the allocation, or count is non-zero for a zero-sized T.
Sourcepub unsafe fn free_async(ptr: *mut T, stream: &Stream) -> Result<()>
pub unsafe fn free_async(ptr: *mut T, stream: &Stream) -> Result<()>
Inserts a free operation into stream.
The allocation must not be accessed after stream execution reaches the free.
After this call returns, accessing the memory from any subsequent work launched on the GPU or querying its pointer attributes results in undefined behavior.
During stream capture, this creates a free node and must therefore be passed the address of a graph allocation.
§Safety
ptr must be null or a live stream-ordered CUDA allocation.
No work may access it after stream reaches the enqueued free.
§Errors
Returns an error if the stream context cannot be bound, CUDA cannot enqueue the free on stream, ptr is invalid for asynchronous freeing, a previous asynchronous launch reports an error, or CUDA reports runtime initialization diagnostics.
Sourcepub unsafe fn copy_async(
dst: *mut T,
src: *const T,
count: usize,
kind: MemoryCopyKind,
stream: &(impl AsStream + ?Sized),
) -> Result<()>
pub unsafe fn copy_async( dst: *mut T, src: *const T, count: usize, kind: MemoryCopyKind, stream: &(impl AsStream + ?Sized), ) -> Result<()>
Enqueues a typed one-dimensional memory copy on stream.
§Safety
dst and src must remain valid for count elements until stream reaches the enqueued copy, and during every replay of a captured copy.
The pointer combination must match kind and the stream’s context.
§Errors
Returns an error if the requested byte count overflows, the context cannot be bound, CUDA cannot enqueue the copy, the pointer combination is invalid for kind, or a previous asynchronous launch reports an error.
Sourcepub unsafe fn set_async(
dst: *mut T,
value: u8,
count: usize,
stream: &(impl AsStream + ?Sized),
) -> Result<()>
pub unsafe fn set_async( dst: *mut T, value: u8, count: usize, stream: &(impl AsStream + ?Sized), ) -> Result<()>
Enqueues a fill of count elements at dst with the byte value on stream.
The call may return before the fill completes, and the fill may overlap work on other streams. See the CUDA memset synchronization rules for when this operation blocks the host.
§Safety
dst must remain valid and exclusive for writes of count * size_of::<T>() bytes until stream reaches the enqueued memset, and during every replay of a captured fill.
§Errors
Returns an error if the requested byte count overflows, the context cannot be bound, CUDA cannot enqueue the memset on stream, or a previous asynchronous launch reports an error.
Sourcepub unsafe fn set_2d_async(
dst: *mut T,
pitch: usize,
value: u8,
width: usize,
height: usize,
stream: &Stream,
) -> Result<()>
pub unsafe fn set_2d_async( dst: *mut T, pitch: usize, value: u8, width: usize, height: usize, stream: &Stream, ) -> Result<()>
Enqueues a 2D pitched memset on stream.
width and height are measured in elements and rows.
pitch is the byte stride between adjacent rows.
§Safety
dst must remain valid for writes over the described pitched rectangle until stream reaches the enqueued memset.
§Errors
Returns an error if the stream context cannot be bound, the requested byte rectangle overflows, pitch is smaller than the row width, CUDA cannot enqueue the memset, or a previous asynchronous launch reports an error.
Sourcepub unsafe fn set_3d_async(
dst: cudaPitchedPtr,
value: u8,
width: usize,
height: usize,
depth: usize,
stream: &Stream,
) -> Result<()>
pub unsafe fn set_3d_async( dst: cudaPitchedPtr, value: u8, width: usize, height: usize, depth: usize, stream: &Stream, ) -> Result<()>
Enqueues a 3D pitched memset on stream.
width, height, and depth are measured in elements, rows, and slices.
CUDA receives an extent whose width is converted to bytes.
§Safety
dst must remain valid for the described extent until stream reaches the enqueued memset.
§Errors
Returns an error if the stream context cannot be bound, the requested byte volume overflows, dst.pitch is smaller than the row width, CUDA cannot enqueue the memset, or a previous asynchronous launch reports an error.
Sourcepub fn prefetch(
ptr: DevicePtr,
count: usize,
location: MemoryLocation,
stream: &Stream,
) -> Result<()>
pub fn prefetch( ptr: DevicePtr, count: usize, location: MemoryLocation, stream: &Stream, ) -> Result<()>
Enqueues a prefetch of count bytes at ptr to location on stream.
The memory range must refer to managed memory allocated via DeviceMemory::alloc_managed or declared via __managed__ variables.
It may also refer to memory allocated from a managed memory pool, or to system-allocated memory on systems where DeviceProperties::pageable_memory_access is enabled.
Using MemoryLocation::Device prefetches memory to the GPU identified by its device ID.
That device, and the device associated with stream, must support concurrent managed access.
Using MemoryLocation::Host prefetches data to host memory.
Applications can request prefetching memory to a specific host NUMA node by using MemoryLocation::Numa with a valid NUMA node identifier, or to the NUMA node closest to the current thread’s CPU by using MemoryLocation::NumaCurrent.
The start and end addresses of the memory range are rounded down and up, respectively, to CPU page-size alignment before the prefetch operation is enqueued in the stream.
If no physical memory has been allocated for this region, CUDA populates and maps it on the destination device.
If there is insufficient memory to prefetch the desired region, the Unified Memory driver may evict pages from other DeviceMemory::alloc_managed allocations to host memory to make room.
Device memory allocated using DeviceMemory::alloc or sys::cudaMallocArray is not evicted.
By default, mappings to the previous location of the migrated pages are removed and mappings for the new location are only set up at the destination.
The exact behavior also depends on the advice applied to this memory range with DeviceMemory::advise:
If read-mostly advice was set on any subset of this memory range, then that subset will create a read-only copy of the pages at the destination location. If the destination location is a host NUMA node, any pages of that subset that are already in another host NUMA node are transferred to the destination.
If preferred-location advice was set on any subset of this memory range, then the pages will migrate to location even if it is not the preferred location of every page in the range.
If accessed-by advice was set on any subset of this memory range, then mappings to those pages from all appropriate processors are updated to refer to the new location if establishing such a mapping is possible. Otherwise, those mappings are cleared.
This is not required for correctness; it improves performance by allowing the application to migrate data to a suitable location before access. Memory accesses to this range are always coherent and are allowed even when the data is actively being migrated.
This call is asynchronous with respect to the host and all work on other devices.
§Errors
Returns an error if the stream context cannot be bound, CUDA cannot enqueue the prefetch on stream, the memory range or destination location is invalid, a previous asynchronous launch reports an error, or CUDA reports runtime initialization diagnostics.
Sourcepub fn advise(
ptr: DevicePtr,
count: usize,
advice: MemoryAdvise,
location: MemoryLocation,
) -> Result<()>
pub fn advise( ptr: DevicePtr, count: usize, advice: MemoryAdvise, location: MemoryLocation, ) -> Result<()>
Applies a managed-memory advice policy to a byte range.
The memory range must refer to managed memory, a managed memory-pool allocation, or pageable memory on systems that support pageable memory access.
§Errors
Returns an error if CUDA rejects the advice, memory range, or location, or if a previous asynchronous launch reports an error.
Source§impl<T> DeviceMemory<T>
impl<T> DeviceMemory<T>
Sourcepub unsafe fn from_raw(raw: RawDeviceMemory<T>) -> Result<Self>
pub unsafe fn from_raw(raw: RawDeviceMemory<T>) -> Result<Self>
Takes ownership of an existing device allocation.
§Safety
raw.ptr must be null for an empty allocation or point to raw.len live elements of raw.context.
Without raw.stream_ordered, the allocation must be valid to free with cudaFree; with it, it must come from cudaMallocAsync or cudaMallocFromPoolAsync and be valid to free on its stream.
No other owner may free the pointer while the returned value is alive, and all elements must be initialized before they are read.
§Errors
Returns an error if the byte count overflows, a nonempty zero-sized allocation is described, or a nonempty allocation has a null pointer.
Returns Error::StreamContextMismatch if the freeing stream belongs to another context.
Sourcepub fn into_raw(self) -> StdResult<RawDeviceMemory<T>, Self>
pub fn into_raw(self) -> StdResult<RawDeviceMemory<T>, Self>
Transfers ownership to the caller when no other allocation owners remain.
On success the caller owns the pointer and must retain the returned context until the allocation is freed.
§Errors
Returns the original wrapper if another owner, submission, graph, or foreign handle retains the allocation.
Sourcepub fn into_uninit(self) -> DeviceMemory<MaybeUninit<T>>
pub fn into_uninit(self) -> DeviceMemory<MaybeUninit<T>>
Erases initialization guarantees while preserving the allocation and its context.
Sourcepub fn create_uninit(
context: &Arc<Context>,
length: usize,
) -> Result<DeviceMemory<MaybeUninit<T>>>where
T: DeviceRepr,
pub fn create_uninit(
context: &Arc<Context>,
length: usize,
) -> Result<DeviceMemory<MaybeUninit<T>>>where
T: DeviceRepr,
Allocates uninitialized device storage while retaining its context.
Write every element, then call DeviceMemory::assume_init to expose them as T.
§Errors
Returns an error if the byte count overflows, a nonempty zero-sized allocation is requested, context binding fails, or CUDA cannot allocate device memory.
Sourcepub fn zeroed(context: &Arc<Context>, length: usize) -> Result<Self>where
T: ZeroableDeviceRepr,
pub fn zeroed(context: &Arc<Context>, length: usize) -> Result<Self>where
T: ZeroableDeviceRepr,
Allocates device memory and completes zero initialization before returning.
§Errors
Propagates allocation, byte-size, access-tracking, context-binding, CUDA fill, and default-stream synchronization errors.
Sourcepub fn filled(context: &Arc<Context>, length: usize, value: u8) -> Result<Self>where
T: AnyBitPatternDeviceRepr,
pub fn filled(context: &Arc<Context>, length: usize, value: u8) -> Result<Self>where
T: AnyBitPatternDeviceRepr,
Allocates device storage and completes its repeated byte fill before returning.
§Errors
Propagates allocation, byte-size, access-tracking, context-binding, CUDA fill, and default-stream synchronization errors.
Sourcepub fn from_slice(context: &Arc<Context>, v: &[T]) -> Result<Self>where
T: DeviceRepr,
pub fn from_slice(context: &Arc<Context>, v: &[T]) -> Result<Self>where
T: DeviceRepr,
Allocates device memory and completes the upload before returning.
§Errors
Propagates allocation, byte-size, context-binding, stream-capture, CUDA copy, and stream synchronization errors. A nonempty synchronous transfer is rejected during stream capture.
Sourcepub unsafe fn from_slice_unchecked(
context: &Arc<Context>,
v: &[T],
) -> Result<Self>
pub unsafe fn from_slice_unchecked( context: &Arc<Context>, v: &[T], ) -> Result<Self>
Uploads values with an externally established device ABI.
This supports vendor ABI descriptors whose padding or embedded device addresses are not modeled by DeviceRepr.
§Safety
T must match the device ABI and must not transfer Rust ownership or host references.
Embedded addresses must remain valid for every operation that consumes the uploaded descriptors.
§Errors
Propagates allocation, byte-size, context-binding, stream-capture, CUDA copy, and stream synchronization errors. A nonempty synchronous transfer is rejected during stream capture.
Sourcepub unsafe fn from_slice_async(v: &[T], stream: &Stream) -> Result<Self>
pub unsafe fn from_slice_async(v: &[T], stream: &Stream) -> Result<Self>
Allocates device memory and enqueues an upload of v on stream.
§Safety
The caller must ensure v remains valid and unmodified until stream has completed the transfer.
The uploaded values must match the device ABI without transferring Rust ownership or host references.
§Errors
Returns an error if CUDA cannot allocate device memory or enqueue the host-to-device copy.
Sourcepub const fn len(&self) -> usize
pub const fn len(&self) -> usize
Returns the number of elements in the logical allocation range.
Sourcepub const fn is_empty(&self) -> bool
pub const fn is_empty(&self) -> bool
Returns whether the logical allocation range contains no elements.
Sourcepub fn byte_len(&self) -> usize
pub fn byte_len(&self) -> usize
Returns the size of the logical allocation range in bytes.
§Panics
Panics if the element count multiplied by the element size overflows usize.
Allocation construction validates this size, so this condition cannot occur for a valid allocation.
Sourcepub const fn as_ptr(&self) -> *const T
pub const fn as_ptr(&self) -> *const T
Returns the allocation’s CUDA-accessible element pointer without synchronizing pending work.
Sourcepub const fn as_mut_ptr(&self) -> *mut T
pub const fn as_mut_ptr(&self) -> *mut T
Returns the allocation’s CUDA-accessible mutable element pointer.
The pointer does not establish execution ordering or permit conflicting accesses.
Sourcepub const fn as_device_ptr(&self) -> DevicePtr
pub const fn as_device_ptr(&self) -> DevicePtr
Returns the allocation’s address as an untyped CUDA device pointer.
Sourcepub fn allocation(&self) -> &Arc<DeviceAllocation> ⓘ
pub fn allocation(&self) -> &Arc<DeviceAllocation> ⓘ
Returns the shared owner retained by asynchronous submissions and interop users.
Sourcepub fn into_bytes(self) -> DeviceMemory<u8>where
T: NoUninitDeviceRepr,
pub fn into_bytes(self) -> DeviceMemory<u8>where
T: NoUninitDeviceRepr,
Preserves allocation ownership while exposing initialized representation bytes.
Sourcepub fn cast<U: AnyBitPatternDeviceRepr>(
self,
) -> StdResult<DeviceMemory<U>, Self>where
T: NoUninitDeviceRepr,
pub fn cast<U: AnyBitPatternDeviceRepr>(
self,
) -> StdResult<DeviceMemory<U>, Self>where
T: NoUninitDeviceRepr,
Reinterprets initialized storage without reallocating it.
Returns the original buffer if alignment or byte length is incompatible. The original allocation owner and deallocation metadata are preserved.
§Errors
Returns the original allocation if U is zero-sized, its size does not divide the exposed byte length, or a nonempty range is not aligned for U.
Sourcepub fn set_zeroes(&mut self) -> Result<()>where
T: ZeroableDeviceRepr,
pub fn set_zeroes(&mut self) -> Result<()>where
T: ZeroableDeviceRepr,
Fills every element with zero bytes and waits for completion.
§Errors
Propagates access-tracking, context-binding, byte-size, CUDA fill, and default-stream synchronization errors.
Sourcepub fn set_value(&mut self, value: u8) -> Result<()>where
T: AnyBitPatternDeviceRepr,
pub fn set_value(&mut self, value: u8) -> Result<()>where
T: AnyBitPatternDeviceRepr,
Fills every byte of the allocation with value and waits for completion.
The byte pattern repeats across each element; value is not converted to T.
§Errors
Propagates access-tracking, context-binding, byte-size, CUDA fill, and default-stream synchronization errors.
Sourcepub unsafe fn set_value_unchecked(&mut self, value: u8) -> Result<()>
pub unsafe fn set_value_unchecked(&mut self, value: u8) -> Result<()>
Sourcepub fn set_value_scoped<'env>(
&'env mut self,
value: u8,
stream: &StreamScope<'_, 'env>,
) -> Result<()>where
T: AnyBitPatternDeviceRepr,
pub fn set_value_scoped<'env>(
&'env mut self,
value: u8,
stream: &StreamScope<'_, 'env>,
) -> Result<()>where
T: AnyBitPatternDeviceRepr,
Enqueues a repeated-byte fill of the entire allocation in a stream scope.
The scope retains the exclusive allocation borrow until the fill completes.
§Errors
Returns an error if the byte count overflows or the scope’s stream belongs to another context. Also propagates context-binding, scope submission, and CUDA fill errors.
Sourcepub unsafe fn set_value_async(
&mut self,
value: u8,
stream: &Stream,
) -> Result<()>where
T: AnyBitPatternDeviceRepr,
pub unsafe fn set_value_async(
&mut self,
value: u8,
stream: &Stream,
) -> Result<()>where
T: AnyBitPatternDeviceRepr,
Enqueues a repeated-byte fill of this allocation on stream, ordered after the allocation’s producer.
§Safety
The caller must ensure self remains valid until stream has completed the memset.
§Errors
Returns an error if the stream belongs to another context, producer ordering fails, or CUDA cannot enqueue the memset on stream.
Sourcepub fn ipc_handle(&self) -> Result<IpcMemoryHandle>
pub fn ipc_handle(&self) -> Result<IpcMemoryHandle>
Takes a pointer to the base of an existing device memory allocation created with DeviceMemory::alloc and exports it for use in another process.
This is a lightweight operation and may be called multiple times on an allocation without adverse effects.
If a region of memory is freed with DeviceMemory::free and a subsequent call to DeviceMemory::alloc returns memory with the same device address, DeviceMemory::ipc_handle returns a unique handle for the new memory.
IPC is restricted to devices with unified-addressing support on Linux and Windows.
IPC on Windows is supported for compatibility but is not recommended because of its performance cost.
Check device IPC support through the device properties exposed by this crate, for example DeviceProperties::ipc_event_supported.
§Errors
Returns an error if the allocation is empty, CUDA cannot export an IPC handle for the allocation, or CUDA reports runtime initialization diagnostics.
Source§impl<T> DeviceMemory<MaybeUninit<T>>
impl<T> DeviceMemory<MaybeUninit<T>>
Sourcepub unsafe fn assume_init_prefix(self, length: usize) -> Result<DeviceMemory<T>>
pub unsafe fn assume_init_prefix(self, length: usize) -> Result<DeviceMemory<T>>
Exposes an initialized prefix while retaining the complete allocation.
§Safety
The first length elements must contain valid initialized values of T.
Producing work must be ordered before every consumer and host read.
The remainder stays allocated but is no longer exposed as typed elements.
§Errors
Returns an error if length exceeds the currently exposed element count.
Sourcepub unsafe fn assume_init(self) -> DeviceMemory<T>
pub unsafe fn assume_init(self) -> DeviceMemory<T>
Converts storage initialized by a device producer into initialized device memory.
§Safety
Every element must contain a valid, initialized T before any consumer reads it.
Pending initialization must be ordered before every subsequent consumer and host readback.
Source§impl<T> DeviceMemory<T>
impl<T> DeviceMemory<T>
Sourcepub unsafe fn create_stream_ordered_unchecked(
length: usize,
stream: &Stream,
) -> Result<Self>
pub unsafe fn create_stream_ordered_unchecked( length: usize, stream: &Stream, ) -> Result<Self>
Allocates stream-ordered device memory on stream for a raw producer to initialize.
The last owner enqueues cudaFreeAsync on stream when it drops.
§Safety
Every element must be initialized to a valid T before it is read.
Consumers on other streams must wait for allocation and producer work.
§Errors
Returns an error if the requested byte size overflows, the stream’s context cannot be bound, CUDA cannot enqueue the allocation, or length is non-zero for a zero-sized T.
Sourcepub unsafe fn create_in_pool_unchecked(
length: usize,
pool: &MemoryPool,
stream: &Stream,
) -> Result<Self>
pub unsafe fn create_in_pool_unchecked( length: usize, pool: &MemoryPool, stream: &Stream, ) -> Result<Self>
Allocates stream-ordered device memory from pool on stream for a raw producer to initialize.
The last owner enqueues cudaFreeAsync on stream when it drops, and retains pool until then.
§Safety
Every element must be initialized to a valid T before it is read.
Consumers on other streams must wait for allocation and producer work.
§Errors
Returns an error if the requested byte size overflows, the stream’s context cannot be bound, CUDA cannot enqueue the pool allocation, CUDA returns a null pointer for a non-empty request, or length is non-zero for a zero-sized T.
Sourcepub fn create_uninit_stream_ordered(
length: usize,
stream: &Stream,
) -> Result<DeviceMemory<MaybeUninit<T>>>where
T: DeviceRepr,
pub fn create_uninit_stream_ordered(
length: usize,
stream: &Stream,
) -> Result<DeviceMemory<MaybeUninit<T>>>where
T: DeviceRepr,
Enqueues an uninitialized allocation on stream from CUDA’s current pool.
Access on other streams must be ordered after the allocation stream.
§Errors
Returns an error if the byte count overflows, a nonempty zero-sized allocation is requested, stream or context setup fails, or CUDA cannot enqueue the allocation.
Sourcepub fn create_uninit_in_pool(
length: usize,
pool: &MemoryPool,
stream: &Stream,
) -> Result<DeviceMemory<MaybeUninit<T>>>where
T: DeviceRepr,
pub fn create_uninit_in_pool(
length: usize,
pool: &MemoryPool,
stream: &Stream,
) -> Result<DeviceMemory<MaybeUninit<T>>>where
T: DeviceRepr,
Enqueues an uninitialized allocation from pool on stream.
The allocation retains both the pool and the stream until it is freed.
§Errors
Returns an error if the byte count overflows, a nonempty zero-sized allocation is requested, or stream or context setup fails. Also propagates CUDA errors for the requested pool allocation and rejects a null handle for a nonempty allocation.
Sourcepub fn stream(&self) -> Option<&Stream>
pub fn stream(&self) -> Option<&Stream>
Returns the stream a stream-ordered allocation was made on and is freed on, or None for an allocation freed with cudaFree.
Sourcepub fn pool(&self) -> Option<&MemoryPool>
pub fn pool(&self) -> Option<&MemoryPool>
Returns the pool a stream-ordered allocation came from, if one was selected.
Sourcepub fn release(self) -> Result<()>
pub fn release(self) -> Result<()>
Releases the allocation now when this is its final owner.
Memory freed with cudaFree is freed before this returns; a stream-ordered allocation enqueues cudaFreeAsync on its stream.
Calling this surfaces the errors that dropping the owner can only report.
§Errors
Returns Error::OwnershipShared if a view, submission, graph, or interop user retains the allocation, which then stays live until its final owner drops.
Otherwise returns an error if the context cannot be bound or CUDA cannot free or enqueue the free.
Source§impl<T: ZeroableDeviceRepr> DeviceMemory<T>
impl<T: ZeroableDeviceRepr> DeviceMemory<T>
Sourcepub fn zeroed_stream_ordered(length: usize, stream: &Stream) -> Result<Self>
pub fn zeroed_stream_ordered(length: usize, stream: &Stream) -> Result<Self>
Allocates stream-ordered device memory on stream and enqueues a fill with zero bytes.
§Errors
Returns an error if allocation fails or CUDA cannot enqueue the memset.
Sourcepub fn zeroed_in_pool(
length: usize,
pool: &MemoryPool,
stream: &Stream,
) -> Result<Self>
pub fn zeroed_in_pool( length: usize, pool: &MemoryPool, stream: &Stream, ) -> Result<Self>
Allocates stream-ordered device memory from pool on stream and enqueues a fill with zero bytes.
§Errors
Returns an error if allocation from the pool fails or CUDA cannot enqueue the memset.
Source§impl<T: DeviceRepr> DeviceMemory<T>
impl<T: DeviceRepr> DeviceMemory<T>
Sourcepub fn view(&self) -> DeviceView<'_, T>
pub fn view(&self) -> DeviceView<'_, T>
Borrows all initialized elements as a shared device view.
Sourcepub fn view_mut(&mut self) -> DeviceViewMut<'_, T>
pub fn view_mut(&mut self) -> DeviceViewMut<'_, T>
Borrows all initialized elements as an exclusive device view.
Source§impl<T: DeviceRepr> DeviceMemory<MaybeUninit<T>>
impl<T: DeviceRepr> DeviceMemory<MaybeUninit<T>>
Sourcepub fn output(&mut self) -> DeviceOutputView<'_, T>
pub fn output(&mut self) -> DeviceOutputView<'_, T>
Borrows this uninitialized allocation as a write-only output of T values.
Trait Implementations§
Source§impl<T: Debug> Debug for DeviceMemory<T>
impl<T: Debug> Debug for DeviceMemory<T>
Source§impl<T: DeviceRepr> DeviceOutput<T> for DeviceMemory<T>
impl<T: DeviceRepr> DeviceOutput<T> for DeviceMemory<T>
Source§fn as_mut_ptr(&mut self) -> *mut T
fn as_mut_ptr(&mut self) -> *mut T
Source§impl<T: DeviceRepr> DeviceOutput<T> for DeviceMemory<MaybeUninit<T>>
impl<T: DeviceRepr> DeviceOutput<T> for DeviceMemory<MaybeUninit<T>>
Source§fn as_mut_ptr(&mut self) -> *mut T
fn as_mut_ptr(&mut self) -> *mut T
Source§impl<T: DeviceRepr> DeviceRange<T> for DeviceMemory<MaybeUninit<T>>
impl<T: DeviceRepr> DeviceRange<T> for DeviceMemory<MaybeUninit<T>>
Source§impl<T: DeviceRepr> DeviceRange<T> for DeviceMemory<T>
impl<T: DeviceRepr> DeviceRange<T> for DeviceMemory<T>
Source§impl<T> DeviceRegionProvider for DeviceMemory<T>
impl<T> DeviceRegionProvider for DeviceMemory<T>
Source§fn region(&self) -> DeviceRegion<'_>
fn region(&self) -> DeviceRegion<'_>
impl<T: DeviceRepr> DeviceSlice<T> for DeviceMemory<T>
impl<T: DeviceRepr> DeviceSliceMut<T> for DeviceMemory<T>
impl<T> Eq for DeviceMemory<T>
Source§impl<T> PartialEq for DeviceMemory<T>
impl<T> PartialEq for DeviceMemory<T>
Source§impl<T: DeviceRepr> PushKernelArg for &DeviceMemory<T>
impl<T: DeviceRepr> PushKernelArg for &DeviceMemory<T>
Source§fn push_to(self, params: &mut KernelParameters<'_>)
fn push_to(self, params: &mut KernelParameters<'_>)
Source§impl<T: DeviceRepr> PushKernelArg for &mut DeviceMemory<T>
impl<T: DeviceRepr> PushKernelArg for &mut DeviceMemory<T>
Source§fn push_to(self, params: &mut KernelParameters<'_>)
fn push_to(self, params: &mut KernelParameters<'_>)
impl<T: Send> Send for DeviceMemory<T>
impl<T: Sync> Sync for DeviceMemory<T>
Auto Trait Implementations§
impl<T> !RefUnwindSafe for DeviceMemory<T>
impl<T> !UnwindSafe for DeviceMemory<T>
impl<T> Forget for DeviceMemory<T>
impl<T> Freeze for DeviceMemory<T>
impl<T> Move for DeviceMemory<T>
impl<T> Unpin for DeviceMemory<T>
impl<T> UnsafeUnpin for DeviceMemory<T>
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.