Open MPI logo

Open MPI User's Mailing List Archives

  |   Home   |   Support   |   FAQ   |  

This web mail archive is frozen.

This page is part of a frozen web archive of this mailing list.

You can still navigate around this archive, but know that no new mails have been added to it since July of 2016.

Click here to be taken to the new web archives of this list; it includes all the mails that are in this frozen archive plus all new mails that have been sent to the list since it was migrated to the new archives.

Subject: Re: [OMPI users] MPI_IN_PLACE in a call to MPI_Allreduce in Fortran
From: Hugo Gagnon (opensource.openmpi_at_[hidden])
Date: 2013-09-06 23:14:30


Thanks for the input but it still doesn't work for me... Here's the
version without MPI_IN_PLACE that does work:

program test
use mpi
integer :: ierr, myrank, a(2), a_loc(2) = 0
call MPI_Init(ierr)
call MPI_Comm_rank(MPI_COMM_WORLD,myrank,ierr)
if (myrank == 0) then
  a_loc(1) = 1
  a_loc(2) = 2
else
  a_loc(1) = 3
  a_loc(2) = 4
endif
call MPI_Allreduce(a_loc,a,2,MPI_INTEGER,MPI_SUM,MPI_COMM_WORLD,ierr)
write(*,*) myrank, a(:)
call MPI_Finalize(ierr)
end program test

$ openmpif90 test.f90
$ openmpirun -np 2 a.out
           0 4 6
           1 4 6

Now I'd be curious to know why your OpenMPI implementation handles
MPI_IN_PLACE correctly and not mine!

-- 
  Hugo Gagnon
On Fri, Sep 6, 2013, at 22:37, Tom Rosmond wrote:
> Hello,
> 
> Your syntax defining 'a' is not correct.  This code works correctly.
> 
> program test
> use mpi
> integer :: ierr, myrank, a(2) = 0
> call MPI_Init(ierr)
> call MPI_Comm_rank(MPI_COMM_WORLD,myrank,ierr)
> if (myrank == 0) then
>  a(1) = 1
>  a(2) = 2
> else
>  a(1) = 3
>  a(2) = 4
> endif
> call
> MPI_Allreduce(MPI_IN_PLACE,a,2,MPI_INTEGER,MPI_SUM,MPI_COMM_WORLD,ierr)
> write(*,*) myrank, a(:)
> call MPI_Finalize(ierr)
> end program test
> 
> mpif90 test.f90
> mpirun -np 2 a.out      
>      0           4           6
>      1           4           6
> 
> T. Rosmond
> 
> 
> 
> 
> 
> On Fri, 2013-09-06 at 21:27 -0400, Hugo Gagnon wrote:
> > Hello,
> > 
> > I'm trying to run this bit of code:
> > 
> > program test
> > use mpi
> > integer :: ierr, myrank, a(2) = 0
> > call MPI_Init(ierr)
> > call MPI_Comm_rank(MPI_COMM_WORLD,myrank,ierr)
> > if (myrank == 0) a(1) = 1; a(2) = 2
> > if (myrank == 1) a(1) = 3; a(2) = 4
> > call
> > MPI_Allreduce(MPI_IN_PLACE,a,2,MPI_INTEGER,MPI_SUM,MPI_COMM_WORLD,ierr)
> > write(*,*) myrank, a(:)
> > call MPI_Finalize(ierr)
> > end program test
> > 
> > but the output is not what I'd expect:
> > 
> > $ openmpif90 test.f90
> > $ openmpirun -np 2 a.out
> >            0           0           0
> >            1           0           0
> > 
> > I tried a version without MPI_IN_PLACE and the call to MPI_Allreduce
> > works fine in that case.  Am I doing something wrong with MPI_IN_PLACE? 
> > I'm using OpenMPI 1.6.5 compiled with gcc 4.8.1 on Mac OS 10.8.
> > 
> > Thanks,
> 
> 
> _______________________________________________
> users mailing list
> users_at_[hidden]
> http://www.open-mpi.org/mailman/listinfo.cgi/users