12 #if defined(HAVE_TPETRACORE_MPI)
13 # include "Teuchos_DefaultMpiComm.hpp"
15 # include "Teuchos_Comm.hpp"
16 #endif // defined(HAVE_TPETRACORE_MPI)
21 #if defined(HAVE_TPETRACORE_MPI)
24 (void) MPI_Initialized (&isInitialized);
30 return isInitialized != 0;
33 #endif // defined(HAVE_TPETRACORE_MPI)
38 #if defined(HAVE_TPETRACORE_MPI)
41 (void) MPI_Finalized (&isFinalized);
47 return isFinalized != 0;
50 #endif // defined(HAVE_TPETRACORE_MPI)
53 #if defined(HAVE_TPETRACORE_MPI)
54 bool isMpiComm (
const Teuchos::Comm<int>& comm)
56 using mpi_comm_type = Teuchos::MpiComm<int>;
57 return dynamic_cast<const mpi_comm_type*
> (&comm) !=
nullptr;
60 bool isMpiComm (
const Teuchos::Comm<int>& )
64 #endif // defined(HAVE_TPETRACORE_MPI)
66 int getRankHarmlessly (
const Teuchos::Comm<int>& comm)
68 if (mpiIsInitialized () && ! mpiIsFinalized () && isMpiComm (comm)) {
69 return comm.getRank ();
82 const Teuchos::Comm<int>* comm)
84 if (comm ==
nullptr || getRankHarmlessly (*comm) == 0) {
bool isInitialized()
Whether Tpetra is in an initialized state.
void printOnce(std::ostream &out, const std::string &s, const Teuchos::Comm< int > *comm)
Print on one process of the given communicator, or at least try to do so (if MPI is not initialized)...
Declaration of Tpetra::Details::printOnce.
bool mpiIsFinalized()
Has MPI_Finalize been called (on this process)?
bool mpiIsInitialized()
Has MPI_Init been called (on this process)?