Skip to main content

xlog_cuda/device_runtime/
mod.rs

1//! Stream-ordered device memory runtime.
2//!
3//! [`crate::CudaProviderBuilder`] constructs one [`XlogDeviceRuntime`] and one
4//! [`crate::GpuMemoryManager`] that share the provider's exact CUDA device.
5//! The runtime owns the stream pool and composes the production resource stack:
6//!
7//! ```text
8//! XlogDeviceRuntime
9//!   -> StreamPool of non-blocking streams
10//!   -> LoggingResource (optional)
11//!   -> GlobalDeviceBudget
12//!   -> AsyncCudaResource
13//! ```
14//!
15//! [`GlobalDeviceBudget`] is the sole byte-admission authority. Optional
16//! [`LoggingResource`] wraps it so successful operations and typed admission
17//! failures are both observable exactly once. [`DirectCudaResource`] remains
18//! available for crate tests that need a synchronous allocator; canonical
19//! providers always use [`AsyncCudaResource`].
20//!
21//! Stream-ordered contract: every alloc / dealloc names a stream;
22//! reuse across streams requires explicit event/sync. No reliance on
23//! the CUDA null/default stream.
24
25pub mod async_resource;
26pub mod budget;
27pub mod direct;
28pub mod logging;
29pub mod resource;
30pub mod runtime;
31pub mod stream_pool;
32
33pub use async_resource::AsyncCudaResource;
34pub use budget::GlobalDeviceBudget;
35pub use direct::DirectCudaResource;
36pub use logging::{
37    InMemorySink, LogAction, LogRecord, LogResult, LoggingResource, LoggingSink, NullSink,
38    SinkError,
39};
40pub(crate) use resource::BlockUse;
41pub use resource::{
42    Access, AllocTag, AllocationAccounting, AllocationRequest, BlockId, BlockState, DeviceBlock,
43    DeviceMemoryResource, Generation, ResourceBudgetSnapshot, ResourceError, ResourceResult,
44    StreamId,
45};
46pub(crate) use runtime::RuntimeMemoryReservation;
47pub use runtime::{
48    ConditionalGraphStats, EventLifecycleStats, ResidentCompletionEvent,
49    ResidentGraphHandleLifecycleStats, XlogDeviceRuntime,
50};
51pub use stream_pool::{StreamPool, StreamPoolError, DEFAULT_MAX_STREAMS};