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_iprobe not behaving as expect
From: Eugene Loh (eugene.loh_at_[hidden])
Date: 2010-06-09 12:38:11


I'll take a stab at this since I don't remember seeing any other replies.

At least in the original code you sent out, you used Isend/sleep/Wait to send messages.  So, I'm guessing that part of the message is sent, Iprobe detects that a matching message is in-coming, and then the receiver goes into MPI_Recv.  This call then can begin to receive the message, but it's stuck waiting for the remainder of the message to arrive.  Off hand, I don't know if that is how MPI_Iprobe is supposed to behave or not.  I see

http://www.mpi-forum.org/docs/mpi-11-html/node50.html#Node50
MPI_IPROBE(source, tag, comm, flag, status) returns flag = true if there is a message that can be received and that matches the pattern specified by the arguments source, tag, and comm.

I suppose this language leaves open the possibility that the message is not yet 100% available to be read, but only that the message header has been received and that it sufficiently matches that specified matching criteria.

David Zhang wrote:
I have modified the code so that all the terminal outputs are done by one executable.  I have attached the source files, after compiling type "make go" and the code will execute.

The previous code output was from a supercomputer cluster where the two processes resides on two different nodes.  When running the same code on a regular-multiprocessor machine (mac mini in this case), I got this output:
 F
 F
 T
           1
 F
 T
           2
 F
 T
           3
 F
 T
           4

If I'm sending a message every 2 seconds and I'm polling every 0.05 second, I would expect 39 F and 1 T between each number.  At least when I ran it on the supercomputer, this is true during the very beginning; however I don't even see this when I'm running the code on my mac mini.

On Sat, Jun 5, 2010 at 2:44 PM, David Zhang <solarbikedz@gmail.com> wrote:
Dear all:

I'm using mpi_iprobe to serve as a way to send signals between different mpi executables. I'm using the following test codes (fortran):

#1
program send
implicit none
        include 'mpif.h'

real*8 :: vec(20000)=1.0
integer :: ierr,i=0,request(1)

        call mpi_init(ierr)
        do
                call mpi_isend(vec,20000,mpi_real8,
0,1,mpi_comm_world,request(1),ierr)
                i=i+1
                print *,i
                vec=-vec
                call usleep_fortran(2.d0)
                call mpi_wait(request(1),MPI_STATUS_IGNORE,ierr)
        end do

end program send
--------------------------------------------------
#2
program send
implicit none
        include 'mpif.h'

real*8 :: vec(20000)
integer :: ierr

        call mpi_init(ierr)
        do
                if(key_present()) then
                        call mpi_recv(vec,20000,mpi_real8,1,1,mpi_comm_world,MPI_STATUS_IGNORE,ierr)
                end if
                call usleep_fortran(0.05d0)

        end do

contains

function key_present()
implicit none
  logical :: key_present

        key_present = .false.
        call mpi_iprobe(1,1,mpi_comm_world,key_present,MPI_STATUS_IGNORE,ierr)
        print *, key_present

end function key_present

end program send
-----------------------------------
The usleep_fortran is a routine I've written to pause the program for that amount of time (in seconds).  As you can see, on the receiving end I'm probing to see whether the message has being received every 0.05 seconds, where each probing would result a print of the probing result; while the sending is once every 2 seconds. 

Doing
mpirun -np 1 recv : -np 1 send
 Naturally I expect the output to be something like:

1
(fourty or so F)
T
2
(another fourty or so F)
T
3

however this is the output I get:

1
(fourty or so F)
T
2
(about a two second delay)
T
3

It seems to me that after the first set of probes, once the message was received, the non-blocking mpi probe becomes blocking for some strange reason.  I'm using mpi_iprobe for the first time, so I'm not sure if I'm doing something blatantly wrong.