Isorropia: Partitioning, Load Balancing and more
Isorropia_EpetraPartitioner.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_EpetraPartitioner_hpp_
41 #define _Isorropia_EpetraPartitioner_hpp_
42 
43 
92 #include <Isorropia_ConfigDefs.hpp>
93 #include <Teuchos_RCP.hpp>
94 #include <Teuchos_ParameterList.hpp>
95 
99 
100 #ifdef HAVE_EPETRA
101 class Epetra_Map;
102 class Epetra_BlockMap;
103 class Epetra_Import;
104 class Epetra_Vector;
105 class Epetra_MultiVector;
106 class Epetra_CrsGraph;
107 class Epetra_CrsMatrix;
108 class Epetra_RowMatrix;
109 class Epetra_LinearProblem;
110 
111 namespace Isorropia {
112 
113 namespace Epetra {
114  class CostDescriber;
115 
123 public:
124 
127  Partitioner(Teuchos::RCP<const Epetra_CrsGraph> inputGraph,
128  const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),
129  bool compute_partitioning_now=true);
130 
134  Partitioner(const Epetra_CrsGraph *inputGraph,
135  const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),
136  bool compute_partitioning_now=true);
137 
141  Partitioner(Teuchos::RCP<const Epetra_CrsGraph> inputGraph,
142  Teuchos::RCP<CostDescriber> costs,
143  const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),
144  bool compute_partitioning_now=true);
145 
149  Partitioner(const Epetra_CrsGraph *inputGraph,
150  CostDescriber* costs,
151  const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),
152  bool compute_partitioning_now=true);
153 
157  Partitioner(Teuchos::RCP<const Epetra_RowMatrix> inputMatrix,
158  const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),
159  bool compute_partitioning_now=true);
160 
164  Partitioner(const Epetra_RowMatrix *inputMatrix,
165  const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),
166  bool compute_partitioning_now=true);
167 
171  Partitioner(Teuchos::RCP<const Epetra_RowMatrix> inputMatrix,
172  Teuchos::RCP<CostDescriber> costs,
173  const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),
174  bool compute_partitioning_now=true);
175 
179  Partitioner(const Epetra_RowMatrix *inputMatrix,
180  CostDescriber *costs,
181  const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),
182  bool compute_partitioning_now=true);
183 
187  Partitioner(Teuchos::RCP<const Epetra_MultiVector> coords,
188  const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),
189  bool compute_partitioning_now=true);
190 
194  Partitioner(const Epetra_MultiVector *coords,
195  const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),
196  bool compute_partitioning_now=true);
197 
201  Partitioner(Teuchos::RCP<const Epetra_MultiVector> coords,
202  Teuchos::RCP<const Epetra_MultiVector> weights,
203  const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),
204  bool compute_partitioning_now=true);
205 
208  Partitioner(const Epetra_MultiVector *coords,
209  const Epetra_MultiVector *weights,
210  const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),
211  bool compute_partitioning_now=true);
212 
215  Partitioner(Teuchos::RCP<const Epetra_BlockMap> inputMap,
216  const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),
217  bool compute_partitioning_now=true);
218 
221  Partitioner(const Epetra_BlockMap *inputMap,
222  const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),
223  bool compute_partitioning_now=true);
224 
227  Partitioner(Teuchos::RCP<const Epetra_CrsGraph> inputGraph,
228  Teuchos::RCP<const Epetra_MultiVector> coords,
229  const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),
230  bool compute_partitioning_now=true);
231 
234  Partitioner(const Epetra_CrsGraph *inputGraph,
235  const Epetra_MultiVector *coords,
236  const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),
237  bool compute_partitioning_now=true);
238 
239 
242  Partitioner(Teuchos::RCP<const Epetra_CrsGraph> inputGraph,
243  Teuchos::RCP<CostDescriber> costs,
244  Teuchos::RCP<const Epetra_MultiVector> coords,
245  Teuchos::RCP<const Epetra_MultiVector> weights,
246  const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),
247  bool compute_partitioning_now=true);
248 
251  Partitioner(const Epetra_CrsGraph *inputGraph,
252  CostDescriber *costs,
253  const Epetra_MultiVector *coords,
254  const Epetra_MultiVector *weights,
255  const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),
256  bool compute_partitioning_now=true);
257 
260  Partitioner(Teuchos::RCP<const Epetra_RowMatrix> inputMatrix,
261  Teuchos::RCP<const Epetra_MultiVector> coords,
262  const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),
263  bool compute_partitioning_now=true);
264 
267  Partitioner(const Epetra_RowMatrix *inputMatrix,
268  const Epetra_MultiVector *coords,
269  const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),
270  bool compute_partitioning_now=true);
271 
274  Partitioner(Teuchos::RCP<const Epetra_RowMatrix> inputMatrix,
275  Teuchos::RCP<CostDescriber> costs,
276  Teuchos::RCP<const Epetra_MultiVector> coords,
277  Teuchos::RCP<const Epetra_MultiVector> weights,
278  const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),
279  bool compute_partitioning_now=true);
280 
283  Partitioner(const Epetra_RowMatrix *inputMatrix,
284  CostDescriber *costs,
285  const Epetra_MultiVector *coords,
286  const Epetra_MultiVector *weights,
287  const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"),
288  bool compute_partitioning_now=true);
289 
290 
294  virtual ~Partitioner();
295 
296  /* @ingroup partitioning_grp
297  * Set the relative number of objects in each part. The default is to
298  * evenly divide objects across parts. The numbers can be fractions of
299  * one, or whole numbers. Zoltan adds the values supplied and takes the sizes
300  * as proportional to that whole.
301  *
302  * We make a copy of id and size lists.
303  *
304  * Caller should supply either global part IDs or local part IDs.
305  * Part IDs are integers beginning at zero for the first part.
306  *
307  * No communication is done during this call. One process can make the call
308  * for all parts, or many processes can make the call. Zoltan checks the
309  * consistency of the information provided.
310  */
311 
312  void setPartSizes(int len, int *global_part_id, float *part_size);
313 
314  /* @ingroup partitioning_grp
315  * Free the memory allocated to store part sizes.
316  */
317  void clearPartSizes();
318 
331  void partition(bool force_repartitioning=false);
332 
335  virtual void compute(bool forceRecomputing=false);
336 
339  int numElemsInPart(int part) const {
340  return (numElemsWithProperty(part));
341  }
342 
345  void elemsInPart(int part, int* elementList, int len) const {
346  elemsWithProperty(part, elementList, len);
347  }
348 
360  Teuchos::RCP<Epetra_Map> createNewMap();
361 
373  void createNewMap(Epetra_Map *&outputMap);
374 
376 
377 private:
378  int *partGIDs;
379  float *partSizes;
382 
383 };//class Partitioner
384 
385 }//namespace Epetra
386 }//namespace Isorropia
387 
388 #endif //HAVE_EPETRA
389 
390 #endif
391 
392 
393 #if defined(Isorropia_SHOW_DEPRECATED_WARNINGS)
394 #ifdef __GNUC__
395 #warning "The Isorropia package is deprecated"
396 #endif
397 #endif
398 
int printZoltanMetrics()
Definition: Isorropia_EpetraPartitioner.hpp:375
An implementation of the Partitioner interface that operates on Epetra matrices and linear systems...
Definition: Isorropia_EpetraOperator.hpp:72
float * partSizes
Definition: Isorropia_EpetraPartitioner.hpp:379
void elemsInPart(int part, int *elementList, int len) const
Fill user-allocated list (of length len) with the local element ids to be located in the given part...
Definition: Isorropia_EpetraPartitioner.hpp:345
virtual void compute(bool forceRecomputing=false)
Method which does the work of computing a new partitioning/coloring/ordering, depending on the child ...
int printMetrics
Definition: Isorropia_EpetraPartitioner.hpp:381
virtual void elemsWithProperty(int property, int *elementList, int len) const
Fill user-allocated list (of length len) with the global element ids to be located in the given parti...
virtual ~Partitioner()
Destructor.
int numPartSizes
Definition: Isorropia_EpetraPartitioner.hpp:380
void setPartSizes(int len, int *global_part_id, float *part_size)
void partition(bool force_repartitioning=false)
partition is the method that computes a rebalanced partitioning for the data in the object that this ...
virtual int numElemsWithProperty(int property) const
Return the number of elements in a given partition.
Definition: Isorropia_EpetraCostDescriber.hpp:128
Teuchos::RCP< Epetra_Map > createNewMap()
Create a new Epetra_Map corresponding to the new partition.
int * partGIDs
Definition: Isorropia_EpetraPartitioner.hpp:378
An implementation of the Partitioner interface that operates on Epetra matrices and linear systems...
Definition: Isorropia_EpetraPartitioner.hpp:122
Partitioner(Teuchos::RCP< const Epetra_CrsGraph > inputGraph, const Teuchos::ParameterList &paramlist=Teuchos::ParameterList("EmptyParameterList"), bool compute_partitioning_now=true)
int numElemsInPart(int part) const
Return the number of LOCAL elements in a given part.
Definition: Isorropia_EpetraPartitioner.hpp:339
Interface (abstract base class) for computing a new partitioning and describing the layout of element...
Definition: Isorropia_Partitioner.hpp:59