Expand description
This module provides the execution policies (sequential / Jacobi-MT / atomic). Execution policies for parallelizable root-finding solvers.
Strategy + Template-Method decomposition:
- Each algorithm supplies a per-root step (the
Steptrait) that computes one Newton correction for a root/factor. The step reads the current values of the other roots through agetclosure provided by the policy, and returns the corrected value; the policy owns all writes to its data layout (live state, frozen snapshot, or seqlock buffer). - Each execution policy owns the iteration loop, the scheduling of the steps, and the convergence aggregation.
This mirrors execution_policy.hpp in ginger-cpp and _policy.py in
ginger (Python): the algorithm (Aberth/Bairstow variant) is decoupled from
the execution mode (sequential Gauss-Seidel, Jacobi-MT, or atomic
decoupled).
Constants§
- PARALLEL_
THRESHOLD - Number of roots above which the multi-threaded policies are used by default.
Traits§
- Atomic
Cell - Atomic cell abstraction over a pair of
f64values (seqlock-backed). - Step
- A per-root Newton correction step shared by every execution policy.
Functions§
- atomic_
decoupled_ run - Atomic decoupled execution: a single seqlock buffer is built once; each thread owns a chunk of slots (single-writer, multi-reader) and runs its own iteration loop independently with no per-iteration barrier, reading the other slots in round-robin order to reduce contention. The returned iteration count is the maximum across threads and is non-deterministic.
- jacobi_
mt_ run - Jacobi multi-threaded execution: each iteration reads a frozen snapshot of the roots and updates them in parallel, so the iteration is order-independent. Small problems (<= 4 roots) fall back to the sequential policy.
- sequential_
run - Sequential Gauss-Seidel execution: roots are updated in-place in ascending index order within each iteration (later roots see earlier updates).
- should_
parallelize - Whether
num_rootsshould use the multi-threaded execution policy.