MPI generally follows a Single Program Multiple Data (SPMD) programming model, whereby a single executable (called a process) is duplicated and executed on multiple processors. Each process (within the MPI Communication World) is uniquely identified by its rank and individual processes can communicate between each other using MPI message-passing routines.
MPI can also accommodate a Multiple Programming Multiple Data (MPMD) programming paradigm (where each process is a different executable) but this approach is less used (and supported) compared to the SPMD approach.
Figure 1 shows a typical MPI communication world (initially referred to as MPI_COMM_WORLD) with 4 processes (labeled P) each identified with a unique rank in the range 0-3. Each process executes the same task T. Processes communicate among other processes in the communication world by sending and receiving messages.
Even though each process contains an instance of the same executable, different instruction streams can be executed by embedding rank dependent code into the executable e.g.
if (myrank .eq. 0) then
call do_this_work_on_process_0()
else if (myrank .eq. 1) then
call do_this_work_on_process_1()
else
call do_this_work_on_remaining_processes()
end if
The most fundamental MPI operations can be classified into 3 groups:
- MPI Initialization and Finalization
- Initialization: MPI_Init()
- Finalization: MPI_Finalize()
- Querying Process Rank and Communication World Size
- Query Process Rank: MPI_Comm_rank()
- Query World Size: MPI_Comm_size()
- Sending and Receiving of Messages
- Send Message: MPI_Send()
- Receive Message: MPI_Receive()
For more detailed information on MPI, download and review the latest MPI standard
specification.