Tutorial by Examples

To get the size of a communicator (e.g. MPI_COMM_WORLD) and the local process' rank inside it: int rank, size; int res; MPI_Comm communicator = MPI_COMM_WORLD; res = MPI_Comm_rank (communicator, &rank); if (res != MPI_SUCCESS) { fprintf (stderr, "MPI_Comm_rank failed\n"); ...
Before any MPI commands can be run, the environment needs to be initialized, and finalized in the end: int main(int argc, char** argv) { int res; res = MPI_Init(&argc,&argv); if (res != MPI_SUCCESS) { fprintf (stderr, "MPI_Init failed\n"); exit (...
Three things are usually important when starting to learn to use MPI. First, you must initialize the library when you are ready to use it (you also need to finalize it when you are done). Second, you will want to know the size of your communicator (the thing you use to send messages to other process...
Almost any MPI call returns an integer error code, which signifies the success of the operation. If no error occurs, the return code is MPI_SUCCESS: if (MPI_Some_op(...) != MPI_SUCCESS) { // Process error } If an error occurs, MPI calls an error handler associated with the communicator, ...

Page 1 of 1