Skip to main content

sum_elements

Function sum_elements 

Source
pub fn sum_elements(view: &V2TypedArrayView) -> Option<(u64, NativeKind)>
Expand description

Sum all elements of a numeric (F64/I64/I32) v2 typed array.

F64 and I64 variants use wide::f64x4/wide::i64x4 SIMD reduction on arrays with >= SIMD_SUM_THRESHOLD elements, delivering ~4x throughput on AVX2-capable CPUs. Smaller arrays fall back to scalar accumulation where the SIMD setup overhead would exceed the savings.

Returns (bits, NativeKind::Float64) for F64 inputs and (bits, NativeKind::Int64) for integer inputs. None for Bool inputs.