Skip to main content

GpuMemoryManager

Struct GpuMemoryManager 

Source
pub struct GpuMemoryManager { /* private fields */ }
Expand description

Budget-enforced device allocation. Every view retains actual storage. Runtime-backed managers use the canonical resource stack. Native allocations share its raw owner: post-malloc failures retain storage and budget together.

Implementations§

Source§

impl GpuMemoryManager

Source

pub fn reserve_bytes( self: &Arc<Self>, bytes: u64, ) -> Result<GpuMemoryReservation>

Atomically reserve bytes for one bounded multi-allocation request.

The returned token owns the complete local-budget claim. A runtime-backed manager also reserves the same bytes against the runtime resource stack’s finite global budget before touching local accounting; runtimes without a reservable global budget are refused. Creating the token performs no device allocation and does not increment alloc_count.

Source

pub fn runtime(&self) -> Option<&Arc<XlogDeviceRuntime>>

Borrow the attached device runtime, if any. None when the manager was constructed via [new].

This accessor is the supported bridge for provider operations that receive runtime-owned allocations through the memory manager and must submit recorded work through crate::launch::LaunchRecorder. Code that already owns the runtime should use that Arc<XlogDeviceRuntime> directly.

Source

pub fn reap_pending_deallocations(&self) -> Result<()>

Complete stream-ordered frees that are pending in the attached device runtime.

Diagnostic transactions use this after dropping temporary buffers on an error path so a later operation observes the restored byte budget.

Source

pub fn alloc<T: DeviceRepr>( self: &Arc<Self>, len: usize, ) -> Result<TrackedCudaSlice<T>>

Allocate len elements through the attached runtime or the shared raw allocator. Allocation completes before publication; retained failures keep their actual allocation and local byte claim.

Source

pub fn check_budget(&self, bytes: u64) -> Result<()>

Check if an allocation of bytes would exceed the budget

§Arguments
  • bytes - Number of bytes to allocate
§Returns

Ok(()) if allocation is within budget

§Errors

XlogError::ResourceExhausted if allocation would exceed budget

Source

pub fn allocated_bytes(&self) -> u64

Get the current allocated memory in bytes

Source

pub fn deallocation_failure_count(&self) -> u64

Number of runtime deallocations that returned an error. Their bytes remain charged locally because physical release was not proven.

Source

pub fn deallocation_failure_bytes(&self) -> u64

Total bytes retained in local accounting after runtime deallocation errors.

Source

pub fn peak_bytes(&self) -> u64

High-water mark of successful manager-accounted reservations since construction or the last reset_peak. Direct CUDA allocations that bypass this manager are not included.

Source

pub fn reset_peak(&self)

Reset the peak high-water mark to the current allocated level, so a measurement window starts from live state rather than zero. Measurement-harness API.

Source

pub fn alloc_count(&self) -> u64

Number of alloc calls issued so far (device allocation requests). The GPU-resident MC engine snapshots this around the measured region to prove per_operator_host_allocations == 0 (all arenas pre-allocated).

Source

pub fn reset_alloc_count(&self)

Reset the allocation-request counter to zero.

Source

pub fn budget(&self) -> &MemoryBudget

Get the memory budget

Source

pub fn budget_limit_bytes(&self) -> u64

Total local budget enforced jointly by this manager and any overlays.

Source

pub fn device(&self) -> &Arc<CudaDevice> ⓘ

Get the underlying CUDA device

Source

pub fn record_free(&self, bytes: u64) -> Result<()>

Validate a caller-requested manual accounting release.

Tracked allocations release themselves through their private owner path. A public caller cannot authenticate ownership, so nonzero manual releases are refused while bytes are live and underflow is rejected without mutating either counter.

Source

pub fn alloc_raw( self: &Arc<Self>, bytes: usize, tag: AllocTag, ) -> Result<RuntimeAllocBlock>

v0.6 device-runtime entry point: allocate bytes raw bytes through the attached XlogDeviceRuntime.

Returns a RuntimeAllocBlock that owns the allocation. On drop, the block deallocates through the runtime and updates both the manager’s local allocated counter and the runtime’s bookkeeping.

Both budgets apply: the manager’s local MemoryBudget::device_bytes AND any GlobalDeviceBudget stacked above the runtime’s underlying resource. Either rejecting the request returns an XlogError. On runtime rejection the local reservation is rolled back so subsequent allocations see consistent state.

§Errors
  • XlogError::Kernel if no runtime is attached.
  • XlogError::ResourceExhausted if the local budget cannot accommodate the request.
  • XlogError::ResourceExhausted if the runtime’s budget rejects the request. Other runtime errors are reported as XlogError::Kernel.
Source

pub fn remaining_bytes(&self) -> u64

Get remaining budget in bytes

Source

pub fn reset_tracking(&self) -> Result<()>

Reset diagnostic tracking only when no tracked bytes are live.

Auto Trait Implementations§

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> Same for T

Source§

type Output = T

Should always be Self
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.