chronix_analytics/compute/mod.rs
1//! # Chronix Compute Engine
2//!
3//! CPU compute engine for Chronix analytics operations — dot products,
4//! matrix solving, exponential smoothing, differencing, autocorrelation, and
5//! batch statistics. Built on multi-tier SIMD acceleration and rayon
6//! parallelism.
7//!
8//! ## Architecture
9//!
10//! ```text
11//! ┌──────────────────────────────────┐
12//! │ ComputeEngine trait │
13//! ├──────────────────────────────────┤
14//! │ batch_dot_product() │
15//! │ batch_matrix_solve() │
16//! │ batch_exponential_smooth() │
17//! │ batch_difference() │
18//! │ batch_autocorrelation() │
19//! └──────────────┬───────────────────┘
20//! │
21//! ┌─────┴────┐
22//! │ CpuEngine │
23//! │ rayon+SIMD│
24//! └───────────┘
25//! ```
26//!
27//! ## SIMD Operations
28//!
29//! Multi-tier SIMD for common statistical operations:
30//! - `simd_sum`, `simd_mean`, `simd_variance`, `simd_min_max`, `simd_dot_product`, `simd_std_dev`
31//! - x86_64: runtime-detected AVX-512F (8×f64) → AVX2+FMA (4×f64) → SSE2 (2×f64, baseline)
32//! - aarch64: NEON (2×f64, baseline)
33//! - Scalar 4-wide ILP fallback on other architectures
34//! - `simd_tier()` returns the active tier for diagnostics
35//!
36//! ## Buffer Pool
37//!
38//! `BufferPool<T>` provides reusable `Vec<T>` to minimize allocation overhead
39//! in hot compute paths.
40
41#![warn(missing_docs)]
42
43mod buffer_pool;
44mod engine;
45mod error;
46// The SIMD module is the one audited exception to the crate-wide
47// unsafe_code deny: every unsafe block is a runtime-feature-gated
48// std::arch intrinsic call with a // SAFETY: justification.
49#[allow(unsafe_code)]
50// chunks_exact(N) with SIMD lane constants reads clearer than as_chunks::<N>() here.
51#[allow(clippy::chunks_exact_to_as_chunks)]
52mod simd;
53
54pub use buffer_pool::BufferPool;
55pub use engine::{ComputeConfig, ComputeEngine, CpuEngine};
56pub use error::ComputeError;
57pub use simd::{
58 simd_dot_product, simd_mean, simd_mean_variance, simd_min_max, simd_population_variance,
59 simd_range_filter_i64, simd_std_dev, simd_sum, simd_tier, simd_variance,
60};