PlayaGlobalAnd.cpp

00001 /* @HEADER@ */
00002 //   
00003 /* @HEADER@ */
00004 
00005 
00006 #include "PlayaGlobalAnd.hpp"
00007 #include "PlayaMPIComm.hpp"
00008 #include "Teuchos_Assert.hpp"
00009 #include "PlayaOut.hpp"
00010 #ifdef HAVE_MPI
00011 #include "mpi.h"
00012 #endif
00013 
00014 
00015 namespace Playa
00016 {
00017 bool globalAnd(bool localVal)
00018 {
00019   int out = localVal;
00020 
00021   
00022 #ifdef HAVE_MPI
00023   int in = localVal;
00024   int ierr = ::MPI_Allreduce((void*) &in, (void*) &out, 1, MPI_INT,
00025     MPI_LAND, MPI_COMM_WORLD);
00026   TEUCHOS_TEST_FOR_EXCEPTION(ierr != 0, std::runtime_error,
00027     "MPI_Allreduce returned error code=" << ierr);
00028 #endif
00029 
00030   return out;
00031 }
00032 }

doxygen