Skip to main content

parallel_reduce

Function parallel_reduce 

Source
pub fn parallel_reduce<T, R, Fold, Combine>(
    data: &[T],
    identity: R,
    fold: Fold,
    combine: Combine,
    n_threads: usize,
) -> CoreResult<R>
where T: Sync + 'static, R: Send + Clone + 'static, Fold: Fn(R, &T) -> R + Send + Sync + 'static, Combine: Fn(R, R) -> R,
Expand description

Parallel reduction using a chunk-local reduce followed by a sequential combine across chunks.

  • fold: combine one element T into accumulator R (called per thread).
  • combine: merge two accumulators (called sequentially to merge chunks).
  • identity: neutral element for combine.