Open MPI logo

Open MPI User's Mailing List Archives

  |   Home   |   Support   |   FAQ   |   all Open MPI User's mailing list

Subject: Re: [OMPI users] possible mismatch between MPI_Iprobe and MPI_Recv?
From: Jeff Squyres (jsquyres_at_[hidden])
Date: 2010-11-22 18:38:01


On Nov 21, 2010, at 1:46 PM, Riccardo Murri wrote:

> I'm using code like this:
>
> MPI_Iprobe(MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &flag, &status);
> if(flag) {
> int size;
> MPI_Get_count(&status, MPI_BYTE, &size);
> void* row = xmalloc(size);
> /* ... */
> MPI_Recv(row, size, MPI_BYTE,
> status.MPI_SOURCE, status.MPI_TAG, MPI_COMM_WORLD,
> &status);
> /* ... */
> }
>
> Question: is it possible that, in the time my program progresses from
> MPI_Iprobe() to MPI_Recv(), another message has arrived, that matches
> the MPI_Recv(), but is not the one originally matched from
> MPI_Iprobe()? (e.g. a shorter one)

No. MPI guarantees matching order. Given that you're receiving on a very specific signature (i.e., the source and tag from the successful probe), messages will be received in order.

As long as there's no other possible MPI_RECV on that signature between your MPI_IPROBE-that-returns-flag==true and the MPI_RECV shown above, then your MPI_RECV should be receiving the message that MPI_IPROBE returned flag==true for.

> In particular, could it be that the size of the message actually
> received by MPI_Recv() does not match `size` (the variable)?

No.

> In case a shorter message (different from the one initially matched)
> was received, can I get the actual message size via a new call to
> MPI_Get_count(&mpi_recv_status ...)?

You certainly can, but you should not need to -- they should be the same size.

-- 
Jeff Squyres
jsquyres_at_[hidden]
For corporate legal information go to:
http://www.cisco.com/web/about/doing_business/legal/cri/