Skip to main content

ManagedMemory

Struct ManagedMemory 

Source
pub struct ManagedMemory<T: DeviceRepr> { /* private fields */ }

Implementations§

Source§

impl<T: DeviceRepr> ManagedMemory<T>

Source

pub fn create(length: usize, attach_flags: MemoryAttachFlags) -> Result<Self>

Allocates typed CUDA managed memory and records its initial attach mode.

§Errors

Returns an error if the requested byte size overflows, CUDA cannot allocate managed memory, or a non-empty zero-sized allocation is requested.

Source

pub fn zeroes(length: usize, attach_flags: MemoryAttachFlags) -> Result<Self>

Source

pub unsafe fn from_raw_parts( ptr: *mut T, length: usize, attach_flags: MemoryAttachFlags, ) -> Self

Takes ownership of an existing managed allocation.

§Safety

ptr must be null for an empty allocation or point to length live elements allocated by a CUDA allocation function compatible with DeviceMemory::free. length * size_of::<T>() must fit in usize. No other owner may free the pointer while the returned value is alive.

Source

pub fn into_raw_parts(self) -> (*mut T, usize, MemoryAttachFlags)

Source

pub const fn len(&self) -> usize

Source

pub const fn is_empty(&self) -> bool

Source

pub fn byte_len(&self) -> usize

Source

pub const fn attach_flags(&self) -> MemoryAttachFlags

Source

pub const fn as_ptr(&self) -> *const T

Source

pub const fn as_mut_ptr(&mut self) -> *mut T

Source

pub fn view(&self) -> DeviceView<'_, T>

Source

pub fn view_mut(&mut self) -> DeviceViewMut<'_, T>

Source

pub unsafe fn as_host_slice(&self) -> &[T]

Returns a host slice over this managed allocation.

§Safety

The caller must ensure no GPU work or other CPU reference can concurrently mutate the same memory for the returned lifetime, and that the allocation is accessible from the host at the point of access.

Source

pub unsafe fn as_host_slice_mut(&mut self) -> &mut [T]

Returns a mutable host slice over this managed allocation.

§Safety

The caller must ensure no GPU work or other CPU reference can concurrently access the same memory for the returned lifetime, and that the allocation is accessible from the host at the point of access.

Source

pub fn set_zeroes(&mut self) -> Result<()>

Source

pub fn prefetch_to( &self, location: MemoryLocation, stream: &Stream, ) -> Result<()>

Source

pub fn attach_to_stream( &mut self, stream: &Stream, flags: MemoryAttachFlags, ) -> Result<()>

Trait Implementations§

Source§

impl<T: Debug + DeviceRepr> Debug for ManagedMemory<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: DeviceRepr> DeviceSlice<T> for ManagedMemory<T>

Source§

impl<T: DeviceRepr> DeviceSliceMut<T> for ManagedMemory<T>

Source§

impl<T: DeviceRepr> Drop for ManagedMemory<T>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl<T: DeviceRepr> PushKernelArg for &ManagedMemory<T>

Source§

fn push_to<'a>(self, params: &mut KernelParameters<'a>)

Source§

impl<T: DeviceRepr> PushKernelArg for &mut ManagedMemory<T>

Source§

fn push_to<'a>(self, params: &mut KernelParameters<'a>)

Source§

impl<T: DeviceRepr + Send> Send for ManagedMemory<T>

Source§

impl<T: DeviceRepr + Sync> Sync for ManagedMemory<T>

Auto Trait Implementations§

§

impl<T> Freeze for ManagedMemory<T>

§

impl<T> RefUnwindSafe for ManagedMemory<T>
where T: RefUnwindSafe,

§

impl<T> Unpin for ManagedMemory<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for ManagedMemory<T>

§

impl<T> UnwindSafe for ManagedMemory<T>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<B> ByteBuffer for B
where B: DeviceSlice<u8> + ?Sized,

Source§

impl<B> ByteBufferMut for B
where B: DeviceSliceMut<u8> + ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T, B> DeviceBuffer<T> for B
where T: DeviceRepr, B: DeviceSlice<T> + ?Sized,

Source§

impl<T, B> DeviceBufferMut<T> for B
where T: DeviceRepr, B: DeviceBuffer<T> + DeviceSliceMut<T> + ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.