pub fn sum<T: Copy + Zero + Add<Output = T> + MaybeSendSync + MaybeSimdOps, Op: ElementOp<T>>(
src: &StridedView<'_, T, Op>,
) -> Result<T>Expand description
Sum all elements: sum(src).
§Evaluation order
The result is independent of the ambient pool width when the call runs under
the sequential policy — ExecContext::serial
or with_execution_policy with
ExecutionPolicy::Sequential. Under a
parallel policy a contiguous identity operand above the threading threshold
is summed per worker and the partial sums are combined in a tree, so the
result is repeatable for a fixed thread count but can differ between thread
counts.
Neither path is a strict left to right sum: a contiguous run is folded with
independent SIMD or scalar lanes (see reduce for the lane scheme of the
generic path). The last bits can therefore differ from a naive loop, and no
bitwise equality across machines or target features is guaranteed.
For a deterministic accumulation of f32 data in f64, use
zip_reduce with an f64 map and a 0.0f64 init.
§Allocation
At rank ≤ INLINE_RANK the view metadata and
the traversal plan are stored inline, so a call performs no heap allocation.