Zoltan2
Toggle main menu visibility
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
13
14
#ifndef _ZOLTAN2_TPETRACRSGRAPHADAPTER_HPP_
15
#define _ZOLTAN2_TPETRACRSGRAPHADAPTER_HPP_
16
17
#include <
Zoltan2_PartitioningHelpers.hpp
>
18
#include <
Zoltan2_StridedData.hpp
>
19
#include <
Zoltan2_TpetraRowGraphAdapter.hpp
>
20
#include <
Zoltan2_XpetraTraits.hpp
>
21
#include <string>
22
23
namespace
Zoltan2
{
24
31
32
template
<
typename
User,
typename
UserCoord = User>
33
class
TpetraCrsGraphAdapter
:
public
TpetraRowGraphAdapter
<User, UserCoord> {
34
35
public
:
36
#ifndef DOXYGEN_SHOULD_SKIP_THIS
37
using
scalar_t
=
typename
InputTraits<User>::scalar_t
;
38
using
offset_t
=
typename
InputTraits<User>::offset_t
;
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
46
using
Base =
GraphAdapter<User, UserCoord>
;
47
using
RowGraph =
TpetraRowGraphAdapter<User, UserCoord>
;
48
#endif
49
58
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>
67
void
applyPartitioningSolution
(
68
const
User &in, User *&out,
69
const
PartitioningSolution<Adapter>
&solution)
const
;
70
71
template
<
typename
Adapter>
72
void
applyPartitioningSolution
(
73
const
User &in, RCP<User> &out,
74
const
PartitioningSolution<Adapter>
&solution)
const
;
75
};
76
78
// Definitions
80
81
template
<
typename
User,
typename
UserCoord>
82
TpetraCrsGraphAdapter<User, UserCoord>::TpetraCrsGraphAdapter
(
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
127
template
<
typename
User,
typename
UserCoord>
128
template
<
typename
Adapter>
129
void
TpetraCrsGraphAdapter<User, UserCoord>::applyPartitioningSolution
(
130
const
User &in, User *&out,
131
const
PartitioningSolution<Adapter>
&solution)
const
{
132
TpetraRowGraphAdapter<User, UserCoord>::applyPartitioningSolution
(in, out,
133
solution);
134
}
135
137
template
<
typename
User,
typename
UserCoord>
138
template
<
typename
Adapter>
139
void
TpetraCrsGraphAdapter<User, UserCoord>::applyPartitioningSolution
(
140
const
User &in, RCP<User> &out,
141
const
PartitioningSolution<Adapter>
&solution)
const
{
142
TpetraRowGraphAdapter<User, UserCoord>::applyPartitioningSolution
(in, out,
143
solution);
144
}
145
146
}
// namespace Zoltan2
147
148
#endif
user_t
Zoltan2::BasicUserTypes< zscalar_t, zlno_t, zgno_t > user_t
Definition
Metric.cpp:39
Zoltan2_PartitioningHelpers.hpp
Helper functions for Partitioning Problems.
Zoltan2_StridedData.hpp
This file defines the StridedData class.
Zoltan2_TpetraRowGraphAdapter.hpp
Defines TpetraRowGraphAdapter class.
Zoltan2_XpetraTraits.hpp
Traits of Xpetra classes, including migration method.
Zoltan2::GraphAdapter
GraphAdapter defines the interface for graph-based user data.
Definition
Zoltan2_GraphAdapter.hpp:59
Zoltan2::PartitioningSolution
A PartitioningSolution is a solution to a partitioning problem.
Definition
Zoltan2_PartitioningSolution.hpp:57
Zoltan2::TpetraCrsGraphAdapter::applyPartitioningSolution
void applyPartitioningSolution(const User &in, RCP< User > &out, const PartitioningSolution< Adapter > &solution) const
Definition
Zoltan2_TpetraCrsGraphAdapter.hpp:139
Zoltan2::TpetraCrsGraphAdapter::getUserGraph
RCP< const User > getUserGraph() const
Access to user's graph.
Definition
Zoltan2_TpetraCrsGraphAdapter.hpp:64
Zoltan2::TpetraCrsGraphAdapter::TpetraCrsGraphAdapter
TpetraCrsGraphAdapter(const RCP< const User > &graph, int nVtxWeights=0, int nEdgeWeights=0)
Constructor for graph with no weights or coordinates.
Definition
Zoltan2_TpetraCrsGraphAdapter.hpp:82
Zoltan2::TpetraCrsGraphAdapter::applyPartitioningSolution
void applyPartitioningSolution(const User &in, User *&out, const PartitioningSolution< Adapter > &solution) const
Definition
Zoltan2_TpetraCrsGraphAdapter.hpp:129
Zoltan2::TpetraRowGraphAdapter< User, User >::nWeightsPerEdge_
int nWeightsPerEdge_
Definition
Zoltan2_TpetraRowGraphAdapter.hpp:301
Zoltan2::TpetraRowGraphAdapter::graph_
RCP< const User > graph_
Definition
Zoltan2_TpetraRowGraphAdapter.hpp:288
Zoltan2::TpetraRowGraphAdapter< User, User >::edgeWeightsDevice_
Base::WeightsDeviceView edgeWeightsDevice_
Definition
Zoltan2_TpetraRowGraphAdapter.hpp:303
Zoltan2::TpetraRowGraphAdapter< User, User >::nWeightsPerVertex_
int nWeightsPerVertex_
Definition
Zoltan2_TpetraRowGraphAdapter.hpp:296
Zoltan2::TpetraRowGraphAdapter< User, User >::offsDevice_
Base::ConstOffsetsDeviceView offsDevice_
Definition
Zoltan2_TpetraRowGraphAdapter.hpp:294
Zoltan2::TpetraRowGraphAdapter< User, User >::vertexWeightsDevice_
Base::WeightsDeviceView vertexWeightsDevice_
Definition
Zoltan2_TpetraRowGraphAdapter.hpp:298
Zoltan2::TpetraRowGraphAdapter::applyPartitioningSolution
void applyPartitioningSolution(const User &in, User *&out, const PartitioningSolution< Adapter > &solution) const
Definition
Zoltan2_TpetraRowGraphAdapter.hpp:728
Zoltan2::TpetraRowGraphAdapter< User, User >::adjIdsDevice_
Base::ConstIdsDeviceView adjIdsDevice_
Definition
Zoltan2_TpetraRowGraphAdapter.hpp:293
Zoltan2::TpetraRowGraphAdapter< User, User >::TpetraRowGraphAdapter
TpetraRowGraphAdapter(const RCP< const User > &ingraph, int nVtxWeights=0, int nEdgeWeights=0)
Definition
Zoltan2_TpetraRowGraphAdapter.hpp:314
Zoltan2::TpetraRowGraphAdapter< User, User >::vertexDegreeWeightsHost_
Base::VtxDegreeHostView vertexDegreeWeightsHost_
Definition
Zoltan2_TpetraRowGraphAdapter.hpp:299
Zoltan2
Created by mbenlioglu on Aug 31, 2020.
Definition
Zoltan2_AlgHybrid2GL.hpp:47
Zoltan2::scalar_t
Zoltan2::InputTraits::offset_t
default_offset_t offset_t
The data type to represent offsets.
Definition
Zoltan2_InputTraits.hpp:155
Zoltan2::InputTraits::gno_t
default_gno_t gno_t
The ordinal type (e.g., int, long, int64_t) that can represent global counts and identifiers.
Definition
Zoltan2_InputTraits.hpp:151
Zoltan2::InputTraits::node_t
default_node_t node_t
The Kokkos node type. This is only meaningful for users of Tpetra objects.
Definition
Zoltan2_InputTraits.hpp:164
Zoltan2::InputTraits::lno_t
default_lno_t lno_t
The ordinal type (e.g., int, long, int64_t) that represents local counts and local indices.
Definition
Zoltan2_InputTraits.hpp:146
Zoltan2::InputTraits::part_t
default_part_t part_t
The data type to represent part numbers.
Definition
Zoltan2_InputTraits.hpp:159
Zoltan2::InputTraits::scalar_t
default_scalar_t scalar_t
The data type for weights and coordinates.
Definition
Zoltan2_InputTraits.hpp:141
core
src
input
Zoltan2_TpetraCrsGraphAdapter.hpp
Generated by
1.17.0