[mpich-discuss] new communicator value differs for myid=0

Rajeev Thakur thakur at mcs.anl.gov
Mon Oct 14 15:02:26 CDT 2013


The communicator is an opaque object. The value of the new communicator variable is not useful. It is a local variable and can be different on each process. As long as the new communicator behaves the way it should, the program is ok.

Rajeev


On Oct 14, 2013, at 2:50 PM, Shan-ho Tsai wrote:

> 
> Hello,
> I am using MPICH2 3.0.2 with gfortran 4.4.7 on a 64-bit
> Linux machine. The program uses MPI_Comm_split to
> create a new communicator. All processes print the same
> value for MPI_COMM_WORLD, but for the new communicator,
> all processes with myid greater than zero print the same value,
> but myid=0 prints a different value. Why is that? I thought
> all processes should print the same number as well. 
> 
> Simple test code:
> ===================================================
> PROGRAM Test
>  IMPLICIT NONE
>  include "mpif.h"
>  INTEGER :: nBins=8, nWalkers=8
>  INTEGER :: ierr,numprocs,myid,energy_comm
>  INTEGER :: energy_id,numranks,iBin,iWalker
>  INTEGER :: mpistatus(MPI_STATUS_SIZE)
> 
>  CALL MPI_INIT(ierr)
>  CALL MPI_COMM_SIZE(MPI_COMM_WORLD,numprocs,ierr)
>  CALL MPI_COMM_RANK(MPI_COMM_WORLD,myid,ierr)
> 
>  iBin = myid/nWalkers
>  iWalker = MOD(myid,nWalkers)
>  CALL MPI_Comm_split(MPI_COMM_WORLD,iBin,iWalker,energy_comm,ierr)
>  CALL MPI_COMM_SIZE(energy_comm,numranks,ierr)
>  CALL MPI_COMM_RANK(energy_comm,energy_id,ierr)
> 
>  write(*,*)myid,MPI_COMM_WORLD,energy_comm
> 
>  CALL MPI_FINALIZE(ierr)
> 
> END PROGRAM Test
> =========================================================
> 
> Compile with
> 
> mpif90 test.f90
> 
> Run with
> 
> mpirun -n 4 -f host.txt ./a.out
> 
> Generates
>           0  1140850688 -2080374780
>           2  1140850688 -2080374782
>           1  1140850688 -2080374782
>           3  1140850688 -2080374782
> 
> "mpif90 -v" returns:
> 
> mpif90 for MPICH version 3.0.2
> Using built-in specs.
> Target: x86_64-redhat-linux6E
> Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --disable-gnu-unique-object --with-as=/usr/libexec/binutils220/as --enable-languages=c,c++,fortran --disable-libgcj --with-mpfr=/builddir/build/BUILD/gcc-4.4.7-20120601/obj-x86_64-redhat-linux6E/mpfr-install/ --with-ppl=/builddir/build/BUILD/gcc-4.4.7-20120601/obj-x86_64-redhat-linux6E/ppl-install --with-cloog=/builddir/build/BUILD/gcc-4.4.7-20120601/obj-x86_64-redhat-linux6E/cloog-install --with-tune=generic --with-arch_32=i586 --build=x86_64-redhat-linux6E
> Thread model: posix
> gcc version 4.4.7 20120313 (Red Hat 4.4.7-1) (GCC)
> 
> I get the same output for MPICH2 1.4.1p1.
> Any ideas what is happening? Or shouldn't the new communicator also
> have the same value for all myids?
> 
> Thank you very much for any suggestions.
> Shan-Ho
> 
> ----------------------------------------------------
> Shan-Ho Tsai
> University of Georgia
> 
> 
> 
> _______________________________________________
> discuss mailing list     discuss at mpich.org
> To manage subscription options or unsubscribe:
> https://lists.mpich.org/mailman/listinfo/discuss




More information about the discuss mailing list