pub struct DirectCudaResource { /* private fields */ }Expand description
Default-device-stream allocation adaptor. The live map retains actual raw
owners while callers hold opaque DeviceBlock identities. Deallocation
removes an exact identity and queues its actual owner after unlocking the
map. Reclamation waits for shared leases; an unknown physical-free outcome
retains the owner and its outstanding byte charge for a later reap.
Implementations§
Source§impl DirectCudaResource
impl DirectCudaResource
Sourcepub fn new(device: Arc<CudaDevice>, device_ordinal: u32) -> Self
pub fn new(device: Arc<CudaDevice>, device_ordinal: u32) -> Self
Construct a resource bound to device. device_ordinal is the
CUDA ordinal for logging / multi-device disambiguation.
Sourcepub fn device(&self) -> &Arc<CudaDevice> ⓘ
pub fn device(&self) -> &Arc<CudaDevice> ⓘ
Borrow the device handle. Tests and downstream resources use this to launch kernels against the same device this resource allocates on.
Trait Implementations§
Source§impl DeviceMemoryResource for DirectCudaResource
impl DeviceMemoryResource for DirectCudaResource
Source§fn materialize(&self, request: AllocationRequest) -> ResourceResult<DeviceBlock>
fn materialize(&self, request: AllocationRequest) -> ResourceResult<DeviceBlock>
Materialize one request. Decorators must forward the same request. Read more
Source§fn deallocate(&self, block: DeviceBlock) -> ResourceResult<()>
fn deallocate(&self, block: DeviceBlock) -> ResourceResult<()>
Return
block to the resource. After this call the block’s
state is BlockState::Retired (or BlockState::Quarantined
for debug-guard resources). Reuse of the underlying memory is
resource-specific but must respect the stream-ordered contract. Read moreSource§fn reap_pending(&self) -> ResourceResult<()>
fn reap_pending(&self) -> ResourceResult<()>
Drain any retired-but-not-yet-freed bytes whose underlying
CUDA work has completed. For synchronous backends this is a
no-op. For stream-ordered async backends this synchronizes
the streams that have queued
cuMemFreeAsync calls and
re-counts bytes_outstanding accordingly. Read moreSource§fn device_ordinal(&self) -> u32
fn device_ordinal(&self) -> u32
CUDA device ordinal this resource serves. Resources are pinned
to a single device.
Source§fn bytes_outstanding(&self) -> usize
fn bytes_outstanding(&self) -> usize
Bytes currently outstanding (live + retired-but-not-yet-freed).
Used by tests and by the global budget adaptor.
Source§fn allocation_accounting(&self) -> Arc<AllocationAccounting> ⓘ
fn allocation_accounting(&self) -> Arc<AllocationAccounting> ⓘ
Exact terminal-backend accounting domain. Decorators return the identical
Arc. Later allocations must pass through the domain’s installed budgets.
Source§fn budget_snapshot(&self) -> Option<ResourceBudgetSnapshot>
fn budget_snapshot(&self) -> Option<ResourceBudgetSnapshot>
Return the outer resource stack’s reservable budget, if one exists.
Base allocators have no declarative admission limit and return
None;
decorators must forward this query unless they enforce their own limit.Source§fn allocate(
&self,
bytes: usize,
stream: StreamId,
tag: AllocTag,
) -> ResourceResult<DeviceBlock>
fn allocate( &self, bytes: usize, stream: StreamId, tag: AllocTag, ) -> ResourceResult<DeviceBlock>
Allocate
bytes bytes on the resource’s device, ordered on
stream. The returned block is in BlockState::Live.Source§fn allocate_with_reservation_pressure(
&self,
bytes: usize,
reservation_pressure_bytes: usize,
stream: StreamId,
tag: AllocTag,
) -> ResourceResult<DeviceBlock>
fn allocate_with_reservation_pressure( &self, bytes: usize, reservation_pressure_bytes: usize, stream: StreamId, tag: AllocTag, ) -> ResourceResult<DeviceBlock>
Allocate while accounting for bytes promised by the runtime but not yet
materialized through this resource stack. Read more
Source§fn record_block_use(
&self,
block: &DeviceBlock,
use_stream: StreamId,
) -> ResourceResult<()>
fn record_block_use( &self, block: &DeviceBlock, use_stream: StreamId, ) -> ResourceResult<()>
Record that work has been (or is being) submitted on
use_stream that touches block’s bytes. Resources that
participate in cross-stream lifetime tracking (notably the
stream-ordered async backend) MUST attach a CUDA event from
use_stream to the block; on deallocate(block), the
block’s alloc_stream will wait on every recorded event
before queueing the underlying free. Read moreSource§fn supports_block_use_tracking(&self) -> bool
fn supports_block_use_tracking(&self) -> bool
Whether this resource (and any inner resources it
composes) actually tracks cross-stream uses via
record_block_use. Used by the launch recorder’s
preflight to fail BEFORE queueing CUDA work, rather than
after. The default returns false to match the trait’s
default record_block_use behavior; resources that
override record_block_use to track events MUST override
this to return true. Decorators forward to inner.Source§fn prepare_block_use(
&self,
block: BlockId,
use_stream: StreamId,
access: Access,
) -> ResourceResult<()>
fn prepare_block_use( &self, block: BlockId, use_stream: StreamId, access: Access, ) -> ResourceResult<()>
Pre-launch / pre-copy hook: queue any cross-stream waits
required for
use_stream to safely access block with
access semantics. MUST be called BEFORE the GPU work is
enqueued on use_stream. Read moreSource§fn finish_block_use(
&self,
block: BlockId,
use_stream: StreamId,
access: Access,
) -> ResourceResult<()>
fn finish_block_use( &self, block: BlockId, use_stream: StreamId, access: Access, ) -> ResourceResult<()>
Post-launch / post-copy hook: record an event on
use_stream capturing the work just enqueued and update
block’s dependency state. Read moreAuto Trait Implementations§
impl !Freeze for DirectCudaResource
impl RefUnwindSafe for DirectCudaResource
impl Send for DirectCudaResource
impl Sync for DirectCudaResource
impl Unpin for DirectCudaResource
impl UnsafeUnpin for DirectCudaResource
impl UnwindSafe for DirectCudaResource
Blanket Implementations§
impl<T> Allocation for T
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
Mutably borrows from an owned value. Read more