Open MPI logo

Open MPI User's Mailing List Archives

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

Subject: Re: [OMPI users] do all processors have to execute MPI_Bcast?
From: David Zhang (solarbikedz_at_[hidden])
Date: 2010-07-17 08:13:25


collective calls return once it receive reply from everyone in the
communicator that the message has been received (this is done under the
hood). Thus since only one process in the communicator calls Bcast, that
process will hang indefinitely waiting for reply from other processes on the
same communicator.

On Sat, Jul 17, 2010 at 1:13 AM, Anton Shterenlikht <mexas_at_[hidden]>wrote:

> On Fri, Jul 16, 2010 at 05:20:53PM -0400, Prentice Bisbal wrote:
> >
> >
> > Eugene Loh wrote:
> > > Anton Shterenlikht wrote:
> > >
> > >> Will this bit of code work:
> > >>
> > >> if (rank .eq. <somerank>) then
> > >>
> > >> *change var*
> > >>
> > >> call MPI_Bcast(var, 1, MPI_INTEGER, rank, &
> > >> MPI_COMM_WORLD, errstat)
> > >> end if
> > >>
> > >> call MPI_Barrier(MPI_COMM_WORLD, errstat)
> > >>
> > >> I'm using a int variable on all processors.
> > >> At some point some process can change its
> > >> value of this variable.
> > >> I then need to let all other
> > >> processes know the new value. So I tried
> > >> to use MPI_Bcast for this. But I think
> > >> MPI waits indefinitely at MPI_Barrier.
> > >>
> > >> I'm now wondering if MPI_Bcast must
> > >> be executed by all processes, similar
> > >> to MPI_Barrier. Is this correct?
> > >>
> > > All processes in the communicator must make the collective call...
> > > Bcast, Barrier, Allreduce, etc.
> >
> > Therefore, following a Bcast with a Barrier is redundant in this example.
>
> Sorry, just to be absolutely clear, are you saying
> that even though only one process in the communicator
> is calling Bcast, the call will be made on all
> processes?
>
> Or are you saying I cannot put Bcast (or any other collective call)
> inside a "if (rank== ...) {} " construct?
>
> many thanks
> anton
>
> --
> Anton Shterenlikht
> Room 2.6, Queen's Building
> Mech Eng Dept
> Bristol University
> University Walk, Bristol BS8 1TR, UK
> Tel: +44 (0)117 331 5944
> Fax: +44 (0)117 929 4423
> _______________________________________________
> users mailing list
> users_at_[hidden]
> http://www.open-mpi.org/mailman/listinfo.cgi/users
>

-- 
David Zhang
University of California, San Diego