Zoltan2
Loading...
Searching...
No Matches
Zoltan2_Algorithm.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_ALGORITHM_HPP_
15#define _ZOLTAN2_ALGORITHM_HPP_
16
17namespace Zoltan2 {
18template <typename Adapter>
19class Algorithm;
20}
21
22#include <Zoltan2_Standards.hpp>
29
30
31namespace Zoltan2 {
32
34//
35// Algorithms do not have to implement all methods in the Algorithm base
36// class. They should implement only those methods that are relevant.
37// For example AlgScotch might implement partition() and order(), while
38// AlgMJ might implement partition() and boxAssign().
39// Default implementations throw a "not implemented" error
40
41template <typename Adapter>
42class Algorithm {
43
44public:
45
46 typedef typename Adapter::lno_t lno_t;
47 typedef typename Adapter::gno_t gno_t;
48 typedef typename Adapter::scalar_t scalar_t;
49 typedef typename Adapter::part_t part_t;
50
51 // Virtual destructor needed to avoid undefined behavior and compiler warnings
52 virtual ~Algorithm() {}
53
55 virtual int localOrder(const RCP<LocalOrderingSolution<lno_t> > &/* solution */)
56 {
58 }
59
61 virtual int globalOrder(const RCP<GlobalOrderingSolution<gno_t> > &/* solution */)
62 {
64 }
65
67 virtual void color(const RCP<ColoringSolution<Adapter> > &/* solution */)
68 {
70 }
71
73 virtual void match() {
75 }
76
78 virtual void partition(const RCP<PartitioningSolution<Adapter> > &/* solution */)
79 {
81 }
82
84 virtual void partitionMatrix(const RCP<MatrixPartitioningSolution<Adapter> > &/* solution */)
85 {
87 }
88
90 virtual void map(const RCP<MappingSolution<Adapter> > &/* solution */)
91 {
93 }
94
96 virtual bool isPartitioningTreeBinary() const
97 {
99 }
100
102 virtual void getPartitionTree(part_t /* numParts */,
103 part_t & /* numTreeVerts */,
104 std::vector<part_t> & /* permPartNums */,
105 std::vector<part_t> & /* splitRangeBeg */,
106 std::vector<part_t> & /* splitRangeEnd */,
107 std::vector<part_t> & /* treeVertParents */) const
108 {
110 }
111
113 // computed parts
114 // Not all partitioning algorithms will support
115 // this method.
116 //
117 virtual std::vector<coordinateModelPartBox> &
122
124 // when a point lies on a part boundary, the lowest part
125 // number on that boundary is returned.
126 // Not all partitioning algorithms will support
127 // this method.
128 //
129 // \param dim : the number of dimensions specified for the point in space
130 // \param point : the coordinates of the point in space; array of size dim
131 // \return the part number of a part overlapping the given point
132 virtual part_t pointAssign(int /* dim */, scalar_t * /* point */) const
133 {
135 }
136
138 // Return an array of all parts overlapping a given box in space.
139 // This method allocates memory for the return argument, but does not
140 // control that memory. The user is responsible for freeing the
141 // memory.
142 //
143 // \param dim : (in) the number of dimensions specified for the box
144 // \param ptLower : (in) the coordinates of the lower corner of the box;
145 // array of size dim
146 // \param ptUpper : (in) the coordinates of the upper corner of the box;
147 // array of size dim
148 // \param nParts : (out) the number of parts overlapping the box
149 // \param parts : (out) array of parts overlapping the box
150 virtual void boxAssign(int /* dim */, scalar_t * /* lower */, scalar_t * /* upper */,
151 size_t &/* nParts */, part_t ** /* partsFound */) const
152 {
154 }
155
157 // Returned graph is identical on all processors, and represents the
158 // global communication pattern in the partition.
159 //
160 // \param comXAdj: (out) the offset array: offsets into comAdj
161 // Format is standard CSR format:
162 // # nbor parts of part i = comXAdj[i+1]-comXAdj[i]
163 // That is, comXAdj[i] = Sum of # nbor parts of parts
164 // 0 through i-1
165 // \param comAdj (out) the neighboring parts
167 const PartitioningSolution<Adapter> * /* solution */,
168 ArrayRCP<part_t> &/* comXAdj */,
169 ArrayRCP<part_t> &/* comAdj */)
170 // TODO: Should the return args be ArrayViews?
171 {
173 }
174
176 // \param p: (in) the part for which the rank is sought
177 // This method need not be implemented by every algorithm or, indeed,
178 // for every mapping algorithm. Mapping algorithms may provide this
179 // function to prevent additional memory use in MappingSolution.
180 // For example, AlgContiguousMapping can compute this function implicitly,
181 // with no additional storage. However, Mapping algorithms can skip this
182 // function and, instead, register their results in MappingSolution.
183 virtual int getRankForPart(part_t /* p */)
184 {
186 }
187
189 // \param numParts: (out) the number of parts assigned to the current rank
190 // \param parts: (out) a view of the assigned parts
191 //
192 // This method need not be implemented by every algorithm or, indeed,
193 // for every mapping algorithm. Mapping algorithms may provide this
194 // function to prevent additional memory use in MappingSolution.
195 // For example, AlgContiguousMapping can compute this function implicitly,
196 // with no additional storage. However, Mapping algorithms can skip this
197 // function and, instead, register their results in MappingSolution.
198 virtual void getMyPartsView(part_t &/* numParts */, part_t *&/* parts */)
199 {
201 }
202
203
204private:
205};
206
207} //namespace Zoltan2
208
209#endif
Defines the ColoringSolution class.
#define Z2_THROW_NOT_IMPLEMENTED
Defines the MappingSolution class.
Defines the OrderingSolution class.
Defines the PartitioningSolution class.
Gathering definitions used in software development.
Algorithm defines the base class for all algorithms.
virtual int globalOrder(const RCP< GlobalOrderingSolution< gno_t > > &)
Ordering method.
virtual void match()
Matching method.
virtual int localOrder(const RCP< LocalOrderingSolution< lno_t > > &)
Ordering method.
virtual void partition(const RCP< PartitioningSolution< Adapter > > &)
Partitioning method.
virtual void color(const RCP< ColoringSolution< Adapter > > &)
Coloring method.
virtual void map(const RCP< MappingSolution< Adapter > > &)
Mapping method.
virtual bool isPartitioningTreeBinary() const
return if algorithm determins tree to be binary
virtual void getPartitionTree(part_t, part_t &, std::vector< part_t > &, std::vector< part_t > &, std::vector< part_t > &, std::vector< part_t > &) const
for partitioning methods, fill arrays with partition tree info
virtual part_t pointAssign(int, scalar_t *) const
pointAssign method: Available only for some partitioning algorithms
virtual void partitionMatrix(const RCP< MatrixPartitioningSolution< Adapter > > &)
Matrix Partitioning method.
Adapter::scalar_t scalar_t
virtual std::vector< coordinateModelPartBox > & getPartBoxesView() const
for partitioning methods, return bounding boxes of the
virtual int getRankForPart(part_t)
In mapping, returns the rank to which a part is assigned.
virtual void getMyPartsView(part_t &, part_t *&)
In mapping, returns a view of parts assigned to the current rank.
virtual void boxAssign(int, scalar_t *, scalar_t *, size_t &, part_t **) const
boxAssign method: Available only for some partitioning algorithms
virtual void getCommunicationGraph(const PartitioningSolution< Adapter > *, ArrayRCP< part_t > &, ArrayRCP< part_t > &)
returns serial communication graph of a computed partition
The class containing coloring solution.
PartitionMapping maps a solution or an input distribution to ranks.
A PartitioningSolution is a solution to a partitioning problem.
A PartitioningSolution is a solution to a partitioning problem.
Created by mbenlioglu on Aug 31, 2020.