Skip to main content

CudaDeviceError

Enum CudaDeviceError 

Source
#[non_exhaustive]
pub enum CudaDeviceError { Discovery { operation: &'static str, source: BoxError, }, Unavailable { requested: CudaDeviceId, discovered: Box<[CudaDeviceInfo]>, }, Initialization { device: CudaDeviceId, operation: &'static str, source: BoxError, }, }
Expand description

Structured failures from CUDA device discovery and initialization.

The error retains only provider-neutral device identities and metadata. It does not expose the concrete CUDA runtime error type behind a source.

§Examples

use tenferro_gpu::{cuda::CudaDeviceError, cuda::CudaDeviceId};

let error = CudaDeviceError::Unavailable {
    requested: CudaDeviceId::from_ordinal(1),
    discovered: Vec::new().into_boxed_slice(),
};
assert_eq!(error.requested(), Some(CudaDeviceId::from_ordinal(1)));

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Discovery

Device discovery failed while performing the named operation.

Fields

§operation: &'static str

The provider-neutral discovery operation being performed.

§source: BoxError

The underlying discovery failure.

§

Unavailable

The requested device was not present in the discovered device list.

Fields

§requested: CudaDeviceId

The device selected by the caller.

§discovered: Box<[CudaDeviceInfo]>

Devices found during discovery, in discovery order.

§

Initialization

Device initialization failed while performing the named operation.

Fields

§device: CudaDeviceId

The device whose runtime could not be initialized.

§operation: &'static str

The provider-neutral initialization operation being performed.

§source: BoxError

The underlying initialization failure.

Implementations§

Source§

impl CudaDeviceError

Source

pub fn operation(&self) -> Option<&'static str>

Return the operation associated with discovery or initialization.

§Examples
use tenferro_gpu::{cuda::CudaDeviceError, cuda::CudaDeviceId};

let error = CudaDeviceError::Unavailable {
    requested: CudaDeviceId::from_ordinal(1),
    discovered: Vec::new().into_boxed_slice(),
};
assert_eq!(error.operation(), None);
Source

pub fn requested(&self) -> Option<CudaDeviceId>

Return the requested device for an unavailable-device error.

§Examples
use tenferro_gpu::{cuda::CudaDeviceError, cuda::CudaDeviceId};

let requested = CudaDeviceId::from_ordinal(1);
let error = CudaDeviceError::Unavailable {
    requested,
    discovered: Vec::new().into_boxed_slice(),
};
assert_eq!(error.requested(), Some(requested));
Source

pub fn discovered(&self) -> Option<&[CudaDeviceInfo]>

Borrow the devices discovered for an unavailable-device error.

§Examples
use tenferro_gpu::{cuda::CudaDeviceError, cuda::CudaDeviceId};

let error = CudaDeviceError::Unavailable {
    requested: CudaDeviceId::from_ordinal(1),
    discovered: Vec::new().into_boxed_slice(),
};
assert!(error.discovered().is_some_and(<[_]>::is_empty));
Source

pub fn device(&self) -> Option<CudaDeviceId>

Return the device whose initialization failed.

§Examples
use tenferro_gpu::{cuda::CudaDeviceError, cuda::CudaDeviceId};

let device = CudaDeviceId::from_ordinal(1);
let error = CudaDeviceError::Initialization {
    device,
    operation: "create_client",
    source: Box::new(std::io::Error::other("context failed")),
};
assert_eq!(error.device(), Some(device));

Trait Implementations§

Source§

impl Debug for CudaDeviceError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for CudaDeviceError

Source§

fn fmt(&self, __formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Error for CudaDeviceError

Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more

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
§

impl<T> ByRef<T> for T

§

fn by_ref(&self) -> &T

§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Imply<T> for U
where T: ?Sized, U: ?Sized,

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.

§

impl<T> IntoComptime for T

§

fn comptime(self) -> Self

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> MaybeSend for T
where T: Send,

§

impl<T> MaybeSendSync for T
where T: Send + Sync,

§

impl<T> MaybeSync for T
where T: Sync,

§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
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.
§

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

impl<T> WasmNotSend for T
where T: Send,

§

impl<T> WasmNotSendSync for T
where T: WasmNotSend + WasmNotSync,

§

impl<T> WasmNotSync for T
where T: Sync,