Expand description
§Hybrid CPU-GPU Processing
Adaptive processing that routes workloads to CPU or GPU based on size and characteristics. Small/irregular workloads use CPU (via Rayon), while bulk parallel operations use GPU.
§Decision Heuristics
| Workload Size | GPU Overhead | Decision |
|---|---|---|
| < threshold | High | CPU |
| >= threshold | Amortized | GPU |
For irregular access patterns (sparse updates, random traversal), CPU may outperform GPU even at larger scales.
§Example
ⓘ
use ringkernel_core::hybrid::*;
// Define your workload
struct MyWorkload { data: Vec<f32> }
impl HybridWorkload for MyWorkload {
type Result = Vec<f32>;
fn workload_size(&self) -> usize { self.data.len() }
fn execute_cpu(&self) -> Self::Result { /* ... */ }
fn execute_gpu(&self) -> Result<Self::Result, HybridError> { /* ... */ }
}
// Create dispatcher and execute
let dispatcher = HybridDispatcher::new(HybridConfig::default());
let result = dispatcher.execute(&workload);Structs§
- Hybrid
Config - Configuration for hybrid processing.
- Hybrid
Config Builder - Builder for
HybridConfig. - Hybrid
Dispatcher - Dispatcher for routing workloads between CPU and GPU.
- Hybrid
Stats - Statistics for hybrid processing decisions.
- Hybrid
Stats Snapshot - A point-in-time snapshot of hybrid processing statistics.
Enums§
- Hybrid
Error - Error type for hybrid processing operations.
- Processing
Mode - Processing mode for hybrid execution.
Traits§
- Hybrid
Workload - Trait for workloads that can be executed on CPU or GPU.
Type Aliases§
- Hybrid
Result - Result type for hybrid processing operations.