How do I use \( MPI\_reduce \)?

Here we have used

MPI_reduce( void *senddata, void* resultdata, int count, 
     MPI_Datatype datatype, MPI_Op, int root, MPI_Comm comm)

The two variables \( senddata \) and \( resultdata \) are obvious, besides the fact that one sends the address of the variable or the first element of an array. If they are arrays they need to have the same size. The variable \( count \) represents the total dimensionality, 1 in case of just one variable, while \( MPI\_Datatype \) defines the type of variable which is sent and received.

The new feature is \( MPI\_Op \). It defines the type of operation we want to do.