Skip to main content

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 at build time |
32//! | `avx2`   | x86_64 AVX2 SIMD via `std::arch`, no external toolchain required |
33//!
34//! When no flag is set the crate compiles and runs normally using the
35//! always-available scalar CPU fallback backed by `zer-compare`.
36
37pub mod backend;
38pub mod batch_sizer;
39pub mod comparator;
40pub mod error;
41pub mod kernel;
42pub mod kernels;
43pub mod scorer;
44pub mod soa;
45
46pub use backend::{BackendPreference, DeviceBackend, GpuBackend};
47pub use batch_sizer::BatchSizer;
48pub use comparator::DeviceComparator;
49pub use error::GpuError;
50pub use scorer::DeviceScorer;