Xpetra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Xpetra_MpiPlatform.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Xpetra: A linear algebra interface package
4 //
5 // Copyright 2012 NTESS and the Xpetra contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef XPETRA_MPIPLATFORM_HPP
11 #define XPETRA_MPIPLATFORM_HPP
12 
13 #include <Teuchos_DefaultMpiComm.hpp>
14 #include <Teuchos_Describable.hpp>
15 #include <Tpetra_KokkosCompat_DefaultNode.hpp>
16 
17 #include "Xpetra_ConfigDefs.hpp"
18 
19 namespace Xpetra {
20 
22 
27 template <class Node = Tpetra::KokkosClassic::DefaultNode::DefaultNodeType>
28 class MpiPlatform : public Teuchos::Describable {
29  public:
31  typedef Node NodeType;
33 
34 
36  explicit MpiPlatform(Teuchos::RCP<Node> node);
37 
39  MpiPlatform(Teuchos::RCP<Node> node, const Teuchos::RCP<const Teuchos::OpaqueWrapper<MPI_Comm> > &rawMpiComm);
40 
42  ~MpiPlatform();
43 
45 
47 
48 
50  Teuchos::RCP<const Teuchos::Comm<int> > getComm() const;
51 
53 
54  private:
55  Teuchos::RCP<Teuchos::MpiComm<int> > comm_;
56  MpiPlatform(const MpiPlatform<Node> &platform);
57 };
58 
59 template <class Node>
60 MpiPlatform<Node>::MpiPlatform(Teuchos::RCP<Node> /* node */, const Teuchos::RCP<const Teuchos::OpaqueWrapper<MPI_Comm> > &rawMpiComm)
61  : comm_(Teuchos::createMpiComm<int>(rawMpiComm)) {}
62 
63 template <class Node>
64 MpiPlatform<Node>::MpiPlatform(Teuchos::RCP<Node> /* node */)
65  : comm_(Teuchos::createMpiComm<int>(Teuchos::opaqueWrapper<MPI_Comm>(MPI_COMM_WORLD))) {} // CHECK: ALLOW MPI_COMM_WORLD
66 
67 template <class Node>
69 
70 template <class Node>
72  comm_ = platform.comm_;
73 }
74 
75 template <class Node>
76 Teuchos::RCP<const Teuchos::Comm<int> >
78  return comm_;
79 }
80 
81 } // namespace Xpetra
82 
83 #endif // XPETRA_MPIPLATFORM_HPP
MpiPlatform(Teuchos::RCP< Node > node)
Constructor.
A implementation of the Platform class for MPI-based platforms.
Node NodeType
Typedef indicating the node type over which the platform is templated. This default to the Kokkos def...
Teuchos::RCP< Teuchos::MpiComm< int > > comm_
Teuchos::RCP< const Teuchos::Comm< int > > getComm() const
Comm Instance.