differents Communicator MPI

Issue #1003 invalid
Davide Baroli created an issue
import dolfin
mesh = dolfin.UnitSquareMesh(10,10)
V = dolfin.FunctionSpace(mesh, dolfin.FiniteElement("Lagrange",mesh.ufl_cell(),1))
u = dolfin.Function(V)
print(V.mesh().mpi_comm() == dolfin.Function(V).vector().mpi_comm())

The last line is expected to be True, but it returns False. About the type , they are both mpi4py.MPI.Intracomm

There is another way to compare MPI communicators ?

Comments (4)

  1. Davide Baroli reporter

    Using mpi4py and check the comparison of communicator, using compare i get the correct results.

    from dolfin import *
    import mpi4py
    mesh = UnitSqureMesh(10,10)
    comm1 = mesh.mpi_comm()
    #Dupplicate the Comm. 
    comm2 = MPI.Dup(comm1)
    #Comparison of comunicator 
    MPI.Comm.Compare(comm1,comm2) == MPI.IDENT # FALSE
    MPI.Comm.Compare(comm1,comm2) == MPI.CONGRUENT # TRUE
    MPI.Group.Compare(comm1.Get_group(),comm2.Get_group()) == MPI.IDENT # True
    

    However, every comparison in c++ in dolfin needs to replace by

    int ierr;
     MPI_Comm_compare(comm1,comm2,&ierr);
    if (ierr > 1) dolfin_error ("communicators are different)" 
    
  2. Davide Baroli reporter

    An idea to fix it:

    • modify MPI.h and MPI.cpp adding the operator==

    • modify python/MPIWrapper.h and cpp ?

    • modify pybind11 part on MPIWrapper.h ?

    • add unit test

    When it occurs: in constructor of branch chris/petsc-matnest

  3. Prof Garth Wells

    This isn't a bug. Objects create copies the communicator so that changes to a communicator in one place don't screw up an object elsewhere that is defined on it.

  4. Davide Baroli reporter

    I agree that the object that is defined is not broken. But the comparison between duplicate communicator by "==" produces wrong result. I could create an operator == in MPI.h and pull request as an improvement?

  5. Log in to comment