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

Lu, Huiwei huiweilu at mcs.anl.gov
Wed Apr 16 16:36:51 CDT 2014


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/




More information about the discuss mailing list