|
Isorropia: Partitioning, Load Balancing and more
|
00001 //@HEADER 00002 //************************************************************************ 00003 // 00004 // Isorropia: Partitioning and Load Balancing Package 00005 // Copyright (2006) Sandia Corporation 00006 // 00007 //Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive 00008 //license for use of this work by or on behalf of the U.S. Government. 00009 // 00010 // Redistribution and use in source and binary forms, with or without 00011 // modification, are permitted provided that the following conditions are 00012 // met: 00013 // 00014 // 1. Redistributions of source code must retain the above copyright 00015 // notice, this list of conditions and the following disclaimer. 00016 // 00017 // 2. Redistributions in binary form must reproduce the above copyright 00018 // notice, this list of conditions and the following disclaimer in the 00019 // documentation and/or other materials provided with the distribution. 00020 // 00021 // 3. Neither the name of the Corporation nor the names of the 00022 // contributors may be used to endorse or promote products derived from 00023 // this software without specific prior written permission. 00024 // 00025 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY 00026 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00027 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 00028 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE 00029 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00030 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00031 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00032 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00033 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00034 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00035 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00036 // 00037 //************************************************************************ 00038 //@HEADER 00039 00040 #ifndef _Isorropia_TpetraPartitioner_hpp_ 00041 #define _Isorropia_TpetraPartitioner_hpp_ 00042 00043 00051 #include <Isorropia_ConfigDefs.hpp> 00052 #include <Teuchos_RCP.hpp> 00053 #include <Teuchos_ParameterList.hpp> 00054 00055 00056 00057 #ifdef HAVE_ISORROPIA_TPETRA 00058 #include <Isorropia_TpetraOperator.hpp> 00059 #include <Isorropia_Partitioner.hpp> 00060 #include <Isorropia_TpetraZoltanLib.hpp> 00061 00062 00063 #include <Kokkos_DefaultNode.hpp> 00064 #include <Tpetra_CrsGraph_decl.hpp> 00065 #include <Tpetra_RowMatrix.hpp> 00066 #include <Tpetra_MultiVector_decl.hpp> 00067 00068 namespace Isorropia { 00069 00070 namespace Tpetra { 00071 00072 00073 00074 00075 template <class Node=KokkosClassic::DefaultNode::DefaultNodeType> 00076 class Partitioner : public Isorropia::Partitioner, public Isorropia::Tpetra::Operator<Node> { 00077 public: 00078 00079 00080 Partitioner(Teuchos::RCP<const ::Tpetra::CrsGraph<int,int,Node> > inputGraph, 00081 const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"), 00082 bool compute_partitioning_now=true); 00083 00084 Partitioner(const ::Tpetra::CrsGraph<int,int,Node> *inputGraph, 00085 const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"), 00086 bool compute_partitioning_now=true); 00087 00088 Partitioner(Teuchos::RCP<const ::Tpetra::CrsGraph<int,int,Node> > inputGraph, 00089 Teuchos::RCP<CostDescriber<Node> > costs, 00090 const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"), 00091 bool compute_partitioning_now=true); 00092 00093 Partitioner(const ::Tpetra::CrsGraph<int,int,Node> *inputGraph, 00094 CostDescriber<Node> * costs, 00095 const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"), 00096 bool compute_partitioning_now=true); 00097 00098 Partitioner(Teuchos::RCP<const ::Tpetra::RowMatrix<double,int,int,Node> > inputMatrix, 00099 const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"), 00100 bool compute_partitioning_now=true); 00101 00102 Partitioner(const ::Tpetra::RowMatrix<double,int,int,Node> *inputMatrix, 00103 const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"), 00104 bool compute_partitioning_now=true); 00105 00106 Partitioner(Teuchos::RCP<const ::Tpetra::RowMatrix<double,int,int,Node> > inputMatrix, 00107 Teuchos::RCP<CostDescriber<Node> > costs, 00108 const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"), 00109 bool compute_partitioning_now=true); 00110 00111 Partitioner(const ::Tpetra::RowMatrix<double,int,int,Node> *inputMatrix, 00112 CostDescriber<Node> *costs, 00113 const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"), 00114 bool compute_partitioning_now=true); 00115 00116 Partitioner(Teuchos::RCP<const ::Tpetra::MultiVector<double,int,int,Node> > coords, 00117 const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"), 00118 bool compute_partitioning_now=true); 00119 00120 Partitioner(const ::Tpetra::MultiVector<double,int,int,Node> *coords, 00121 const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"), 00122 bool compute_partitioning_now=true); 00123 00124 Partitioner(Teuchos::RCP<const ::Tpetra::MultiVector<double,int,int,Node> > coords, 00125 Teuchos::RCP<const ::Tpetra::MultiVector<double,int,int,Node> > weights, 00126 const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"), 00127 bool compute_partitioning_now=true); 00128 00129 Partitioner(const ::Tpetra::MultiVector<double,int,int,Node> *coords, 00130 const ::Tpetra::MultiVector<double,int,int,Node> *weights, 00131 const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"), 00132 bool compute_partitioning_now=true); 00133 00134 Partitioner(Teuchos::RCP<const ::Tpetra::Map<int,int,Node> > inputMap, 00135 const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"), 00136 bool compute_partitioning_now=true); 00137 00138 Partitioner(const ::Tpetra::Map<int,int,Node> *inputMap, 00139 const Teuchos::ParameterList& paramlist=Teuchos::ParameterList("EmptyParameterList"), 00140 bool compute_partitioning_now=true); 00141 00142 00143 // MMW: currently not supporting hiearchical partitioning 00144 00145 00146 00147 00148 00149 virtual ~Partitioner(); 00150 00151 /* @ingroup partitioning_grp 00152 * Set the relative number of objects in each part. The default is to 00153 * evenly divide objects across parts. The numbers can be fractions of 00154 * one, or whole numbers. Zoltan adds the values supplied and takes the sizes 00155 * as proportional to that whole. 00156 * 00157 * We make a copy of id and size lists. 00158 * 00159 * Caller should supply either global part IDs or local part IDs. 00160 * Part IDs are integers beginning at zero for the first part. 00161 * 00162 * No communication is done during this call. One process can make the call 00163 * for all parts, or many processes can make the call. Zoltan checks the 00164 * consistency of the information provided. 00165 */ 00166 00167 void setPartSizes(int len, int *global_part_id, float *part_size); 00168 00169 /* @ingroup partitioning_grp 00170 * Free the memory allocated to store part sizes. 00171 */ 00172 void clearPartSizes(); 00173 00186 void partition(bool force_repartitioning=false); 00187 00190 virtual void compute(bool forceRecomputing=false); 00191 00194 int numElemsInPart(int part) const { 00195 return (numElemsWithProperty(part)); 00196 } 00197 00200 void elemsInPart(int part, int* elementList, int len) const { 00201 elemsWithProperty(part, elementList, len); 00202 } 00203 00215 Teuchos::RCP< ::Tpetra::Map<int,int,Node> > createNewMap(); 00216 00228 void createNewMap(::Tpetra::Map<int,int,Node> *&outputMap); 00229 00230 private: 00231 int *partGIDs; 00232 float *partSizes; 00233 int numPartSizes; 00234 00235 };//class Partitioner 00236 00237 }//namespace Tpetra 00238 }//namespace Isorropia 00239 00240 #endif //HAVE_ISORROPIA_TPETRA 00241 00242 #endif 00243