MueLu Version of the Day
Loading...
Searching...
No Matches
MueLu_LWGraph_kokkos_decl.hpp
Go to the documentation of this file.
1// @HEADER
2//
3// ***********************************************************************
4//
5// MueLu: A package for multigrid based preconditioning
6// Copyright 2012 Sandia Corporation
7//
8// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
9// the U.S. Government retains certain rights in this software.
10//
11// Redistribution and use in source and binary forms, with or without
12// modification, are permitted provided that the following conditions are
13// met:
14//
15// 1. Redistributions of source code must retain the above copyright
16// notice, this list of conditions and the following disclaimer.
17//
18// 2. Redistributions in binary form must reproduce the above copyright
19// notice, this list of conditions and the following disclaimer in the
20// documentation and/or other materials provided with the distribution.
21//
22// 3. Neither the name of the Corporation nor the names of the
23// contributors may be used to endorse or promote products derived from
24// this software without specific prior written permission.
25//
26// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37//
38// Questions? Contact
39// Jonathan Hu (jhu@sandia.gov)
40// Andrey Prokopenko (aprokop@sandia.gov)
41// Ray Tuminaro (rstumin@sandia.gov)
42//
43// ***********************************************************************
44//
45// @HEADER
46#ifndef MUELU_LWGRAPH_KOKKOS_DECL_HPP
47#define MUELU_LWGRAPH_KOKKOS_DECL_HPP
48
49#include "MueLu_ConfigDefs.hpp"
50
51#include <Kokkos_StaticCrsGraph.hpp>
52#include <KokkosCompat_ClassicNodeAPI_Wrapper.hpp>
53
54#include <Xpetra_ConfigDefs.hpp> // global_size_t
55#include <Xpetra_Map.hpp>
56
60
61#include "MueLu_Exceptions.hpp"
62
63namespace MueLu {
64
72 template<class LocalOrdinal, class GlobalOrdinal, class Node>
74
75 // Partial specialization for DeviceType
76 template<class LocalOrdinal, class GlobalOrdinal, class DeviceType>
77 class LWGraph_kokkos<LocalOrdinal, GlobalOrdinal, Kokkos::Compat::KokkosDeviceWrapperNode<DeviceType>> {
78 public:
81 using execution_space = typename DeviceType::execution_space;
82 using memory_space = typename DeviceType::memory_space;
83 using device_type = Kokkos::Device<execution_space, memory_space>;
84 using node_type = Kokkos::Compat::KokkosDeviceWrapperNode<DeviceType>;
86 using size_type = size_t;
87
88 using map_type = Xpetra::Map<LocalOrdinal, GlobalOrdinal, node_type>;
89 using local_graph_type = typename local_lw_graph_type::local_graph_type;
90 using boundary_nodes_type = typename local_lw_graph_type::boundary_nodes_type;
91
92 private:
93 // For compatibility
94 typedef node_type Node;
95#undef MUELU_LWGRAPH_KOKKOS_SHORT
97
98 public:
99
101
102
104 //
105 // @param[in] graph: local graph of type Kokkos::StaticCrsGraph containing CRS data
106 // @param[in] domainMap: non-overlapping (domain) map for graph. Usually provided by AmalgamationFactory stored in UnAmalgamationInfo container
107 // @param[in] importMap: overlapping map for graph. Usually provided by AmalgamationFactory stored in UnAmalgamationInfo container
108 // @param[in] objectLabel: label string
110 const RCP<const map_type>& domainMap,
111 const RCP<const map_type>& importMap,
112 const std::string& objectLabel = "")
113 : lclLWGraph_(graph, domainMap), domainMap_(domainMap), importMap_(importMap), objectLabel_(objectLabel) { }
114
115 ~LWGraph_kokkos() = default;
117
118 const RCP<const Teuchos::Comm<int> > GetComm() const {
119 return domainMap_->getComm();
120 }
121 const RCP<const Map> GetDomainMap() const {
122 return domainMap_;
123 }
125 const RCP<const Map> GetImportMap() const {
126 return importMap_;
127 }
128
130 KOKKOS_INLINE_FUNCTION size_type GetNodeNumVertices() const {
131 return lclLWGraph_.GetNodeNumVertices();
132 }
134 KOKKOS_INLINE_FUNCTION size_type GetNodeNumEdges() const {
135 return lclLWGraph_.GetNodeNumEdges();
136 }
137
139 KOKKOS_INLINE_FUNCTION size_type getLocalMaxNumRowEntries () const {
140 return lclLWGraph_.getLocalMaxNumRowEntries();
141 }
142
144 std::string description() const {
145 return "LWGraph (" + objectLabel_ + ")";
146 }
147
149 void print(Teuchos::FancyOStream &out, const VerbLevel verbLevel = Default) const;
150
152 return lclLWGraph_;
153 }
154
155 private:
156
159
161 const RCP<const map_type> domainMap_;
162 const RCP<const map_type> importMap_;
163
165 const std::string objectLabel_;
166 };
167
168}
169
170#define MUELU_LWGRAPH_KOKKOS_SHORT
171#endif // MUELU_LWGRAPH_KOKKOS_DECL_HPP
MueLu::DefaultLocalOrdinal LocalOrdinal
MueLu::DefaultGlobalOrdinal GlobalOrdinal
LWGraph_kokkos(const local_graph_type &graph, const RCP< const map_type > &domainMap, const RCP< const map_type > &importMap, const std::string &objectLabel="")
LWGraph constructor.
KOKKOS_INLINE_FUNCTION size_type getLocalMaxNumRowEntries() const
Returns the maximum number of entries across all rows/columns on this node.
Lightweight MueLu representation of a compressed row storage graph.
Namespace for MueLu classes and methods.