[Trilinos-Users] Epetra_MpiComm.Barrier() does not seem to work?

Heroux, Mike MHeroux at csbsju.edu
Sat Jun 25 11:03:39 MDT 2011


Jack,

Generally speaking, output does not respect communication barriers.  There
are functions in Teuchos that serialize output, and might do what you want.
Another approach is to send all output to a single process that is in charge
of output.  However, these approaches are not scalable, so you need to be
careful.

I hope this helps.

Mike


On 6/24/11 2:25 PM, "Jack Chessa" <jfchessa at utep.edu> wrote:

> Hello,  I am having issues (I believe) with the
> Epetra_MpiComm.Barrier() member.  When I execute the following code
> with three processors
> 
> #ifdef HAVE_MPI
> #include "mpi.h"
> #include "Epetra_MpiComm.h"
> #else
> #include "Epetra_SerialComm.h"
> #endif
> 
> 
> int main(int argc, char* argv[])
> {
> 
> #ifdef HAVE_MPI
> MPI_Init(&argc, &argv);
> Epetra_MpiComm MyComm(MPI_COMM_WORLD);
> #else
> Epetra_SerialComm MyComm;
> #endif 
> 
> if ( MyComm.MyPID()==0 )
> std::cout << "\nHi there from processor " << MyComm.MyPID() << endl;
> 
> if ( MyComm.MyPID()==1 )
> std::cout << "\nHi there from processor " << MyComm.MyPID() << endl;
> 
> if ( MyComm.MyPID()==2 )
> std::cout << "\nHi there from processor " << MyComm.MyPID() << endl;
> 
> 
> 
> MyComm.Barrier();
> 
> if ( MyComm.MyPID()==0 )
> std::cout << "\nfrom processor " << MyComm.MyPID() << endl;
> 
> MyComm.Barrier();
> 
> if ( MyComm.MyPID()==1 )
> std::cout << "\nfrom processor " << MyComm.MyPID() << endl;
> 
> MyComm.Barrier();
> 
> if ( MyComm.MyPID()==2 )
> std::cout << "\nfrom processor " << MyComm.MyPID() << endl;
> 
> return 0;
> }
> 
> //------------------
> I tend to get something as follows; that seems to indicate that the
> barrier is being ignored.  Is there some trick I am missing?
> 
> [jfchessa at virgo2 examples]$ mpirun -np 3 barrier_test
> 
> Hi there from processor 1
> 
> Hi there from processor 2
> 
> Hi there from processor 0
> 
> from processor 1
> 
> from processor 2
> 
> from processor 0
> 
> Thanks for any information
> Jack
> 
> 
> Jack Chessa
> Associate Professor
> Mechancial Engineering
> The University of Texas at El Paso
> Voice: (915) 747-6900
> Fax: (915) 747-5019
> Email: jfchessa at utep.edu
> 
> 
> 
> 
> _______________________________________________
> Trilinos-Users mailing list
> Trilinos-Users at software.sandia.gov
> http://software.sandia.gov/mailman/listinfo/trilinos-users
> 





More information about the Trilinos-Users mailing list