Isorropia: Partitioning, Load Balancing and more
Isorropia_TpetraPartitioner.hpp
Go to the documentation of this file.
1 //@HEADER
2 //************************************************************************
3 //
4 // Isorropia: Partitioning and Load Balancing Package
5 // Copyright (2006) Sandia Corporation
6 //
7 //Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 //license for use of this work by or on behalf of the U.S. Government.
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 //************************************************************************
38 //@HEADER
39 
40 #ifndef _Isorropia_TpetraPartitioner_hpp_
41 #define _Isorropia_TpetraPartitioner_hpp_
42 
43 
51 #include <Isorropia_ConfigDefs.hpp>
52 #include <Teuchos_RCP.hpp>
53 #include <Teuchos_ParameterList.hpp>
54 
55 
56 
57 #ifdef HAVE_ISORROPIA_TPETRA
61 
62 
63 #include <Kokkos_DefaultNode.hpp>
64 #include <Tpetra_CrsGraph_decl.hpp>
65 #include <Tpetra_RowMatrix.hpp>
66 #include <Tpetra_MultiVector_decl.hpp>
67 
68 namespace Isorropia {
69 
70 namespace Tpetra {
71 
72 
73 
74 
75 template <class Node = ::Tpetra::Map<int, int>::node_type>
76 class Partitioner : public Isorropia::Partitioner, public Isorropia::Tpetra::Operator<Node> {
77 public:
78 
79 
80  Partitioner(Teuchos::RCP<const ::Tpetra::CrsGraph<int,int,Node> > inputGraph,
81  const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),
82  bool compute_partitioning_now=true);
83 
84  Partitioner(const ::Tpetra::CrsGraph<int,int,Node> *inputGraph,
85  const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),
86  bool compute_partitioning_now=true);
87 
88  Partitioner(Teuchos::RCP<const ::Tpetra::CrsGraph<int,int,Node> > inputGraph,
89  Teuchos::RCP<CostDescriber<Node> > costs,
90  const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),
91  bool compute_partitioning_now=true);
92 
93  Partitioner(const ::Tpetra::CrsGraph<int,int,Node> *inputGraph,
94  CostDescriber<Node> * costs,
95  const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),
96  bool compute_partitioning_now=true);
97 
98  Partitioner(Teuchos::RCP<const ::Tpetra::RowMatrix<double,int,int,Node> > inputMatrix,
99  const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),
100  bool compute_partitioning_now=true);
101 
102  Partitioner(const ::Tpetra::RowMatrix<double,int,int,Node> *inputMatrix,
103  const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),
104  bool compute_partitioning_now=true);
105 
106  Partitioner(Teuchos::RCP<const ::Tpetra::RowMatrix<double,int,int,Node> > inputMatrix,
107  Teuchos::RCP<CostDescriber<Node> > costs,
108  const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),
109  bool compute_partitioning_now=true);
110 
111  Partitioner(const ::Tpetra::RowMatrix<double,int,int,Node> *inputMatrix,
112  CostDescriber<Node> *costs,
113  const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),
114  bool compute_partitioning_now=true);
115 
116  Partitioner(Teuchos::RCP<const ::Tpetra::MultiVector<double,int,int,Node> > coords,
117  const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),
118  bool compute_partitioning_now=true);
119 
120  Partitioner(const ::Tpetra::MultiVector<double,int,int,Node> *coords,
121  const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),
122  bool compute_partitioning_now=true);
123 
124  Partitioner(Teuchos::RCP<const ::Tpetra::MultiVector<double,int,int,Node> > coords,
125  Teuchos::RCP<const ::Tpetra::MultiVector<double,int,int,Node> > weights,
126  const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),
127  bool compute_partitioning_now=true);
128 
129  Partitioner(const ::Tpetra::MultiVector<double,int,int,Node> *coords,
130  const ::Tpetra::MultiVector<double,int,int,Node> *weights,
131  const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),
132  bool compute_partitioning_now=true);
133 
134  Partitioner(Teuchos::RCP<const ::Tpetra::Map<int,int,Node> > inputMap,
135  const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),
136  bool compute_partitioning_now=true);
137 
138  Partitioner(const ::Tpetra::Map<int,int,Node> *inputMap,
139  const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),
140  bool compute_partitioning_now=true);
141 
142 
143  // MMW: currently not supporting hiearchical partitioning
144 
145 
146 
147 
148 
149  virtual ~Partitioner();
150 
151  /* @ingroup partitioning_grp
152  * Set the relative number of objects in each part. The default is to
153  * evenly divide objects across parts. The numbers can be fractions of
154  * one, or whole numbers. Zoltan adds the values supplied and takes the sizes
155  * as proportional to that whole.
156  *
157  * We make a copy of id and size lists.
158  *
159  * Caller should supply either global part IDs or local part IDs.
160  * Part IDs are integers beginning at zero for the first part.
161  *
162  * No communication is done during this call. One process can make the call
163  * for all parts, or many processes can make the call. Zoltan checks the
164  * consistency of the information provided.
165  */
166 
167  void setPartSizes(int len, int *global_part_id, float *part_size);
168 
169  /* @ingroup partitioning_grp
170  * Free the memory allocated to store part sizes.
171  */
172  void clearPartSizes();
173 
186  void partition(bool force_repartitioning=false);
187 
190  virtual void compute(bool forceRecomputing=false);
191 
194  int numElemsInPart(int part) const {
195  return (numElemsWithProperty(part));
196  }
197 
200  void elemsInPart(int part, int* elementList, int len) const {
201  elemsWithProperty(part, elementList, len);
202  }
203 
215  Teuchos::RCP< ::Tpetra::Map<int,int,Node> > createNewMap();
216 
228  void createNewMap(::Tpetra::Map<int,int,Node> *&outputMap);
229 
230 private:
231  int *partGIDs;
232  float *partSizes;
233  int numPartSizes;
234 
235 };//class Partitioner
236 
237 }//namespace Tpetra
238 }//namespace Isorropia
239 
240 #endif //HAVE_ISORROPIA_TPETRA
241 
242 #endif
243 
Isorropia is the namespace that contains general definitions that apply to all partitioners and that ...
Definition: Isorropia_Epetra.hpp:60
Interface (abstract base class) for computing a new partitioning and describing the layout of element...
Definition: Isorropia_Partitioner.hpp:59