Open MPI logo

Open MPI User's Mailing List Archives

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

Subject: Re: [OMPI users] MPI_Irecv, MPI_Wait and MPI_Iprobe
From: Lukas Razik (linux_at_[hidden])
Date: 2011-11-20 09:22:56


Hello Mudassar!

>Dear people,
>                       I have a scenario as shown below, please tell me if it is possible or not
>
>
>------------------------------------------------------------------
>while(!IsDone)
>{
>
>// some code here
>
>MPI_Irecv( .......... );
>
>// some code here
>
>MPI_Iprobe( ........., &is_there_a_message);
>
>if(is_there_a_message)
>    MPI_Wait( ....... );
>
>// move forward ... some other code here....
>
>}
>--------------------------------------------------------------------
>
>My scenario is an
asynchronous communication where some other process may or may not send a
 message to this
> process, will MPI_Iprobe find out whether it is necessary to call MPI_Wait()  or not ?

Sorry, but this conveys no sense to me...
1.You don't need to call MPI_Irecv() before MPI_Iprobe() to get the information if there's a new message... :)

2. If MPI_Iprobe() returns that there's a message then you don't need to call MPI_Wait() anymore.
Just receive it by MPI_Recv()... :)

> because if we do not do this the process may start waiting for a message that may not come and will block.

Wouldn't this fit?

---
while(!isDone) {
    // some code here
    MPI_Iprobe(...,there_is_a_message,...); // never blocks
    if( there_is_a_message ) {
        // doesn't block because there's a message:
        MPI_Recv(message,...);
        // here you can use your message:
        process(message);
    }
    else
        process(other_work); // we have no new message so we do another work
}
---
Here the process will receive the message if there's one.
It won't block if there's no message.
If I haven't understood your problem in the right way - please write more systematically
- how receiver should react if there's a message (e.g. receive it or what else?)
- how receiver should react if there's no message (e.g. block or continue with another work?)
Best regards,
Lukas