Tpetra parallel linear algebra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Tpetra_SerialPlatform.hpp
1 // @HEADER
2 // ***********************************************************************
3 //
4 // Tpetra: Templated Linear Algebra Services Package
5 // Copyright (2008) Sandia Corporation
6 //
7 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
8 // the U.S. Government retains certain rights in this software.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
38 //
39 // ************************************************************************
40 // @HEADER
41 
42 #ifndef TPETRA_SERIALPLATFORM_HPP
43 #define TPETRA_SERIALPLATFORM_HPP
44 
45 #include <Tpetra_ConfigDefs.hpp>
46 #include <Tpetra_Core.hpp>
47 #include <Kokkos_DefaultNode.hpp>
48 #include <Teuchos_DefaultSerialComm.hpp>
49 #include <Teuchos_Describable.hpp>
50 
51 namespace Tpetra {
52 
65  template <class Node>
66  class TPETRA_DEPRECATED SerialPlatform : public Teuchos::Describable {
67  public:
69 
70 
72  typedef Node NodeType;
73 
75 
77 
83  explicit SerialPlatform (int* argc, char*** argv) :
84  comm_ (Teuchos::null)
85  {
86  initialize (argc, argv);
87  comm_ = getDefaultComm ();
88  }
89 
95  explicit SerialPlatform (const Teuchos::RCP<NodeType>& /* node */) :
96  comm_ (Teuchos::rcp (new Teuchos::SerialComm<int> ()))
97  {
98  }
99 
110  explicit SerialPlatform (int* argc, char*** argv,
111  const Teuchos::RCP<NodeType>& /* node */) :
112  comm_ (Teuchos::null)
113  {
114  initialize (argc, argv);
115  comm_ = getDefaultComm ();
116  }
117 
119  virtual ~SerialPlatform () {}
120 
122 
124 
126  Teuchos::RCP<const Teuchos::Comm<int> > getComm () const {
127  return comm_;
128  }
129 
134  Teuchos::RCP<Node> getNode () const {
135  return Teuchos::rcp (new Node);
136  }
137 
139  protected:
141  Teuchos::RCP<const Teuchos::Comm<int> > comm_;
142 
143  private:
145  SerialPlatform (const SerialPlatform<NodeType>& platform);
147  SerialPlatform& operator= (const SerialPlatform<NodeType>& platform);
148  };
149 
156  template <>
157  class TPETRA_DEPRECATED SerialPlatform<Tpetra::Details::DefaultTypes::node_type> :
158  public Teuchos::Describable {
159  public:
161 
162 
165 
167 
169 
175  comm_ (Teuchos::rcp (new Teuchos::SerialComm<int> ()))
176  {}
177 
183  explicit SerialPlatform (int* argc, char*** argv) :
184  comm_ (Teuchos::null)
185  {
186  initialize (argc, argv);
187  comm_ = getDefaultComm ();
188  }
189 
202  explicit SerialPlatform (const Teuchos::RCP<NodeType>& /* node */) :
203  comm_ (Teuchos::rcp (new Teuchos::SerialComm<int> ()))
204  {
205  }
206 
217  explicit SerialPlatform (int* argc, char*** argv,
218  const Teuchos::RCP<NodeType>& /* node */) :
219  comm_ (Teuchos::null)
220  {
221  initialize (argc, argv);
222  comm_ = getDefaultComm ();
223  }
224 
226  virtual ~SerialPlatform () {}
227 
229 
231 
233  Teuchos::RCP<const Teuchos::Comm<int> > getComm() const {
234  return comm_;
235  }
236 
242  Teuchos::RCP<Tpetra::Details::DefaultTypes::node_type>
243  getNode () const
244  {
245  return Teuchos::rcp (new Tpetra::Details::DefaultTypes::node_type);
246  }
247 
249  private:
251  SerialPlatform (const SerialPlatform<NodeType>& platform);
252 
254  SerialPlatform& operator= (const SerialPlatform<NodeType>& platform);
255 
256  protected:
258  Teuchos::RCP<const Teuchos::Comm<int> > comm_;
259  };
260 
261 } // namespace Tpetra
262 
263 #endif // TPETRA_SERIALPLATFORM_HPP
void initialize(int *argc, char ***argv)
Initialize Tpetra.
SerialPlatform(int *argc, char ***argv, const Teuchos::RCP< NodeType > &)
Constructor that accepts the same arguments as Tpetra::initialize(), plus a Kokkos Node...
SerialPlatform(const Teuchos::RCP< NodeType > &)
Constructor that accepts a Kokkos Node.
Tpetra::Details::DefaultTypes::node_type NodeType
Kokkos Node type; the template parameter of this class.
Implementation of the Platform concept for non-MPI platforms.
SerialPlatform()
Default constructor: uses Kokkos default node.
Teuchos::RCP< const Teuchos::Comm< int > > getComm() const
The Teuchos::Comm instance with which this object was created.
virtual ~SerialPlatform()
Destructor (virtual for memory safety of derived classes).
Teuchos::RCP< const Teuchos::Comm< int > > getComm() const
The Teuchos::Comm instance with which this object was created.
Node NodeType
Kokkos Node type; the template parameter of this class.
Functions for initializing and finalizing Tpetra.
::Kokkos::Compat::KokkosDeviceWrapperNode< execution_space > node_type
Default value of Node template parameter.
Teuchos::RCP< const Teuchos::Comm< int > > getDefaultComm()
Get Tpetra's default communicator.
SerialPlatform(const Teuchos::RCP< NodeType > &)
Constructor that accepts a Kokkos Node instance.
SerialPlatform(int *argc, char ***argv, const Teuchos::RCP< NodeType > &)
Constructor that accepts the same arguments as Tpetra::initialize(), plus a Kokkos Node...
SerialPlatform(int *argc, char ***argv)
Constructor that accepts the same arguments as Tpetra::initialize().
Teuchos::RCP< Tpetra::Details::DefaultTypes::node_type > getNode() const
The Kokkos Node instance.
Teuchos::RCP< Node > getNode() const
The Kokkos Node instance.
virtual ~SerialPlatform()
Destructor (virtual for memory safety of derived classes).
SerialPlatform(int *argc, char ***argv)
Constructor that accepts the same arguments as Tpetra::initialize().
Teuchos::RCP< const Teuchos::Comm< int > > comm_
Teuchos::Comm object instantiated for the platform.
Teuchos::RCP< const Teuchos::Comm< int > > comm_
Teuchos::Comm object instantiated for the platform.