tk_pg_greedy_synth/synthesis/parallel_mode.rs
1const PARALLEL_COSTING_THRESHOLD: usize = 150_000;
2
3/// Parallelization mode for gate costing.
4#[derive(Debug, Clone, Copy, PartialEq, Eq)]
5pub enum ParallelMode {
6 /// Always use sequential execution.
7 Off,
8 /// Always use parallel execution.
9 On,
10 /// Use parallel execution when the workload reaches 150,000.
11 Auto,
12}
13
14impl ParallelMode {
15 /// Reports whether the two workload dimensions justify parallel execution.
16 ///
17 /// Auto mode uses parallel costing at a workload product of 150,000. This
18 /// inherited tuning threshold should only change after representative
19 /// benchmarks.
20 pub(crate) fn should_use_parallel(self, work_items: usize, candidates: usize) -> bool {
21 match self {
22 Self::Off => false,
23 Self::On => true,
24 Self::Auto => work_items.saturating_mul(candidates) >= PARALLEL_COSTING_THRESHOLD,
25 }
26 }
27}