pub enum DeviceBackend {
Cpu,
}Expand description
Active backend selected at runtime.
Obtain via DeviceBackend::auto_detect for automatic selection, or
DeviceBackend::from_preference to request a specific backend.
§Feature gating
Cudavariant requires--features cuda.Avx2variant requires--features avx2on an x86_64 host.Cpuis always present and is the fallback of last resort.
Variants§
Cpu
Scalar CPU path, delegates to zer-compare (Rayon parallel).
Implementations§
Source§impl DeviceBackend
impl DeviceBackend
Sourcepub fn auto_detect() -> Self
pub fn auto_detect() -> Self
Auto-detect the best available backend: CUDA → AVX2 → CPU scalar.
Never panics; always returns a usable backend. Tracing output explains which path was selected and why alternatives were skipped.
Sourcepub fn cpu() -> Self
pub fn cpu() -> Self
Force the scalar CPU backend regardless of available hardware.
Useful in tests where deterministic, non-SIMD behaviour is required.
Sourcepub fn from_preference(pref: BackendPreference) -> Result<Self, GpuError>
pub fn from_preference(pref: BackendPreference) -> Result<Self, GpuError>
Request a specific backend.
Returns Err(BackendUnavailable) when:
- The requested feature flag was not compiled in.
- The hardware initialisation fails (e.g. no CUDA GPU present).
- The requested ISA extension is absent at runtime (AVX2).
Sourcepub fn run<K: Kernel>(&self, input: K::Input<'_>) -> Result<K::Output, GpuError>where
Self: KernelDispatch<K>,
pub fn run<K: Kernel>(&self, input: K::Input<'_>) -> Result<K::Output, GpuError>where
Self: KernelDispatch<K>,
Dispatch kernel K on this backend.
Sourcepub fn is_accelerated(&self) -> bool
pub fn is_accelerated(&self) -> bool
true when this backend provides any hardware acceleration
(GPU or SIMD), i.e. it is not the scalar CPU fallback.
Sourcepub fn available_vram_bytes(&self) -> Option<u64>
pub fn available_vram_bytes(&self) -> Option<u64>
Available VRAM in bytes, or None for CPU/AVX2 paths.
Sourcepub fn total_vram_bytes(&self) -> Option<u64>
pub fn total_vram_bytes(&self) -> Option<u64>
Total (installed) VRAM in bytes, or None for CPU/AVX2 paths.
Trait Implementations§
Source§impl KernelDispatch<EmReduce> for DeviceBackend
impl KernelDispatch<EmReduce> for DeviceBackend
fn dispatch(&self, input: EmReduceInput<'_>) -> Result<EmReduceOutput, GpuError>
Source§impl KernelDispatch<HelloBackend> for DeviceBackend
impl KernelDispatch<HelloBackend> for DeviceBackend
fn dispatch( &self, input: HelloBackendInput, ) -> Result<HelloBackendOutput, GpuError>
Auto Trait Implementations§
impl Freeze for DeviceBackend
impl RefUnwindSafe for DeviceBackend
impl Send for DeviceBackend
impl Sync for DeviceBackend
impl Unpin for DeviceBackend
impl UnsafeUnpin for DeviceBackend
impl UnwindSafe for DeviceBackend
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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