1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
//! Compile-time execution policies for data-parallel operations.
//!
//! A policy decides *whether* a data-parallel operation runs in parallel. The
//! types are zero-sized **type-level markers** — the decision is an associated
//! function, so generic code over `P: ExecutionPolicy` monomorphizes to one
//! concrete path with no value passed and no dynamic dispatch:
//!
//! - [`Sequential`] / [`Parallel`] return a constant, so the unused branch is
//! eliminated entirely at compile time.
//! - [`Adaptive`] parallelizes only at or above [`ADAPTIVE_PARALLEL_THRESHOLD`],
//! a cheap inlined runtime check that routes per workload size (and thus across
//! the worker threads only when worthwhile).
//!
//! Select a policy by type via the [`ParallelSlice`](crate::ParallelSlice) /
//! [`ParallelSliceMut`](crate::ParallelSliceMut) extension traits
//! (`slice.par_with::<Parallel>()`) or the `*_with::<P>` functions; the `par_*`
//! helpers and `slice.par()` use [`Adaptive`] as the unset default.
/// Element count at or above which [`Adaptive`] chooses parallel execution.
///
/// Mirrors `moirai-iter`'s `parallel_threshold`: below this, dispatch and join
/// overhead typically exceeds the benefit of parallelism.
pub const ADAPTIVE_PARALLEL_THRESHOLD: usize = 1024;
/// Compile-time strategy selector for the data-parallel operations in this crate.
///
/// Implemented by zero-sized marker types; used purely as a type parameter so
/// each operation monomorphizes to a single concrete path.
/// Always run sequentially (single thread, no scheduling).
;
/// Always run in parallel on the shared work-stealing pool.
;
/// Run in parallel only for inputs at or above [`ADAPTIVE_PARALLEL_THRESHOLD`].
;
/// Run in parallel only for inputs at or above the custom threshold `N`.
;