Newsgroups: comp.parallel.mpi
From: A Gordon Smith <smith@epcc.ed.ac.uk>
Subject: Re: Problem with MPI 
Organization: Edinburgh Parallel Computing Centre
Date: Thu, 21 Nov 1996 16:24:09 GMT
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Message-ID: <32948229.41C67EA6@epcc.ed.ac.uk>

Joao Macedo wrote:
> 
> Hi there:
> 
> The following program (which can only be used by 2 processes), works as
> expected.
> 
> But, if I uncomment line
> 
> /* #define USING_MPI_Probe */
> 
> the program just does not work anymore.
> 
> What am I doing wrong whit MPI_Probe?
> 
> Thanks a lot!
> Joao
> 
> /* BEGIN OF PROGRAM */
> [...]
>                 printf("[%d] - Before MPI_Irecv   ...\n", my_id);
>                 fflush(stdout);
>                 MPI_Irecv(recv_buf,
> [...]
>                 printf("[%d] - Before MPI_Irsend  ...\n", my_id);
>                 fflush(stdout);
>                 MPI_Irsend(send_buf,
> [...]
> #ifdef USING_MPI_Probe
> 
>                 printf("[%d] - Before MPI_Probe   ...\n", my_id);
>                 fflush(stdout);
>                 MPI_Probe(MPI_ANY_SOURCE, BOUNDARY_DATA_TAG, MPI_COMM_WORLD,
>                     &status);
> 
> #else /* #ifdef USING_MPI_Probe */
> 
>                 printf("[%d] - Before MPI_Test    ...\n", my_id);
>                 fflush(stdout);
>                 flag = 0;
>                 while (MPI_Test(&request_recv, &flag, &status), !flag)
>                         ;
> #endif /* #ifdef USING_MPI_Probe */
> [...]
> /* END OF PROGRAM */


The problem (PROBE-lem?) here is that the Irsend and Irecv calls
match before the call to MPI_Probe(); the probe call then will
wait forever for another matching send call. You should think
of probe as a "non-destructive" receive call: it blocks in the
same way as an equivalent call to MPI_Recv but does not read the
data. MPI_Test simply checks for completion of the passed request;
in your program, if flag==1, it has finished off the Irecv.

Probe completes, and Iprobe returns success, when an equivalent
new receive would immediately match and complete.

Probe is usually only used when the transfer size is not known
by the receiver in advance; the message size can be found from
the status returned by Probe/Iprobe.

-- 
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
 -=-=- A. Gordon Smith -=- Edinburgh Parallel Computing Centre -=-=-
 =- http://www.epcc.ed.ac.uk/~smith -=- Phone +44 (0)131 650 6712 -=
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

