[This is preliminary documentation and is subject to change.]
Allreducec> 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:
MPIAssembly: MPI (in MPI)
Version: 0.5.0.0 (0.5.0.0)
Syntax
| C# |
|---|
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++ |
|---|
public: generic<typename T> T Allreduce( T value, ReductionOperation<T>^ op ) |
Parameters
- value
- Type: T
The local value that will be combined with the values provided by other processes.
- op
- Type: MPI..::.ReductionOperation<(Of <(T>)>)
The operation used to combine two values. This operation must be associative.
Type Parameters
- T
- Any serializable type.
Return Value
The result of the reduction. The same value will be returned to all processes.
Examples
This example computes the sum of the ranks of all of the processes using
Allreduce<(Of <(T>)>)(T, ReductionOperation<(Of <(T>)>)).
CopyC#
using System; using MPI; class Allreduce { static void Main(string[] args) { using (MPI.Environment env = new MPI.Environment(ref args)) { Communicator world = Communicator.world; int sum = world.Allreduce(world.Rank, Operation<int>.Add); System.Console.WriteLine("Sum of ranks = " + sum); } } };