Zoltan2
Loading...
Searching...
No Matches
Zoltan2_TpetraCrsGraphAdapter.hpp
Go to the documentation of this file.
1// @HEADER
2// *****************************************************************************
3// Zoltan2: A package of combinatorial algorithms for scientific computing
4//
5// Copyright 2012 NTESS and the Zoltan2 contributors.
6// SPDX-License-Identifier: BSD-3-Clause
7// *****************************************************************************
8// @HEADER
9
14#ifndef _ZOLTAN2_TPETRACRSGRAPHADAPTER_HPP_
15#define _ZOLTAN2_TPETRACRSGRAPHADAPTER_HPP_
16
21#include <string>
22
23namespace Zoltan2 {
24
32template <typename User, typename UserCoord = User>
33class TpetraCrsGraphAdapter : public TpetraRowGraphAdapter<User, UserCoord> {
34
35public:
36#ifndef DOXYGEN_SHOULD_SKIP_THIS
39 using lno_t = typename InputTraits<User>::lno_t;
40 using gno_t = typename InputTraits<User>::gno_t;
41 using part_t = typename InputTraits<User>::part_t;
42 using node_t = typename InputTraits<User>::node_t;
43 using user_t = User;
44 using userCoord_t = UserCoord;
45
48#endif
49
59 TpetraCrsGraphAdapter(const RCP<const User> &graph, int nVtxWeights = 0,
60 int nEdgeWeights = 0);
61
64 RCP<const User> getUserGraph() const { return this->graph_; }
65
66 template <typename Adapter>
68 const User &in, User *&out,
69 const PartitioningSolution<Adapter> &solution) const;
70
71 template <typename Adapter>
73 const User &in, RCP<User> &out,
74 const PartitioningSolution<Adapter> &solution) const;
75};
76
78// Definitions
80
81template <typename User, typename UserCoord>
83 const RCP<const User> &graph, int nVtxWgts, int nEdgeWgts)
84 : TpetraRowGraphAdapter<User>(nVtxWgts, nEdgeWgts, graph) {
85 auto adjIdsHost = graph->getLocalIndicesHost();
86
87 auto adjIdsGlobalHost =
88 typename Base::IdsHostView("adjIdsGlobalHost", adjIdsHost.extent(0));
89 auto colMap = graph->getColMap();
90
91 // Convert to global IDs using Tpetra::Map
92 Kokkos::parallel_for("adjIdsGlobalHost",
93 Kokkos::RangePolicy<Kokkos::HostSpace::execution_space>(
94 0, adjIdsGlobalHost.extent(0)),
95 [=](const int i) {
96 adjIdsGlobalHost(i) =
97 colMap->getGlobalElement(adjIdsHost(i));
98 });
99
100 auto adjIdsDevice = Kokkos::create_mirror_view_and_copy(
101 typename Base::device_t(), adjIdsGlobalHost);
102
103 this->adjIdsDevice_ = adjIdsDevice;
104 this->offsDevice_ = graph->getLocalRowPtrsDevice();
105
106 if (this->nWeightsPerVertex_ > 0) {
107
108 this->vertexWeightsDevice_ = typename Base::WeightsDeviceView(
109 "vertexWeightsDevice_", graph->getLocalNumRows(),
110 this->nWeightsPerVertex_);
111
112 this->vertexDegreeWeightsHost_ = typename Base::VtxDegreeHostView(
113 "vertexDegreeWeightsHost_", this->nWeightsPerVertex_);
114
115 for (int i = 0; i < this->nWeightsPerVertex_; ++i) {
116 this->vertexDegreeWeightsHost_(i) = false;
117 }
118 }
119
120 if (this->nWeightsPerEdge_) {
121 this->edgeWeightsDevice_ = typename Base::WeightsDeviceView(
122 "nWeightsPerEdge_", graph->getLocalNumRows(), this->nWeightsPerEdge_);
123 }
124}
125
127template <typename User, typename UserCoord>
128template <typename Adapter>
135
137template <typename User, typename UserCoord>
138template <typename Adapter>
145
146} // namespace Zoltan2
147
148#endif
Helper functions for Partitioning Problems.
This file defines the StridedData class.
Defines TpetraRowGraphAdapter class.
Traits of Xpetra classes, including migration method.
typename InputTraits< User >::node_t node_t
typename InputTraits< User >::lno_t lno_t
typename InputTraits< User >::scalar_t scalar_t
typename InputTraits< User >::gno_t gno_t
typename InputTraits< User >::offset_t offset_t
typename InputTraits< User >::part_t part_t
GraphAdapter defines the interface for graph-based user data.
A PartitioningSolution is a solution to a partitioning problem.
Provides access for Zoltan2 to Tpetra::CrsGraph data.
RCP< const User > getUserGraph() const
Access to user's graph.
TpetraCrsGraphAdapter(const RCP< const User > &graph, int nVtxWeights=0, int nEdgeWeights=0)
Constructor for graph with no weights or coordinates.
void applyPartitioningSolution(const User &in, User *&out, const PartitioningSolution< Adapter > &solution) const
Provides access for Zoltan2 to Tpetra::RowGraph data.
void applyPartitioningSolution(const User &in, User *&out, const PartitioningSolution< Adapter > &solution) const
Created by mbenlioglu on Aug 31, 2020.
default_offset_t offset_t
The data type to represent offsets.
default_gno_t gno_t
The ordinal type (e.g., int, long, int64_t) that can represent global counts and identifiers.
default_node_t node_t
The Kokkos node type. This is only meaningful for users of Tpetra objects.
default_lno_t lno_t
The ordinal type (e.g., int, long, int64_t) that represents local counts and local indices.
default_part_t part_t
The data type to represent part numbers.
default_scalar_t scalar_t
The data type for weights and coordinates.