Ernesto,

MPI_Bcast() has no barrier semantic.
It means the root rank can return after the message is sent (kind of eager
send) and before it is received by other ranks.


Cheers,

Gilles

On Sat, Apr 2, 2022, 09:33 Ernesto Prudencio via users <
users@lists.open-mpi.org> wrote:

> I have an “extreme” case below, for the sake of example.
>
>
>
> Suppose one is running a MPI job with N >= 2 ranks, and at a certain
> moment the code does the following:
>
>
>
> .
>
> .
>
> .
>
> If (rank == 0) {
>
>     MPI_Bcast(…);
>
> }
>
> .
>
> .
>
> .
>
> std::cout << “Here A, rank = “ << rank << std::endl;
>
> MPI_Barrier(…);
>
> std::cout << “Here B, rank = “ << rank << std::endl;
>
> .
>
> .
>
> .
>
>
>
> I thought rank 0 would never print the message “Here A”, because he MPI
> lib at rank 0 would be stuck on the MPI_Bcast waiting for all other ranks
> to notify (internally, in the MPI lib logic) that they have received the
> contents.
>
>
>
> But this seems not to be the case. Instead, the code behaves as follows:
>
>    1. MPI_Bcast() returns the processing to rank 0, so it (rank 0) prints
>    the “Here A” message (and all the other ranks print “Here A” as well).
>    2. All ranks get to the barrier, and then all of them print the “Here
>    B” message afterwards.
>
>
>
> Am I correct on the statements (1) and (2) above?
>
>
>
> Thanks,
>
>
>
> Ernesto.
>
> Schlumberger-Private
>

Reply via email to