Tpetra parallel linear algebra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Tpetra_Details_isInterComm.cpp
1 // @HEADER
2 // *****************************************************************************
3 // Tpetra: Templated Linear Algebra Services Package
4 //
5 // Copyright 2008 NTESS and the Tpetra contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
11 #include "Teuchos_Comm.hpp"
12 #ifdef HAVE_TPETRACORE_MPI
14 #endif // HAVE_TPETRACORE_MPI
15 #include <stdexcept> // std::logic_error
16 
17 namespace Tpetra {
18 namespace Details {
19 
20 #ifdef HAVE_TPETRACORE_MPI
21 bool isInterComm(const Teuchos::Comm<int>& comm) {
22  MPI_Comm rawMpiComm = extractMpiCommFromTeuchos(comm);
23  int flag = 0;
24  // This is a "local routine" (MPI 3.1, Section 6.6.1, p. 259).
25  (void)MPI_Comm_test_inter(rawMpiComm, &flag);
26  return flag != 0;
27 }
28 
29 #else // NOT HAVE_TPETRACORE_MPI
30 
31 bool isInterComm(const Teuchos::Comm<int>& /* comm */) {
32  return false;
33 }
34 #endif // HAVE_TPETRACORE_MPI
35 
36 } // namespace Details
37 } // namespace Tpetra
Declaration of Tpetra::Details::extractMpiCommFromTeuchos.
bool isInterComm(const Teuchos::Comm< int > &)
Return true if and only if the input communicator wraps an MPI intercommunicator. ...
Declaration of Tpetra::Details::isInterComm.