From: bingo on
Thanks a lot for the reply. But in my understanding, all the
collective communications like mpi_gather require synchronization,
correct? My problem really do not have this feature at all. Maybe I'm
just being stupid, but it would be nice if the rank=1 processor can
communicate with master node with no dependence on the status of other
slave processors.



On Feb 16, 1:23 pm, Harald Anlauf <anlauf.2...(a)arcor.de> wrote:
> On Feb 16, 9:50 pm, bingo <zhn...(a)gmail.com> wrote:
>
>
>
> > Now I have another question. By doing the loop, as shown below, I'm
> > actually applying dependency between individual slave processors. That
> > said, now the rank=2 need to wait for master processor to receive
> > result from rank=1. Even though the calculation on rank=2 might finish
> > earlier, it won't receive further data until the calculation on rank=1
> > is finished. Even worse, the whole process won't proceed any further
> > if the calculation on one processor get stuck. I think this should be
> > a problem of my bad coding algorithm. Ideally, the slave processors
> > should ran independently, and only communicate with the master node.
> > Is there a way to improve on this?
>
> > Thanks again.
> > Bin
>
> > =====================================
> >       do rank = 1, nprocs-1
> >           ! send initial condition
> >           call mpi_send(config, 4, mpidp, rank, confTag,
> >                         mpi_comm_world, ierror)
> >           ! receive result
> >           call mpi_recv(endInfo, 7, mpidp, rank, endTag,
> >               mpi_comm_world, istatus, ierror)
> >       enddo
>
> Well, this is not really a Fortran-related question,
> but anyway, you have multiple options:
>
> First split the loop into parts where initial data are
> distributed, then another loop where results are collected.
> In these loops:
>
> - Either use mpi_scatter/mpi_gather to distribute the data to
>   the individual PEs, or receive the results.  (Recommended)
>
> - use explicit coding instead of the collective MPI operations.
>
> E.g.:
>
>   do rank = 0, nprocs-1
>      if (node == 0) then
>         if (rank /= node) then
>            call mpi_send (..., rank, ...)
>         end if
>      else ! node /= 0
>         if (rank == node) then
>            call mpi_recv (..., 0, ...)
>         end if
>      end if
>   end do
>
> to distribute the data to the PEs, and corresponding code
> to gather the results.
>
> (Warning: the above code has not been tested, but I think you
> get the idea.  I use similar code on machines where mpi_scatter
> has poor performance or when I need to debug.)

From: Victor Eijkhout on
bingo <zhngbn(a)gmail.com> wrote:

> Even though the calculation on rank=2 might finish
> earlier, it won't receive further data until the calculation on rank=1
> is finished.

Yep, I noticed that.

You need to look into the Isend and Irecv calls. They send the data off
asynchronously. Then when you've sent data to all slaves, do a receive
from MPI_ANY_SOURCE and process data as it comes in.

Victor.
--
Victor Eijkhout -- eijkhout at tacc utexas edu
From: Harald Anlauf on
On Feb 17, 8:30 pm, bingo <zhn...(a)gmail.com> wrote:
> Thanks a lot for the reply. But in my understanding, all the
> collective communications like mpi_gather require synchronization,
> correct? My problem really do not have this feature at all. Maybe I'm
> just being stupid, but it would be nice if the rank=1 processor can
> communicate with master node with no dependence on the status of other
> slave processors.

I spend quite some effort on getting a good load balance of my
application
so that I can use blocking communication and get good efficiency.

From your last comment I infer that your application should
dynamically
distribute the load. I think you're better off asking in an MPI-
related
newsgroup.