Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ok to call MPI_Isend multiple times on one buffer?

Regarding MPI_Isend, the MPI standard says "A nonblocking send call indicates that the system may start copying data out of the send buffer. The sender should not access any part of the send buffer after a nonblocking send operation is called, until the send completes." (http://www.mpi-forum.org/docs/mpi-11-html/node46.html)

Is referencing the send buffer in another send call ok, or is that included in "access any part of the send buffer"?

In other words, is the following C code for the sender correct?

MPI_Request req[2];
MPI_Status statuses[2];
...
MPI_Isend(buf, type, count, dest0, tag, comm, &req[0]);
MPI_Isend(buf, type, count, dest1, tag, comm, &req[1]);
MPI_Waitall(2, req, statuses);
like image 213
Posco Grubb Avatar asked Jun 12 '13 20:06

Posco Grubb


2 Answers

The MPI Standard does allow for this kind of usage.

If there are more that a "handful" of ranks that need the same buffer, or if this communication patter will be repeated more than a "handful" of times...then creating a comm with the relevant ranks, and using MPI_Bcast would be preferable.

EDIT:

To clarify my own answer. The MPI 2.0 Standard specifically prohibited this kind of usage. The restriction was to accommodate Fortran. The MPI 2.1 or 2.2 Standard included a "clarification" that this re-use of a send buffer in multiple ISends was permissible. See Section 16.2.2 of the MPI 2.2 Standard for more.

like image 128
Stan Graves Avatar answered Sep 24 '22 18:09

Stan Graves


I just consulted the MPI 3.0 Standard and found the following information:

A nonblocking send call indicates that the system may start copying data out of the send buffer. The sender should not modify any part of the send buffer after a nonblocking send operation is called, until the send completes.

However, I very recently attended a tutorial on MPI 3.0 given by some of the developers of the standard and it was mentioned that, depending on the MPI implementation (MPICH, LAM, etc.), it may be unsafe to access a buffer used in a nonblocking communication call as the buffer may be modified from the Isend procedure before the send is complete. In other words, it might not be guaranteed that the buffer in the second MPI_Isend is the same as the buffer in the first send. In order to figure this out for sure, I would consult your implementation source code.

like image 42
Alex Brooks Avatar answered Sep 23 '22 18:09

Alex Brooks