Tpetra parallel linear algebra
Version of the Day
Toggle main menu visibility
Loading...
Searching...
No Matches
core
src
Tpetra_Details_extractMpiCommFromTeuchos.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
10
#include "
Tpetra_Details_extractMpiCommFromTeuchos.hpp
"
11
12
#ifdef HAVE_TPETRACORE_MPI
13
#include "Teuchos_DefaultMpiComm.hpp"
14
#include "Teuchos_DefaultSerialComm.hpp"
15
#include <stdexcept>
16
#endif
// HAVE_TPETRACORE_MPI
17
18
namespace
Tpetra
{
19
namespace
Details
{
20
21
#ifdef HAVE_TPETRACORE_MPI
22
MPI_Comm
23
extractMpiCommFromTeuchos(
const
Teuchos::Comm<int>& comm) {
24
using
::Teuchos::MpiComm;
25
using
::Teuchos::SerialComm;
26
27
const
MpiComm<int>* mpiComm =
dynamic_cast<
const
MpiComm<int>*
>
(&comm);
28
if
(mpiComm != NULL) {
// It's an MpiComm; extract the MPI_Comm
29
MPI_Comm rawComm = *(mpiComm->getRawMpiComm());
30
return
rawComm;
31
}
else
{
32
const
SerialComm<int>* serialComm =
33
dynamic_cast<
const
SerialComm<int>*
>
(&comm);
34
if
(serialComm != NULL) {
35
return
MPI_COMM_SELF;
// single-process comm including this process
36
}
else
{
37
throw
std::invalid_argument(
38
"Tpetra::Details::extractMpiCommFromTeuchos: "
39
"Input Teuchos::Comm is "
40
"neither a Teuchos::MpiComm, "
41
"nor a Teuchos::SerialComm. "
42
"As a result, I don't know "
43
"how to get the MPI_Comm out of it."
);
44
}
45
}
46
}
47
#endif
// HAVE_TPETRACORE_MPI
48
49
#ifdef HAVE_TPETRACORE_MPI
50
bool
teuchosCommIsAnMpiComm
(
const
Teuchos::Comm<int>& comm) {
51
const
Teuchos::MpiComm<int>* mpiComm =
52
dynamic_cast<
const
Teuchos::MpiComm<int>*
>
(&comm);
53
return
mpiComm !=
nullptr
;
54
}
55
#else
56
bool
teuchosCommIsAnMpiComm
(
const
Teuchos::Comm<int>&) {
57
return
false
;
58
}
59
#endif
// HAVE_TPETRACORE_MPI
60
61
}
// namespace Details
62
}
// namespace Tpetra
Tpetra_Details_extractMpiCommFromTeuchos.hpp
Declaration of Tpetra::Details::extractMpiCommFromTeuchos.
Tpetra::Details
Nonmember function that computes a residual Computes R = B - A * X.
Definition
Tpetra_KokkosRefactor_Details_MultiVectorLocalDeepCopy.hpp:17
Tpetra::Details::teuchosCommIsAnMpiComm
bool teuchosCommIsAnMpiComm(const Teuchos::Comm< int > &)
Is the given Comm a Teuchos::MpiComm<int> instance?
Definition
Tpetra_Details_extractMpiCommFromTeuchos.cpp:56
Tpetra
Namespace Tpetra contains the class and methods constituting the Tpetra library.
Generated by
1.17.0