Skip to main content

ringkernel_core/hybrid/
mod.rs

1//! # Hybrid CPU-GPU Processing
2//!
3//! Adaptive processing that routes workloads to CPU or GPU based on size
4//! and characteristics. Small/irregular workloads use CPU (via Rayon),
5//! while bulk parallel operations use GPU.
6//!
7//! ## Decision Heuristics
8//!
9//! | Workload Size | GPU Overhead | Decision |
10//! |---------------|--------------|----------|
11//! | < threshold   | High         | CPU      |
12//! | >= threshold  | Amortized    | GPU      |
13//!
14//! For irregular access patterns (sparse updates, random traversal),
15//! CPU may outperform GPU even at larger scales.
16//!
17//! ## Example
18//!
19//! ```ignore
20//! use ringkernel_core::hybrid::*;
21//!
22//! // Define your workload
23//! struct MyWorkload { data: Vec<f32> }
24//!
25//! impl HybridWorkload for MyWorkload {
26//!     type Result = Vec<f32>;
27//!
28//!     fn workload_size(&self) -> usize { self.data.len() }
29//!     fn execute_cpu(&self) -> Self::Result { /* ... */ }
30//!     fn execute_gpu(&self) -> Result<Self::Result, HybridError> { /* ... */ }
31//! }
32//!
33//! // Create dispatcher and execute
34//! let dispatcher = HybridDispatcher::new(HybridConfig::default());
35//! let result = dispatcher.execute(&workload);
36//! ```
37
38mod config;
39mod dispatcher;
40mod error;
41mod stats;
42mod traits;
43
44pub use config::{HybridConfig, HybridConfigBuilder, ProcessingMode};
45pub use dispatcher::HybridDispatcher;
46pub use error::{HybridError, HybridResult};
47pub use stats::{HybridStats, HybridStatsSnapshot};
48pub use traits::HybridWorkload;