pub struct HybridDispatcher { /* private fields */ }Expand description
Dispatcher for routing workloads between CPU and GPU.
The dispatcher uses the configured ProcessingMode to decide where to
execute each workload. In Adaptive mode, it learns the optimal threshold
from runtime measurements.
Implementations§
Source§impl HybridDispatcher
impl HybridDispatcher
Sourcepub fn new(config: HybridConfig) -> Self
pub fn new(config: HybridConfig) -> Self
Creates a new hybrid dispatcher.
Sourcepub fn with_defaults() -> Self
pub fn with_defaults() -> Self
Creates a dispatcher with default configuration.
Sourcepub fn should_use_gpu(&self, workload_size: usize) -> bool
pub fn should_use_gpu(&self, workload_size: usize) -> bool
Returns whether GPU should be used for the given workload size.
Sourcepub fn execute<W: HybridWorkload>(
&self,
workload: &W,
) -> HybridResult<W::Result>
pub fn execute<W: HybridWorkload>( &self, workload: &W, ) -> HybridResult<W::Result>
Executes a workload using the appropriate backend.
Returns the result and records execution statistics.
Sourcepub fn execute_measured<W: HybridWorkload>(
&self,
workload: &W,
) -> HybridResult<W::Result>
pub fn execute_measured<W: HybridWorkload>( &self, workload: &W, ) -> HybridResult<W::Result>
Executes a workload and measures both backends for comparison.
In Adaptive mode, this updates the threshold based on measurements.
Returns the result from the faster backend.
Sourcepub fn update_adaptive_threshold(
&self,
_workload_size: usize,
cpu_time: Duration,
gpu_time: Duration,
)
pub fn update_adaptive_threshold( &self, _workload_size: usize, cpu_time: Duration, gpu_time: Duration, )
Updates the adaptive threshold based on runtime measurements.
Sourcepub fn execute_cpu<W: HybridWorkload>(&self, workload: &W) -> W::Result
pub fn execute_cpu<W: HybridWorkload>(&self, workload: &W) -> W::Result
Forces execution on CPU regardless of mode.
Sourcepub fn execute_gpu<W: HybridWorkload>(
&self,
workload: &W,
) -> HybridResult<W::Result>
pub fn execute_gpu<W: HybridWorkload>( &self, workload: &W, ) -> HybridResult<W::Result>
Forces execution on GPU regardless of mode.
Sourcepub fn config(&self) -> &HybridConfig
pub fn config(&self) -> &HybridConfig
Returns the configuration.
Sourcepub fn stats(&self) -> &HybridStats
pub fn stats(&self) -> &HybridStats
Returns the execution statistics.
Sourcepub fn stats_arc(&self) -> Arc<HybridStats>
pub fn stats_arc(&self) -> Arc<HybridStats>
Returns a shared reference to the statistics.
Sourcepub fn adaptive_threshold(&self) -> usize
pub fn adaptive_threshold(&self) -> usize
Returns the current adaptive threshold.
Sourcepub fn set_adaptive_threshold(&self, threshold: usize)
pub fn set_adaptive_threshold(&self, threshold: usize)
Manually sets the adaptive threshold.