Open MPI logo

Open MPI User's Mailing List Archives

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

Subject: Re: [OMPI users] Should order of implementation matter for MPI_reduce?
From: George Bosilca (bosilca_at_[hidden])
Date: 2013-03-04 17:38:07


The MPI standard is quite clear about this. All collective communications should be entered in exactly the same order by all participants. If I'm not mistaken there is an entire subsection (5.13) addressing the correctness of calling the MPI collectives.

  George.

On Mar 4, 2013, at 23:16 , Andrew J Gomes <a-gomes_at_[hidden]> wrote:

> I have the following code which does not give the expected result:
> if (mpi_rank!=0)
> { MPI_Reduce(&intensity,&intensity ,1,MPI_DOUBLE,MPI_SUM,0,MPI_COMM_WORLD);
> MPI_Reduce(&intensity2,&intensity2 ,1,MPI_DOUBLE,MPI_SUM,0,MPI_COMM_WORLD); }
> else
> {
> MPI_Reduce(MPI_IN_PLACE,&intensity2 ,1,MPI_DOUBLE,MPI_SUM,0,MPI_COMM_WORLD);
> MPI_Reduce(MPI_IN_PLACE,&intensity ,1,MPI_DOUBLE,MPI_SUM,0,MPI_COMM_WORLD);}
>
> However if I change the the order of the else block (reduction of intensity variable before intensity2 variable) to :
> else
> {
> MPI_Reduce(MPI_IN_PLACE,&intensity ,1,MPI_DOUBLE,MPI_SUM,0,MPI_COMM_WORLD);
> MPI_Reduce(MPI_IN_PLACE,&intensity2 ,1,MPI_DOUBLE,MPI_SUM,0,MPI_COMM_WORLD);}
>
> I get the expected result. This surprised me. Is there a reason the order of the else block should match the order of the if block? Is there a more robust way of implementing this type of code. Thank you
>
> Andrew
> _______________________________________________
> users mailing list
> users_at_[hidden]
> http://www.open-mpi.org/mailman/listinfo.cgi/users