What if two processes Pi and Pj send message to each other at the same time ? 
Will both block in your suggested code ? 

if not then I can go for that.  BTW, I have tried that before.

regards,




________________________________
 From: Lukas Razik <li...@razik.name>
To: Mudassar Majeed <mudassar...@yahoo.com>; "us...@open-mpi.org" 
<us...@open-mpi.org> 
Sent: Sunday, November 20, 2011 3:22 PM
Subject: Re: [OMPI users] MPI_Irecv, MPI_Wait and MPI_Iprobe
 
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

Reply via email to