Setup and Tear Down
void main(int argc, char *argv) |
starts up the MPI runtime environment at the beginning of a run. |
MPI_Finalize() |
shuts down the MPI runtime environment at the end of a run. |
Gathering Information
MPI_Comm_rank(MPI_COMM_WORLD,&myid) |
gets the process ID that the current process uses, which is between 0 and Np-1 inclusive. |
MPI_Comm_size(MPI_COMM_WORLD,&numprocs) |
gets the number of processes in a run. |
MPI Data Types
MPI_CHAR |
char |
MPI_SHORT |
short int |
MPI_INT |
int |
MPI_FLOAT |
float |
MPI_DOUBLE |
double |
MPI_LONG_DOUBLE |
long double |
MPI_BYTE |
consists of a byte (8 binary digits) |
Compile
mpicc -o file file.c |
compiles MPI programs written in C. |
mpiCC -o file file.cpp |
compiles MPI programs written in C++. |
Run
mpirun -np no_processors file |
run MPI compiled file with no_processors |
Time
MPI_Wtime() |
Returns an elapsed time on the calling processor |
int MPI_Bcast ( *b, c,d, root,MPI_Comm )
b |
The message to be broadcasted |
c |
Number of elements in the message |
d |
The data type of the elements in the message |
root |
The process number that has the message to be broadcasted to others |
MPI_Comm |
The communication world |
MPI_Recv( *b, c, d, sender, t, MPI_Comm, status)
b |
Receive in buffer b |
c |
The number of element of data type d |
d |
The data type of element b |
sender |
The rank of the sender |
t |
The tag used in the communication |
MPI_Comm |
The communication world |
status |
the status of the reception operation |
int MPI_Scatter(sb,sc,sd,rb,rc,rd,root,MPI_Comm)
sb |
The buffer containing the data to disptach from the root process. |
sc |
The number of elements to send to each process, not the total number of elements in the send buffer. |
sd |
The type of one send buffer element |
rb |
The buffer in which store the data dispatched. |
rc |
The number of elements in the receive buffer |
rd |
The type of one receive buffer element. |
root |
The rank of the root process |
MPI_Comm |
The communication world |
Libraries
<mpi.h> |
For MPI implementation |
<stdio.h> |
C input&output |
<math.h> |
Handles Math |
|
|
Terms
Blocking |
return after their actions complete |
Non-Blocking |
return immediately. |
Message Tag |
carried within message and used to differentiate between different types of messages being sent |
MPI_Status |
represents the status of a reception operation. |
MPI Point-to-Point Communication
MPI_Send() |
sends a message from the current process to some other process. |
MPI_Recv() |
receives a message on the current process from some other process. |
Collective Communication
MPI_Bcast() |
Broadcast from root to all other processes |
MPI_Gather() |
Gather values for group of processes |
MPI_Scatter() |
Scatters buffer in parts to group of processes |
MPI_Alltoall() |
Sends data from all processes to all processes |
MPI_Reduce() |
Combine values on all processes to single value |
MPI_Reduce_scatter() |
Combine values and scatter results |
MPI Nonblocking Routines
MPI_Isend() |
Non-blocking send; will return “immediately” |
MPI_Irecv() |
Nonblocking receive; will return even if no message to accept. |
MPI_Wait(request,status) |
waits until operation completed and returns then. |
MPI_Test() |
returns with flag set indicating whether operation completed at that time. |
MPI_Send(*d, c, m, receiver, t, MPI_Comm)
d |
Send Data from address d |
c |
The number of elements of d |
m |
The Datatype of d |
receiver |
The rank of the reciever |
t |
The communication is marked with t tag |
MPI_Comm_World |
The communication world |
int MPI_Gather(sb,sc,sd,rb,rc,rd,root,MPI_Comm)
sb |
The sender buffer |
sc |
The number of elements in the buffer |
sd |
The datatype of one element in the buffer |
rb |
The buffer in which store the gathered data for the root process |
rc |
The number of elements per message received, not the total number of elements to receive from all processes altogether. |
rd |
The type of one receive buffer element. |
root |
MPI_Comm |
The communication world |
int MPI_Reduce(sb,rb,c,d,op,root,MPI_Comm);
sb |
A pointer on the buffer to send for reduction. |
rb |
A pointer on the buffer in which store the result of the reduction |
c |
The number of elements in the send buffer |
d |
The type of a buffer element. |
op |
The operation to apply to combine messages received in the reduction |
root |
The rank of the MPI process that will collect the reduction result. |
MPI_Comm |
The communication world |
|
Created By
Metadata
Comments
No comments yet. Add yours below!
Add a Comment