//! Pluggable compute backends.  The crate ships with a pure-Rust CPU backend
//! by default; the `gpu` feature adds an optional CUDA/cuBLAS backend.

pub mod cpu;
#[cfg(feature = "gpu")]
pub mod gpu;

/// Identifies which compute backend the crate was built against.
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum Backend {
    /// Pure-Rust CPU backend (the default).
    Cpu,
    /// nVIDIA GPU backend (CUDA + cuBLAS), enabled by the `gpu` feature.
    Gpu,
}

// The active backend is chosen at compile time via Cargo features:
//   cargo build              -> CPU (default, no CUDA required)
//   cargo build --features gpu -> GPU (nVIDIA, requires CUDA + cuBLAS)
#[cfg(not(feature = "gpu"))]
pub use self::cpu as current;

/// The backend selected at compile time (`Cpu` unless the `gpu` feature is on).
#[cfg(not(feature = "gpu"))]
pub const BACKEND: Backend = Backend::Cpu;

#[cfg(feature = "gpu")]
pub use self::gpu::nvidia as current;

/// The backend selected at compile time (`Gpu` when the `gpu` feature is on).
#[cfg(feature = "gpu")]
pub const BACKEND: Backend = Backend::Gpu;
