Tpetra Matrix/Vector Services  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups 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 <Teuchos_DefaultSerialComm.hpp>
46 #include <Teuchos_Describable.hpp>
47 #include <Tpetra_ConfigDefs.hpp>
48 #include <Kokkos_DefaultNode.hpp>
49 
50 namespace Tpetra {
51 
73  template <class Node>
74  class SerialPlatform : public Teuchos::Describable {
75  public:
77 
78 
80  typedef Node NodeType;
81 
83 
85 
90  explicit SerialPlatform (const RCP<Node> &node) :
91  comm_ (rcp (new Teuchos::SerialComm<int>())),
92  node_ (node.is_null () ? Kokkos::Details::getNode<Node> () : node)
93  {}
94 
96  virtual ~SerialPlatform() {}
97 
99 
101 
103  RCP<const Comm<int> > getComm() const {
104  return comm_;
105  }
106 
108  RCP<Node> getNode() const {
109  return node_;
110  }
111 
113  protected:
115  RCP<const Teuchos::SerialComm<int> > comm_;
117  RCP<Node> node_;
118 
119  private:
121  SerialPlatform (const SerialPlatform<Node> &platform);
123  SerialPlatform& operator= (const SerialPlatform<Node> &platform);
124  };
125 
142  template <>
143  class SerialPlatform<Kokkos::DefaultNode::DefaultNodeType> :
144  public Teuchos::Describable {
145  public:
147 
148 
150  typedef Kokkos::DefaultNode::DefaultNodeType NodeType;
151 
153 
155 
162  comm_ (rcp (new Teuchos::SerialComm<int> ())),
163  node_ (Kokkos::DefaultNode::getDefaultNode ())
164  {}
165 
179  explicit SerialPlatform (const RCP<Kokkos::DefaultNode::DefaultNodeType> &node) :
180  comm_ (rcp (new Teuchos::SerialComm<int> ())),
181  node_ (node.is_null() ? Kokkos::DefaultNode::getDefaultNode() : node)
182  {}
183 
185  virtual ~SerialPlatform() {}
186 
188 
190 
192  RCP<const Teuchos::Comm<int> > getComm() const {
193  return comm_;
194  }
195 
197  RCP<Kokkos::DefaultNode::DefaultNodeType> getNode() const {
198  return node_;
199  }
200 
202  private:
205 
208 
209  protected:
211  RCP<const Teuchos::SerialComm<int> > comm_;
212 
214  RCP<Kokkos::DefaultNode::DefaultNodeType> node_;
215  };
216 
217 } // namespace Tpetra
218 
219 #endif // TPETRA_SERIALPLATFORM_HPP
RCP< const Comm< int > > getComm() const
The Teuchos::Comm instance with which this object was created.
RCP< Kokkos::DefaultNode::DefaultNodeType > node_
Node object instantiated for the platform.
Implementation of the Platform concept for non-MPI platforms.
SerialPlatform(const RCP< Node > &node)
RCP< const Teuchos::Comm< int > > getComm() const
The Teuchos::Comm instance with which this object was created.
Kokkos::DefaultNode::DefaultNodeType NodeType
Kokkos Node type; the template parameter of this class.
virtual ~SerialPlatform()
Destructor (virtual for memory safety of derived classes).
SerialPlatform specialization for Kokkos::DefaultNode::DefaultNodeType.
SerialPlatform(const RCP< Kokkos::DefaultNode::DefaultNodeType > &node)
Constructor that accepts a Kokkos Node.
RCP< const Teuchos::SerialComm< int > > comm_
Teuchos::Comm object instantiated for the platform.
RCP< Kokkos::DefaultNode::DefaultNodeType > getNode() const
The Kokkos Node instance for this platform to use.
Node NodeType
Kokkos Node type; the template parameter of this class.
SerialPlatform()
Default constructor: uses Kokkos default node.
RCP< Node > node_
Kokkos Node object instantiated for the platform.
virtual ~SerialPlatform()
Destructor (virtual for memory safety of derived classes).
RCP< Node > getNode() const
The Kokkos Node instance with which this object was created.
RCP< const Teuchos::SerialComm< int > > comm_
Teuchos::Comm object instantiated for the platform.