Struct HybridDispatcher
pub struct HybridDispatcher {
config: HybridConfig,
stats: Arc<HybridStats>,
adaptive_threshold: AtomicUsize,
}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.
Fields§
§config: HybridConfig§stats: Arc<HybridStats>§adaptive_threshold: AtomicUsizeImplementations§
§impl HybridDispatcher
impl HybridDispatcher
pub fn new(config: HybridConfig) -> HybridDispatcher
pub fn new(config: HybridConfig) -> HybridDispatcher
Creates a new hybrid dispatcher.
pub fn with_defaults() -> HybridDispatcher
pub fn with_defaults() -> HybridDispatcher
Creates a dispatcher with default configuration.
pub 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.
pub fn execute<W>(
&self,
workload: &W,
) -> Result<<W as HybridWorkload>::Result, HybridError>where
W: HybridWorkload,
pub fn execute<W>(
&self,
workload: &W,
) -> Result<<W as HybridWorkload>::Result, HybridError>where
W: HybridWorkload,
Executes a workload using the appropriate backend.
Returns the result and records execution statistics.
pub fn execute_measured<W>(
&self,
workload: &W,
) -> Result<<W as HybridWorkload>::Result, HybridError>
pub fn execute_measured<W>( &self, workload: &W, ) -> Result<<W as HybridWorkload>::Result, HybridError>
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.
pub 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.
pub fn execute_cpu<W>(&self, workload: &W) -> <W as HybridWorkload>::Resultwhere
W: HybridWorkload,
pub fn execute_cpu<W>(&self, workload: &W) -> <W as HybridWorkload>::Resultwhere
W: HybridWorkload,
Forces execution on CPU regardless of mode.
pub fn execute_gpu<W>(
&self,
workload: &W,
) -> Result<<W as HybridWorkload>::Result, HybridError>where
W: HybridWorkload,
pub fn execute_gpu<W>(
&self,
workload: &W,
) -> Result<<W as HybridWorkload>::Result, HybridError>where
W: HybridWorkload,
Forces execution on GPU regardless of mode.
pub fn config(&self) -> &HybridConfig
pub fn config(&self) -> &HybridConfig
Returns the configuration.
pub fn stats(&self) -> &HybridStats
pub fn stats(&self) -> &HybridStats
Returns the execution statistics.
pub fn stats_arc(&self) -> Arc<HybridStats>
pub fn stats_arc(&self) -> Arc<HybridStats>
Returns a shared reference to the statistics.
pub fn adaptive_threshold(&self) -> usize
pub fn adaptive_threshold(&self) -> usize
Returns the current adaptive threshold.
pub fn set_adaptive_threshold(&self, threshold: usize)
pub fn set_adaptive_threshold(&self, threshold: usize)
Manually sets the adaptive threshold.
Auto Trait Implementations§
impl !Freeze for HybridDispatcher
impl RefUnwindSafe for HybridDispatcher
impl Send for HybridDispatcher
impl Sync for HybridDispatcher
impl Unpin for HybridDispatcher
impl UnwindSafe for HybridDispatcher
Blanket Implementations§
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<F, W, T, D> Deserialize<With<T, W>, D> for F
§fn deserialize(
&self,
deserializer: &mut D,
) -> Result<With<T, W>, <D as Fallible>::Error>
fn deserialize( &self, deserializer: &mut D, ) -> Result<With<T, W>, <D as Fallible>::Error>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more