[mpich-discuss] Is it a correct program? Sending without receiving.

Wesley Bland wbland at anl.gov
Wed Apr 16 16:48:53 CDT 2014


It's the user's responsibility. The only guarantee made by MPI_Send is that
the data can be overwritten by the user. This may mean that it's copied
into a buffer locally and will be sent later. If the data is being sent
eagerly, this is exactly what's happened. If you want to make sure the data
is actually received, you need to use MPI_Ssend.


On Wed, Apr 16, 2014 at 4:36 PM, Lu, Huiwei <huiweilu at mcs.anl.gov> wrote:

> One of our group members is using MPI_Send in his program without
> receiving. I am surprised why his program will finish.
>
> Here is the program:
>
> #include <mpi.h>
> #include <stdio.h>
> int main(int argc,char** argv)
> {
>     int rank;
>     int size;
>     MPI_Init(&argc, &argv);
>     MPI_Comm_rank(MPI_COMM_WORLD,&rank);
>     MPI_Comm_size(MPI_COMM_WORLD,&size);
>
>     int aa = 10;
>     if(rank == 0) {
>         MPI_Send(&aa, 1, MPI_INT, 1, 0,MPI_COMM_WORLD);
>     }
>     MPI_Barrier(MPI_COMM_WORLD);
>     printf("%d, complete barrier!\n",rank);
>
>     MPI_Finalize();
> }
>
> When I run the above program with: mpiexec -n 2 ./mpi_send. The output is:
> 0, complete barrier!
> 1, complete barrier!
> In direct memory block for handle type REQUEST, 1 handles are still
> allocated
> [1] 8 at [0x00007fe79a7026b8], src/mpid/ch3/src/ch3u_eager.c[440]
>
> The warning tells me the send message is sent using eager protocol. Is it
> right behavior for an MPI_Send to return without actually delivering the
> data?
> Or is it user’s responsibility to pair all the send/receive calls.
>
>> Huiwei Lu
> Postdoc Appointee
> Mathematics and Computer Science Division, Argonne National Laboratory
> http://www.mcs.anl.gov/~huiweilu/
>
> _______________________________________________
> discuss mailing list     discuss at mpich.org
> To manage subscription options or unsubscribe:
> https://lists.mpich.org/mailman/listinfo/discuss
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mpich.org/pipermail/discuss/attachments/20140416/8dd6fe0a/attachment.html>


More information about the discuss mailing list