Message-Passing Programming with MPI
Message-Passing Concepts
Message-Passing Programming with MPI Message-Passing Concepts - - PowerPoint PPT Presentation
Message-Passing Programming with MPI Message-Passing Concepts Overview This lecture will cover message passing model SPMD communication modes collective communications Programming Models Message-Passing Serial Programming
Message-Passing Concepts
Control flow Variables Arrays Human-readable
Serial Programming
Concepts if/then/else Languages Java Fortran struct Python C/C++ Subroutines Implementations icc pgcc -fast crayftn gcc -O3 OO Processes SPMD Concepts Libraries Implementations Intel MPI
Message-Passing Parallel Programming
Groups Send/Receive Collectives javac MPI MPICH2 OpenMPI Cray MPI IBM MPI craycc MPI_Init()
processes
with the program’s data
having many processes co-operate on the same task
receiving messages
2 3
P M P M P M P M P M P M P M P M
Interconnect
a=23 Recv(1,b) Process 1 Process 2 23 23 24 23 Program Data Send(2,a) a=b+1
Program-Multiple-Data (SPMD) model
program, depending on their process ID
main (int argc, char **argv) { if (controller_process) { Controller( /* Arguments */ ); } else { Worker ( /* Arguments */ ); }
}
PROGRAM SPMD IF (controller_process) THEN CALL CONTROLLER ( ! Arguments ! ) ELSE CALL WORKER ( ! Arguments ! ) ENDIF END PROGRAM SPMD
type from the memory of one process to the memory of another process
asynchronous
has started to be received
message has gone
must wait until the message arrives
received.
groups of processes is required
implemented separately, for efficiency
8 8 8 8 8 8
0 1 2 3 4 5 1 3 4 5 2
0 1 2 3 4 5 1 3 4 5 2
1 3 4 5 2 15
passing library provided for you
that often occur in many codes
if (x < 0) print(“Error”); exit;