Skip to main content

ManagedBuffer

Struct ManagedBuffer 

Source
pub struct ManagedBuffer<T: DeviceRepr> { /* private fields */ }
Expand description

Unified managed-memory buffer — allocated via cudaMallocManaged. Accessible from both host and device without explicit copies.

Implementations§

Source§

impl<T: DeviceRepr> ManagedBuffer<T>

Source

pub fn new(len: usize) -> Result<Self>

Allocate len managed elements with the default attach (GLOBAL).

Source

pub fn with_flags(len: usize, flags: u32) -> Result<Self>

Allocate with explicit attach flags (see baracuda_cuda_sys::runtime::types::cudaMemAttach).

Source

pub fn len(&self) -> usize

Number of elements.

Source

pub fn is_empty(&self) -> bool

Source

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

Raw pointer — usable from both host and device code.

Source

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

Source

pub fn as_slice(&self) -> &[T]

Access as a host slice (synchronizes through device cache on access).

Source

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

Trait Implementations§

Source§

impl<T: DeviceRepr> Debug for ManagedBuffer<T>

Source§

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

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

impl<T: DeviceRepr> Drop for ManagedBuffer<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 + Send> Send for ManagedBuffer<T>

Source§

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

Auto Trait Implementations§

§

impl<T> Freeze for ManagedBuffer<T>

§

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

§

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

§

impl<T> UnsafeUnpin for ManagedBuffer<T>

§

impl<T> UnwindSafe for ManagedBuffer<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<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, 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.