pub struct GpuRuntime {
pub device: GpuDeviceInfo,
pub devices: Vec<GpuDeviceInfo>,
pub policy: GpuDispatchPolicy,
pub memory_budget_bytes: usize,
}Fields§
§device: GpuDeviceInfoHighest-scoring probed CUDA device. Existing dispatch code routes one-shot kernels through this device.
devices: Vec<GpuDeviceInfo>All usable CUDA devices discovered at probe time, ordered by score.
policy: GpuDispatchPolicy§memory_budget_bytes: usizeImplementations§
Source§impl GpuRuntime
impl GpuRuntime
pub fn probe() -> Result<Option<Self>, GpuError>
pub fn global() -> Option<&'static Self>
pub fn is_available() -> bool
Sourcepub fn global_or_fail(mode: GpuMode) -> Result<&'static Self, GpuError>
pub fn global_or_fail(mode: GpuMode) -> Result<&'static Self, GpuError>
Fail-closed accessor for the process-wide runtime under a [GpuMode]
contract (issue #1017).
- [
GpuMode::Required] — the device MUST be present: when the probe found no usable runtime this returnsErr(GpuError::DriverLibraryUnavailable)carrying the recorded CPU reason, so the resident path surfaces a structured error instead of silently falling back to the CPU. - [
GpuMode::Auto] / [GpuMode::Off] — preserve the existing probe-first behavior bit-for-bit: this is a thin wrapper overSelf::globalthat maps theNonecase to the same typed error without ever forcing the runtime on or changing any numerics.Autocallers treat theErrexactly as they treatedglobal().is_none()today (fall back to CPU); only theRequiredcaller propagates it.
This does NOT alter global()/cuda_context_for/ensure_cuda_runtime_device;
it only adds the residency gate on top of the working Auto path.
pub fn policy(&self) -> &GpuDispatchPolicy
pub fn selected_device(&self) -> &GpuDeviceInfo
Source§impl GpuRuntime
impl GpuRuntime
Sourcepub fn device_ordinals(&self) -> Vec<usize>
pub fn device_ordinals(&self) -> Vec<usize>
Ordinals of all usable devices, highest-score first.
self.devices is already score-sorted at probe time, so this simply
projects out the ordinals. Empty only if the probe somehow produced no
devices (the public probe() guarantees at least one on Ok(Some(_))).
Sourcepub fn device_count(&self) -> usize
pub fn device_count(&self) -> usize
Number of usable devices in the pool.
Sourcepub fn memory_budget_for(&self, ordinal: usize) -> usize
pub fn memory_budget_for(&self, ordinal: usize) -> usize
Per-device byte budget: free memory capped at half of total, matching the
primary-device budget computed in device_runtime::probe. Falls back to the
primary memory_budget_bytes when the ordinal is not in the pool so a
caller that passes a stale ordinal still gets a usable (conservative)
budget rather than zero.
Trait Implementations§
Source§impl Clone for GpuRuntime
impl Clone for GpuRuntime
Source§fn clone(&self) -> GpuRuntime
fn clone(&self) -> GpuRuntime
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for GpuRuntime
impl RefUnwindSafe for GpuRuntime
impl Send for GpuRuntime
impl Sync for GpuRuntime
impl Unpin for GpuRuntime
impl UnsafeUnpin for GpuRuntime
impl UnwindSafe for GpuRuntime
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<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T, U> Imply<T> for U
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more