A Mpi Example

MPI example

The complete MPI interface consist of 129 functions. The functions that is used most oftenly required is those that enable processes to exchange data, that is to be able to send and receive messages.

The following are basic functions that are used to build most MPI programs.

  • All MPI/C programs must include a mpi.h header
  • All MPI programs must call MPI_INT as the first MPI call, to initialize.
  • MPI_COMM_SIZE must be called to get the number of processes that are running
  • MPI_COMM_RANK to determine the process rank, which is a number between 0 and (number of processes) -1
  • General message passing will use MPI_SEND and MPI_RECV
  • All MPI programs must call MPI_Finalize as the last call to an MPI library routine

The following is one of the simple MPI/C programs that makes all involving nodes print "Hallo, world" external link: Sample program