Skip to main content

Module backend

Module backend 

Source
Expand description

Backend abstraction, DeviceBackend enum, BackendPreference, and auto-detection logic.

§Selecting a backend

// Auto: CUDA → AVX2 → CPU scalar
let backend = DeviceBackend::auto_detect();

// Explicit with error if not compiled in or hardware missing
let backend = DeviceBackend::from_preference(BackendPreference::Cuda)?;

§Dispatching kernels

use zer_compute::kernels::hello_backend::{HelloBackend, HelloBackendInput};

let out = backend.run::<HelloBackend>(HelloBackendInput)?;

run<K> is generic over any K: Kernel for which DeviceBackend: KernelDispatch<K> is implemented. The impl KernelDispatch<K> for DeviceBackend blocks at the bottom of this file do the N-arm match that delegates to the active variant.

Modules§

cpu
CPU backend, pure-CPU implementations of all kernels via zer-compare.

Enums§

BackendPreference
Explicit backend preference passed to DeviceBackend::from_preference.
DeviceBackend
Active backend selected at runtime.

Type Aliases§

GpuBackend
Backward-compatibility alias. New code should use DeviceBackend.