HPC - NRW 02 MPI Concepts
HPC - NRW 02 MPI Concepts
MPI in Small Bites THE COMPETENCE NETWORK FOR HIGH PERFORMANCE COMPUTING IN NRW.
MPI Concepts
HPC.NRW Competence Network
- Initializes the MPI library and makes the process member of MPI_COMM_WORLD
- [C] Both arguments must be either NULL or they must point to the arguments of main()
- May not be called more than once for the duration of the program execution
- Error code as return value in [C] and additional parameter in [F]
C: ierr = MPI_Finalize();
- Finalization: Fortran: CALL MPI_Finalize(ierr)
- Cleans up the MPI library and prepares the process for termination
- Must be called once before the process terminates
- Having other code after the finalisation call is not recommended
?
?
?
? ?
?
? ?
2
3
1
6 0
MPI communicator
7
4 5
- The processes in any MPI program are initially indistinguishable (for the user)
- MPI assigns each process a unique identity (rank) in a communication context
(communicator)
- Ranks
- Range from 0 to n-1 (with n processes in the communicator)
- An MPI process can have different ranks in different communicators
- Communicators
- Logical contexts where communication takes place
- Comprises a group of MPI processes with some additional information
- MPI_COMM_WORLD is implicitly available
- Comprises all processes initially started with the MPI program
cc mpicc
c++ mpic++
f90 mpif90
- The standard specifies the mpiexec program, but does not require it:
- IBM BG/Q: runjob --np 1024 …
- SLURM resource manager: srun …
- C (mpi.h)
- typedef’d handle types: MPI_Comm, MPI_Datatype, MPI_File, etc.
- MPI is a library
- Cannot infer datatypes of supplied buffers at runtime
- User needs to provide additional information on buffer type
- Type Signatures
- Sequence of basic datatypes in a buffer
- Basic datatypes correspond to native language datatypes
- Type Maps
- Sequence of basic datatypes AND their location in a buffer
- Type signatures of associated operations have to match; Type map may differ!
MPI in Small Bites INNOVATION THROUGH COOPERATION.
Basic MPI Datatypes
… … MPI_CHARACTER CHARACTER(1)
MPI_BYTE - … …
MPI_BYTE -
8 binary digits
no conversion
used for untyped data
MPI in Small Bites INNOVATION THROUGH COOPERATION.
Local vs. Non-local Procedures
- Four stages
1. Initialization – Resources (argument lists, buffer address, etc.) are handed to the MPI library
2. Starting – The operation takes over control of the resources (buffer contents)
3. Completion – Return control of the resources (buffer contents)
4. Freeing – Return control of the remaining resources