| 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_EpetraPartitioner2D_hpp_ |
| 41 |
#define _Isorropia_EpetraPartitioner2D_hpp_ |
| 42 |
|
| 43 |
#include <Isorropia_ConfigDefs.hpp> |
| 44 |
#include <Teuchos_RCP.hpp> |
| 45 |
#include <Teuchos_ParameterList.hpp> |
| 46 |
|
| 47 |
#include <Isorropia_EpetraOperator.hpp> |
| 48 |
#include <Isorropia_Partitioner2D.hpp> |
| 49 |
|
| 50 |
#ifdef HAVE_EPETRA |
| 51 |
class Epetra_Map; |
| 52 |
class Epetra_BlockMap; |
| 53 |
class Epetra_Import; |
| 54 |
class Epetra_Vector; |
| 55 |
class Epetra_MultiVector; |
| 56 |
class Epetra_CrsGraph; |
| 57 |
class Epetra_CrsMatrix; |
| 58 |
class Epetra_RowMatrix; |
| 59 |
class Epetra_LinearProblem; |
| 60 |
|
| 61 |
namespace Isorropia { |
| 62 |
|
| 63 |
namespace Epetra { |
| 64 |
|
| 65 |
/** An implementation of the Partitioner interface that operates on |
| 66 |
Epetra matrices and linear systems. |
| 67 |
|
| 68 |
*/ |
| 69 |
|
| 70 |
class Partitioner2D : virtual public Isorropia::Partitioner2D, virtual public Isorropia::Epetra::Operator { |
| 71 |
public: |
| 72 |
/** Constructor that accepts an Epetra_CrsGraph object, called by |
| 73 |
API function create_partitioner(). |
| 74 |
|
| 75 |
\param input_graph Matrix-graph object for which a new partitioning |
| 76 |
is to be computed. A Teuchos::RefCountPtr is used here because a |
| 77 |
reference to the input object may be held by this object after |
| 78 |
this constructor completes and returns. |
| 79 |
|
| 80 |
\param paramlist Teuchos::ParameterList which will be copied to an |
| 81 |
internal ParameterList attribute. No reference to this input |
| 82 |
object is held after this constructor completes.<br> |
| 83 |
If the ParameterList object contains a sublist named "Zoltan", then |
| 84 |
the Zoltan library is used to perform the balancing. Also, any |
| 85 |
parameters in the "Zoltan" sublist will be relayed directly to Zoltan. |
| 86 |
Refer to the Zoltan users guide for specific parameters that Zoltan |
| 87 |
recognizes. A couple of important ones are "LB_METHOD" (valid values |
| 88 |
include "GRAPH", "HYPERGRAPH"), "DEBUG_LEVEL" (valid values are |
| 89 |
0 to 10, default is 1), etc. |
| 90 |
|
| 91 |
\param compute_partitioning_now Optional argument defaults to true. |
| 92 |
If true, the method compute_partitioning() will be called before |
| 93 |
this constructor returns. |
| 94 |
*/ |
| 95 |
Partitioner2D(Teuchos::RCP<const Epetra_CrsGraph> input_graph, |
| 96 |
const Teuchos::ParameterList& paramlist = Teuchos::ParameterList("EmptyParameterList"), |
| 97 |
bool compute_partitioning_now=true); |
| 98 |
|
| 99 |
/** |
| 100 |
Constructor that accepts an Epetra_RowMatrix object, called by |
| 101 |
API function create_partitioner(). |
| 102 |
|
| 103 |
\param input_matrix Matrix object for which a new partitioning is |
| 104 |
to be computed. A Teuchos::RefCountPtr is used here because a |
| 105 |
reference to the input object may be held by this object after |
| 106 |
this constructor completes and returns. |
| 107 |
|
| 108 |
\param paramlist Teuchos::ParameterList which will be copied to an |
| 109 |
internal ParameterList attribute. No reference to this input |
| 110 |
object is held after this constructor completes.<br> |
| 111 |
If the ParameterList object contains a sublist named "Zoltan", then |
| 112 |
the Zoltan library is used to perform the balancing. Also, any |
| 113 |
parameters in the "Zoltan" sublist will be relayed directly to Zoltan. |
| 114 |
Refer to the Zoltan users guide for specific parameters that Zoltan |
| 115 |
recognizes. A couple of important ones are "LB_METHOD" (valid values |
| 116 |
include "GRAPH", "HYPERGRAPH"), "DEBUG_LEVEL" (valid values are |
| 117 |
0 to 10, default is 1), etc. |
| 118 |
|
| 119 |
\param compute_partitioning_now Optional argument defaults to true. |
| 120 |
If true, the method compute_partitioning() will be called before |
| 121 |
this constructor returns. |
| 122 |
*/ |
| 123 |
Partitioner2D(Teuchos::RCP<const Epetra_RowMatrix> input_matrix, |
| 124 |
const Teuchos::ParameterList& paramlist = Teuchos::ParameterList("EmptyParameterList"), |
| 125 |
bool compute_partitioning_now=true); |
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
/** Destructor */ |
| 130 |
virtual ~Partitioner2D(); |
| 131 |
|
| 132 |
|
| 133 |
// MMW: Missing functions that are in EpetraPartioner, might need to implement |
| 134 |
//void setPartSizes(int len, int *global_part_id, float *part_size); |
| 135 |
//void clearPartSizes(); |
| 136 |
|
| 137 |
/** partition is a method that computes |
| 138 |
a rebalanced partitioning for the data in the object |
| 139 |
that this class was constructed with. |
| 140 |
|
| 141 |
\param force_repartitioning Optional argument defaults to false. By |
| 142 |
default, compute_partitioning() only does anything the first time |
| 143 |
it is called, and subsequent repeated calls are no-ops. If the user's |
| 144 |
intent is to re-compute the partitioning (e.g., if parameters |
| 145 |
or other inputs have been changed), then setting this flag to |
| 146 |
true will force a new partitioning to be computed. |
| 147 |
*/ |
| 148 |
void partition(bool force_repartitioning=false); |
| 149 |
|
| 150 |
virtual void compute(bool forceRecomputing=false); |
| 151 |
|
| 152 |
|
| 153 |
/** |
| 154 |
*/ |
| 155 |
int numElemsInPart(int part) const; |
| 156 |
|
| 157 |
|
| 158 |
/** |
| 159 |
*/ |
| 160 |
int getNZIndx(int row, int column) const; |
| 161 |
|
| 162 |
|
| 163 |
/** global element ids to be located in the given partition. |
| 164 |
*/ |
| 165 |
void elemsInPart(int part, int* elementList, int len) const; |
| 166 |
|
| 167 |
|
| 168 |
// Should add RCP versions of the below |
| 169 |
|
| 170 |
int createDomainAndRangeMaps(Epetra_Map *domainMap, |
| 171 |
Epetra_Map *rangeMap); |
| 172 |
|
| 173 |
// perhaps pass parameter lists to these? |
| 174 |
int createColumnMap(Epetra_Map* colMap); |
| 175 |
int createRowMap(Epetra_Map* rowMap); |
| 176 |
|
| 177 |
|
| 178 |
|
| 179 |
|
| 180 |
};//class Partitioner2D |
| 181 |
|
| 182 |
}//namespace Epetra |
| 183 |
}//namespace Isorropia |
| 184 |
|
| 185 |
#endif //HAVE_EPETRA |
| 186 |
|
| 187 |
#endif |
| 188 |
|
| 189 |
|
| 190 |
|
| 191 |
#if defined(Isorropia_SHOW_DEPRECATED_WARNINGS) |
| 192 |
#ifdef __GNUC__ |
| 193 |
#warning "The Isorropia package is deprecated" |
| 194 |
#endif |
| 195 |
#endif |
| 196 |
|