pub struct DeviceRegion<'a> { /* private fields */ }Expand description
A borrowed byte range within one context-associated allocation.
Implementations§
Source§impl<'a> DeviceRegion<'a>
impl<'a> DeviceRegion<'a>
Sourcepub unsafe fn from_raw_parts(
context: &'a Arc<Context>,
allocation_id: AllocationId,
base: *mut u8,
bytes: usize,
) -> Result<Self>
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.
Sourcepub fn context(self) -> &'a Arc<Context> ⓘ
pub fn context(self) -> &'a Arc<Context> ⓘ
Returns the CUDA context associated with this allocation.
Sourcepub const fn stream(self) -> Option<&'a Stream>
pub const fn stream(self) -> Option<&'a Stream>
Returns the stream that orders allocation and writes for stream-ordered storage.
Sourcepub unsafe fn with_stream(self, stream: &'a Stream) -> Result<Self>
pub unsafe fn with_stream(self, stream: &'a Stream) -> Result<Self>
Sourcepub fn order_on(self, stream: &Stream) -> Result<()>
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.
Sourcepub fn synchronize(self) -> Result<()>
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.
Sourcepub const fn allocation_id(self) -> AllocationId
pub const fn allocation_id(self) -> AllocationId
Returns the identity shared by all aliases of the backing allocation.
Sourcepub const fn allocation_byte_len(self) -> usize
pub const fn allocation_byte_len(self) -> usize
Returns the byte length of the complete allocation before slicing.
Sourcepub fn byte_range(self) -> Range<usize> ⓘ
pub fn byte_range(self) -> Range<usize> ⓘ
Returns this region’s byte offsets relative to the start of the backing allocation.
Sourcepub fn overlaps(self, other: Self) -> bool
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.
Sourcepub fn as_ptr(self) -> *mut u8
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.
Sourcepub fn ensure_aligned(self, alignment: usize, name: &'static str) -> Result<()>
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.
Trait Implementations§
Source§impl<'a> Clone for DeviceRegion<'a>
impl<'a> Clone for DeviceRegion<'a>
impl<'a> Copy for DeviceRegion<'a>
Source§impl<'a> Debug for DeviceRegion<'a>
impl<'a> Debug for DeviceRegion<'a>
impl<'a> Eq for DeviceRegion<'a>
Source§impl<'a> Hash for DeviceRegion<'a>
impl<'a> Hash for DeviceRegion<'a>
Source§impl<'a> PartialEq for DeviceRegion<'a>
impl<'a> PartialEq for DeviceRegion<'a>
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> 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<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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.