Allreduce is a collective algorithm that combines the values stored by each process into a single value available to all processes. The values are combined in a user-defined way, specified via a delegate. If value1, value2, ..., valueN are the values provided by the N processes in the communicator, the result will be the value value1 op value2 op ... op valueN. An Allreduce is equivalent to a Reduce<(Of <(T>)>)(T, ReductionOperation<(Of <(T>)>), Int32) followed by a Broadcast<(Of <(T>)>)(T%, Int32).

Namespace:  MPI
Assembly:  MPI (in MPI.dll)
Version: (


public T Allreduce<T>(
	T value,
	ReductionOperation<T> op
Visual Basic (Declaration)
Public Function Allreduce(Of T) ( _
	value As T, _
	op As ReductionOperation(Of T) _
) As T
Visual C++
generic<typename T>
T Allreduce(
	T value, 
	ReductionOperation<T>^ op


Type: T
The local value that will be combined with the values provided by other processes.
Type: MPI..::.ReductionOperation<(Of <(T>)>)
The operation used to combine two values. This operation must be associative.

Type Parameters

Any serializable type.

Return Value

The result of the reduction. The same value will be returned to all processes.


This example computes the sum of the ranks of all of the processes using Allreduce<(Of <(T>)>)(T, ReductionOperation<(Of <(T>)>)).
using System;
using MPI;

class Allreduce
  static void Main(string[] args)
    using (MPI.Environment env = new MPI.Environment(ref args))
      Communicator world =;

      int sum = world.Allreduce(world.Rank, Operation<int>.Add);
      System.Console.WriteLine("Sum of ranks = " + sum);

See Also