66 const Teuchos::Comm<int>& comm2)
71 using Teuchos::rcpFromRef;
72 using Teuchos::MpiComm;
73 using Teuchos::rcp_dynamic_cast;
75 RCP<const MpiComm<int> > mpiComm1 =
76 rcp_dynamic_cast<
const MpiComm<int> > (rcpFromRef (comm1));
77 RCP<const MpiComm<int> > mpiComm2 =
78 rcp_dynamic_cast<
const MpiComm<int> > (rcpFromRef (comm2));
80 if (mpiComm1.is_null ()) {
81 return comm1.getSize () == comm2.getSize ();
83 if (mpiComm2.is_null ()) {
84 return comm1.getSize () == comm2.getSize ();
86 MPI_Comm rawMpiComm1 = * (mpiComm1->getRawMpiComm ());
87 MPI_Comm rawMpiComm2 = * (mpiComm2->getRawMpiComm ());
89 int result = MPI_UNEQUAL;
90 const int err = MPI_Comm_compare (rawMpiComm1, rawMpiComm2, &result);
91 TEUCHOS_TEST_FOR_EXCEPTION(err != MPI_SUCCESS, std::runtime_error,
92 "congruent: MPI_Comm_compare failed");
93 return result == MPI_IDENT || result == MPI_CONGRUENT;
97 return comm1.getSize () == comm2.getSize ();
bool congruent(const Teuchos::Comm< int > &comm1, const Teuchos::Comm< int > &comm2)
Whether the two communicators are congruent.
Stand-alone utility functions and macros.