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

Jack Chessa jfchessa at utep.edu
Fri Jun 24 13:25:57 MDT 2011


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






More information about the Trilinos-Users mailing list