zer_compute/lib.rs
1//! `zer-compute`, hardware-accelerated backend for entity resolution.
2//!
3//! Provides [`DeviceComparator`] and [`DeviceScorer`] as drop-in replacements for
4//! the CPU-only counterparts in `zer-compare`. Both implement the same
5//! [`zer_core::traits::Comparator`] and [`zer_core::traits::Scorer`]
6//! traits, so the rest of the pipeline is backend-agnostic.
7//!
8//! # Backend selection
9//!
10//! ```rust
11//! use std::sync::Arc;
12//! use zer_compute::{GpuBackend, DeviceComparator, DeviceScorer};
13//! use zer_core::schema::{FieldKind, SchemaBuilder};
14//!
15//! let schema = SchemaBuilder::new()
16//! .field("naam", FieldKind::Name)
17//! .field("datum", FieldKind::Date)
18//! .build()
19//! .unwrap();
20//!
21//! // Auto-detect: tries CUDA → AVX2 → CPU in order.
22//! let backend = Arc::new(GpuBackend::auto_detect());
23//! let comparator = DeviceComparator::new(Arc::clone(&backend), &schema).unwrap();
24//! let scorer = DeviceScorer::new(Arc::clone(&backend));
25//! ```
26//!
27//! # Feature flags
28//!
29//! | Flag | Description |
30//! |------------------|---|
31//! | `cuda` | NVIDIA CUDA via `cudarc`, requires CUDA Toolkit 13.1+ and `nvcc` at build time |
32//! | `vulkan` | Vulkan 1.3 compute via `ash`, requires `slangc` on `PATH` at build time |
33//! | `avx2` | x86_64 AVX2 SIMD via `std::arch`, no external toolchain required |
34//! | `cpu` | Explicit scalar CPU path backed by `zer-compare` (Rayon parallel) |
35//! | `debug-shaders` | Embed debug info in compiled CUDA kernels for `cuda-gdb` / Nsight stepping |
36//!
37//! When no flag is set the crate compiles and runs normally using the
38//! always-available scalar CPU fallback backed by `zer-compare`.
39
40pub mod backend;
41pub mod batch_sizer;
42pub mod comparator;
43pub mod error;
44pub mod kernel;
45pub mod kernels;
46pub mod scorer;
47pub mod soa;
48
49pub use backend::{BackendPreference, DeviceBackend, GpuBackend};
50pub use batch_sizer::BatchSizer;
51pub use comparator::DeviceComparator;
52pub use error::GpuError;
53pub use scorer::DeviceScorer;