|
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_EPETRA_ZOLTAN_QUERYOBJECT_H 00041 #define ISORROPIA_EPETRA_ZOLTAN_QUERYOBJECT_H 00042 00043 #include "Isorropia_ConfigDefs.hpp" 00044 00045 #include <Teuchos_RCP.hpp> 00046 00047 #include <zoltan_cpp.h> 00048 00049 #include <set> 00050 #include <map> 00051 00052 class Epetra_BlockMap; 00053 class Epetra_CrsGraph; 00054 class Epetra_RowMatrix; 00055 class Epetra_MultiVector; 00056 00057 namespace Isorropia { 00058 00059 namespace Epetra { 00060 00061 class CostDescriber; 00062 00070 namespace ZoltanLib { 00071 00081 class QueryObject 00082 { 00083 00087 const bool haveGraph_; 00088 00092 Teuchos::RCP<const Epetra_CrsGraph> graph_; 00093 00098 Teuchos::RCP<const Epetra_RowMatrix> matrix_; 00099 00105 Teuchos::RCP<const Epetra_MultiVector> coords_; 00106 00109 const Epetra_BlockMap *rowMap_; 00110 00113 const Epetra_BlockMap *colMap_; 00114 00119 Teuchos::RCP<const Isorropia::Epetra::CostDescriber> costs_; 00120 00126 Teuchos::RCP<const Epetra_MultiVector> weights_; 00127 00128 std::map<int,int> procmap_; 00129 std::set<int> graph_self_edges_; 00130 00131 unsigned int myProc_; 00132 unsigned int base_; 00133 00134 void fill_procmap(); 00135 00142 int My_Number_Objects(int *ierr); 00143 00147 void My_Object_List (int num_gid_entries, int num_lid_entries, 00148 ZOLTAN_ID_PTR global_ids, ZOLTAN_ID_PTR local_ids, 00149 int weight_dim, float * object_weights, int * ierr ); 00150 00155 void My_Number_Edges_Multi (int num_gid_entries, int num_lid_entries, 00156 int num_obj, ZOLTAN_ID_PTR global_ids, ZOLTAN_ID_PTR local_ids, 00157 int *num_edges, int * ierr ); 00158 00163 void My_Edge_List_Multi(int num_gid_entries, int num_lid_entries, 00164 int num_obj, ZOLTAN_ID_PTR global_ids, ZOLTAN_ID_PTR local_ids, 00165 int *num_edges, ZOLTAN_ID_PTR neighbor_global_ids, int * neighbor_procs, 00166 int weight_dim, float * edge_weights, int * ierr ); 00167 00171 void My_HG_Size_CS (int* num_lists, int* num_pins, int* format, 00172 int * ierr ); 00173 00177 void My_HG_CS (int num_gid_entries, int num_row_or_col, int num_pins, 00178 int format, ZOLTAN_ID_PTR vtxedge_GID, int* vtxedge_ptr, ZOLTAN_ID_PTR pin_GID, 00179 int * ierr ); 00180 00181 00185 void My_FGHG_CS (int num_gid_entries, int num_row_or_col, int num_pins, 00186 int format, ZOLTAN_ID_PTR vtxedge_GID, int* vtxedge_ptr, ZOLTAN_ID_PTR pin_GID, 00187 int * ierr ); 00188 00193 void My_HG_Size_Edge_Weights(int* num_edges, int* ierr); 00194 00199 void My_HG_Edge_Weights(int num_gid_entries, int num_lid_entries, int num_edges, int edge_weight_dim, 00200 ZOLTAN_ID_PTR edge_GID, ZOLTAN_ID_PTR edge_LID, float* edge_weights, int* ierr); 00201 00206 int My_Number_Geom(int *ierr); 00207 00211 void My_Geom_Multi(int num_gid_entries, int num_lid_entries, 00212 int num_obj, ZOLTAN_ID_PTR gids, ZOLTAN_ID_PTR lids, int num_dim, 00213 double *geom_vec, int *ierr); 00214 00215 public: 00216 00219 QueryObject( Teuchos::RCP<const Epetra_CrsGraph> graph, 00220 Teuchos::RCP<const Isorropia::Epetra::CostDescriber> costs, 00221 int inputType); 00222 00223 00226 QueryObject( Teuchos::RCP<const Epetra_RowMatrix> matrix, 00227 Teuchos::RCP<const Isorropia::Epetra::CostDescriber> costs, 00228 int inputType); 00229 00232 QueryObject( Teuchos::RCP<const Epetra_MultiVector> coords, 00233 Teuchos::RCP<const Epetra_MultiVector> weights); 00234 00235 00238 QueryObject(Teuchos::RCP<const Epetra_CrsGraph> graph, 00239 Teuchos::RCP<const Isorropia::Epetra::CostDescriber> costs, 00240 Teuchos::RCP<const Epetra_MultiVector> coords, 00241 Teuchos::RCP<const Epetra_MultiVector> weights, 00242 int inputType); 00243 00244 00247 QueryObject(Teuchos::RCP<const Epetra_RowMatrix> matrix, 00248 Teuchos::RCP<const Isorropia::Epetra::CostDescriber> costs, 00249 Teuchos::RCP<const Epetra_MultiVector> coords, 00250 Teuchos::RCP<const Epetra_MultiVector> weights, 00251 int inputType); 00252 00253 00256 QueryObject( Teuchos::RCP<const Epetra_BlockMap> inputMap, 00257 int inputType); 00258 00259 00260 00261 00264 virtual ~QueryObject(); 00265 00271 static const int hgraph_input_ = 1; 00272 00277 static const int hgraph2d_finegrain_input_ = 2; 00278 00284 static const int graph_input_ = 3; 00285 00292 static const int geometric_input_ = 4; 00293 00299 static const int hgraph_graph_input_ = 5; 00300 00306 static const int hgraph_geometric_input_ = 6; 00307 00314 static const int graph_geometric_input_ = 7; 00315 00321 static const int hgraph_graph_geometric_input_ = 8; 00322 00326 static const int simple_input_ = 9; 00327 00328 00332 static const int unspecified_input_ = 10; 00333 00334 00335 00341 int input_type_; 00342 00345 const Epetra_BlockMap &RowMap(void){ return *rowMap_;}; 00346 00350 bool haveVertexWeights(); 00351 00355 bool haveGraphEdgeWeights(); 00356 00360 bool haveHypergraphEdgeWeights(); 00361 00362 // General query functions 00363 00366 static int Number_Objects(void *data, int *ierr); 00367 00370 static void Object_List ( void * data, int num_gid_entries, int num_lid_entries, 00371 ZOLTAN_ID_PTR global_ids, ZOLTAN_ID_PTR local_ids, 00372 int weight_dim, float * object_weights, int * ierr ); 00373 00374 // Query functions for graph partitioning only 00375 00378 static void Number_Edges_Multi ( void * data, int num_gid_entries, int num_lid_entries, 00379 int num_obj, ZOLTAN_ID_PTR global_ids, ZOLTAN_ID_PTR local_ids, 00380 int *num_edges, int * ierr ); 00381 00384 static void Edge_List_Multi( void * data, int num_gid_entries, int num_lid_entries, 00385 int num_obj, ZOLTAN_ID_PTR global_ids, ZOLTAN_ID_PTR local_ids, 00386 int *num_edges, ZOLTAN_ID_PTR neighbor_global_ids, int * neighbor_procs, 00387 int weight_dim, float * edge_weights, int * ierr ); 00388 00389 // Query functions for hypergraph partitioning only 00390 00393 static void HG_Size_CS ( void * data, int* num_lists, int* num_pins, int* format, 00394 int * ierr ); 00397 static void HG_CS ( void * data, int num_gid_entries, int num_row_or_col, int num_pins, 00398 int format, ZOLTAN_ID_PTR vtxedge_GID, int* vtxedge_ptr, ZOLTAN_ID_PTR pin_GID, 00399 int * ierr ); 00402 static void HG_Size_Edge_Weights(void * data, int* num_edges, int* ierr); 00403 00406 static void HG_Edge_Weights(void * data, 00407 int num_gid_entries, int num_lid_entries, int num_edges, int edge_weight_dim, 00408 ZOLTAN_ID_PTR edge_GID, ZOLTAN_ID_PTR edge_LID, float* edge_weights, int* ierr); 00409 00412 static int Number_Geom(void *data, int *ierr); 00413 00416 static void Geom_Multi(void *data, int num_gid_entries, int num_lid_entries, 00417 int num_obj, ZOLTAN_ID_PTR gids, ZOLTAN_ID_PTR lids, int num_dim, 00418 double *geom_vec, int *ierr); 00419 00420 00421 //M.M.W. need to add hierarchical query functions 00422 00423 }; 00424 00425 } //namespace ZoltanLib 00426 } //namespace Epetra 00427 } //namespace Isorropia 00428 00429 #endif //ISORROPIA_EPETRA_ZOLTAN_QUERYOBJECT_H