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
22 isInterComm (const Teuchos::Comm<int>& comm)
23 {
24  MPI_Comm rawMpiComm = extractMpiCommFromTeuchos (comm);
25  int flag = 0;
26  // This is a "local routine" (MPI 3.1, Section 6.6.1, p. 259).
27  (void) MPI_Comm_test_inter (rawMpiComm, &flag);
28  return flag != 0;
29 }
30 
31 #else // NOT HAVE_TPETRACORE_MPI
32 
33 bool
34 isInterComm (const Teuchos::Comm<int>& /* comm */ )
35 {
36  return false;
37 }
38 #endif // HAVE_TPETRACORE_MPI
39 
40 } // namespace Details
41 } // namespace Tpetra
42 
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.