<< MPI_Recv | Message Passing Interface | MPI_Send >> |
r = MPI_Reduce(Value, Operation, Root) |
r = MPI_Reduce(Value, Operation, Root, Comm) |
value to send: numeric or logical array (sparse not supported).
a string: MPI_SUM, MPI_MAX, MPI_MIN, MPI_SUM, MPI_PROD, MPI_LAND, MPI_LOR, MPI_BAND, MPI_BOR, MPI_LXOR or MPI_BXOR
a integer value: rank of root process.
a MPI_Comm object.
received value
Reduces values on all processes to a single value.
Nelson does not check to ensure that the reduction operation are all the same size across the various processes in the group.
Please be sure that each process passes the same sized array to the MPI_Allreduce operation.
mpiexec([modulepath('mpi'), '/examples/help_examples/MPI_Reduce.m'], 4)
if ~MPI_Initialized()
MPI_Init();
end
my_rank = MPI_Comm_rank ();
num_ranks = MPI_Comm_size();
A = [1 + my_rank:3 + my_rank]
B = MPI_Reduce(A, 'MPI_SUM', 0);
if (my_rank == 0)
disp('Result:')
B
end
if MPI_Initialized()
MPI_Finalize();
end
Version | Description |
---|---|
1.0.0 | initial version |
Allan CORNET