Skip to main content

DeviceRegion

Struct DeviceRegion 

Source
pub struct DeviceRegion<'a> { /* private fields */ }
Expand description

A borrowed byte range within one context-associated allocation.

Implementations§

Source§

impl<'a> DeviceRegion<'a>

Source

pub unsafe fn from_raw_parts( context: &'a Arc<Context>, allocation_id: AllocationId, base: *mut u8, bytes: usize, ) -> Result<Self>

Describes an externally established allocation and its full byte range.

§Safety

base must identify bytes live CUDA-accessible bytes in context for 'a. allocation_id must be shared by all aliases of this allocation and must not identify another live allocation.

§Errors

Returns an error if a nonempty range has a null base pointer or its ending address overflows usize.

Source

pub fn context(self) -> &'a Arc<Context> ⓘ

Returns the CUDA context associated with this allocation.

Source

pub const fn stream(self) -> Option<&'a Stream>

Returns the stream that orders allocation and writes for stream-ordered storage.

Source

pub unsafe fn with_stream(self, stream: &'a Stream) -> Result<Self>

Associates this region with the stream that establishes its readiness.

§Safety

Allocation and pending producer writes must be ordered on this stream. Work on other streams must establish dependencies before accessing the region.

§Errors

Returns an error if the stream belongs to a different context.

Source

pub fn order_on(self, stream: &Stream) -> Result<()>

Orders this range’s allocation and producer stream before a consumer stream.

§Errors

Returns an error if the consumer stream belongs to a different context or joining the readiness stream fails.

Source

pub fn synchronize(self) -> Result<()>

Waits for an associated allocation stream before synchronous access.

§Errors

Propagates access-tracking and synchronization errors while waiting for pending accesses to this region.

Source

pub const fn allocation_id(self) -> AllocationId

Returns the identity shared by all aliases of the backing allocation.

Source

pub const fn allocation_byte_len(self) -> usize

Returns the byte length of the complete allocation before slicing.

Source

pub const fn byte_len(self) -> usize

Returns the byte length of this region.

Source

pub fn byte_range(self) -> Range<usize> ⓘ

Returns this region’s byte offsets relative to the start of the backing allocation.

Source

pub fn overlaps(self, other: Self) -> bool

Reports conflicts between byte ranges sharing one allocation identity. Empty subranges inside another range conservatively count as conflicts.

Source

pub fn as_ptr(self) -> *mut u8

Returns the CUDA-accessible pointer at this region’s starting byte offset.

The pointer does not grant host access or establish initialization or exclusive access.

Source

pub fn ensure_aligned(self, alignment: usize, name: &'static str) -> Result<()>

Checks that a nonempty region starts at a multiple of alignment bytes, which must be nonzero.

§Errors

Returns Error::Misaligned naming name if the region is nonempty and its start is not a multiple of alignment.

Source

pub fn slice<R: RangeBounds<usize>>(self, range: R) -> Result<Self>

Borrows a byte subrange while preserving allocation and context identity.

§Errors

Returns an error if the byte range is reversed, exceeds this range’s bounds, or an inclusive bound cannot be converted without overflow.

Trait Implementations§

Source§

impl<'a> Clone for DeviceRegion<'a>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Copy for DeviceRegion<'a>

Source§

impl<'a> Debug for DeviceRegion<'a>

Source§

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

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

impl<'a> Eq for DeviceRegion<'a>

Source§

impl<'a> Hash for DeviceRegion<'a>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<'a> PartialEq for DeviceRegion<'a>

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<'a> StructuralPartialEq for DeviceRegion<'a>

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for DeviceRegion<'a>

§

impl<'a> !Send for DeviceRegion<'a>

§

impl<'a> !Sync for DeviceRegion<'a>

§

impl<'a> !UnwindSafe for DeviceRegion<'a>

§

impl<'a> Forget for DeviceRegion<'a>

§

impl<'a> Freeze for DeviceRegion<'a>

§

impl<'a> Move for DeviceRegion<'a>

§

impl<'a> Unpin for DeviceRegion<'a>

§

impl<'a> UnsafeUnpin for DeviceRegion<'a>

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<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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.