MPI/en: Difference between revisions

Jump to navigation Jump to search
Updating to match new version of source page
(Updating to match new version of source page)
(Updating to match new version of source page)
Line 692: Line 692:
</tabs>
</tabs>
Is there still a problem here if the number of processors is odd? It might seem so at first as process 0 (which is even) will be sending while process N-1 (also even) is trying to send to 0. But process 0 is originating a send that is correctly paired with a receive at process 1. Since process 1 (odd) begins with a receive, that transaction is guaranteed to complete. When it does, process 0 will proceed to receive the message from process N-1. There may be a (very small!) delay, but there is no chance of a deadlock.
Is there still a problem here if the number of processors is odd? It might seem so at first as process 0 (which is even) will be sending while process N-1 (also even) is trying to send to 0. But process 0 is originating a send that is correctly paired with a receive at process 1. Since process 1 (odd) begins with a receive, that transaction is guaranteed to complete. When it does, process 0 will proceed to receive the message from process N-1. There may be a (very small!) delay, but there is no chance of a deadlock.
 
<!--T:49-->
[~]$ mpicc -Wall phello3.c -o phello3
[~]$ mpicc -Wall phello3.c -o phello3
  [~]$ mpirun -np 16 ./phello3
  [~]$ mpirun -np 16 ./phello3
  [P_1] process 0 said: "Hello, world! from process 0 of 16"]
  [P_1] process 0 said: "Hello, world! from process 0 of 16"]
Line 711: Line 711:
  [P_15] process 14 said: "Hello, world! from process 14 of 16"]
  [P_15] process 14 said: "Hello, world! from process 14 of 16"]
  [P_11] process 10 said: "Hello, world! from process 10 of 16"]
  [P_11] process 10 said: "Hello, world! from process 10 of 16"]
Note that many frequently-occurring communication patterns have been captured in the [http://www.mcs.anl.gov/research/projects/mpi/mpi-standard/mpi-report-1.1/node64.htm#Node64 collective communication] functions of MPI. If there is a collective function that matches the communication pattern you need, you should use it instead of implementing it yourself with <tt>MPI_Send</tt> and <tt>MPI_Recv</tt>.
Note that many frequently-occurring communication patterns have been captured in the [http://www.mcs.anl.gov/research/projects/mpi/mpi-standard/mpi-report-1.1/node64.htm#Node64 collective communication] functions of MPI. If there is a collective function that matches the communication pattern you need, you should use it instead of implementing it yourself with <tt>MPI_Send</tt> and <tt>MPI_Recv</tt>.


38,757

edits

Navigation menu