|
Isorropia: Partitioning, Load Balancing and more Version 3.0
|
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 // This library is free software; you can redistribute it and/or modify 00011 // it under the terms of the GNU Lesser General Public License as 00012 // published by the Free Software Foundation; either version 2.1 of the 00013 // License, or (at your option) any later version. 00014 // 00015 // This library is distributed in the hope that it will be useful, but 00016 // WITHOUT ANY WARRANTY; without even the implied warranty of 00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00018 // Lesser General Public License for more details. 00019 // 00020 // You should have received a copy of the GNU Lesser General Public 00021 // License along with this library; if not, write to the Free Software 00022 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 00023 // USA 00024 // 00025 // *********************************************************************** 00026 //@HEADER 00027 00028 #ifndef ISORROPIA_EPETRA_ZOLTAN_QUERYOBJECT_H 00029 #define ISORROPIA_EPETRA_ZOLTAN_QUERYOBJECT_H 00030 00031 #include "Isorropia_ConfigDefs.hpp" 00032 00033 #include <Teuchos_RCP.hpp> 00034 00035 #include <zoltan_cpp.h> 00036 00037 #include <set> 00038 #include <map> 00039 00040 class Epetra_BlockMap; 00041 class Epetra_CrsGraph; 00042 class Epetra_RowMatrix; 00043 class Epetra_MultiVector; 00044 00045 namespace Isorropia { 00046 00047 namespace Epetra { 00048 00049 class CostDescriber; 00050 00058 namespace ZoltanLib { 00059 00069 class QueryObject 00070 { 00071 00075 const bool haveGraph_; 00076 00080 Teuchos::RCP<const Epetra_CrsGraph> graph_; 00081 00086 Teuchos::RCP<const Epetra_RowMatrix> matrix_; 00087 00093 Teuchos::RCP<const Epetra_MultiVector> coords_; 00094 00097 const Epetra_BlockMap *rowMap_; 00098 00101 const Epetra_BlockMap *colMap_; 00102 00107 Teuchos::RCP<const Isorropia::Epetra::CostDescriber> costs_; 00108 00114 Teuchos::RCP<const Epetra_MultiVector> weights_; 00115 00116 std::map<int,int> procmap_; 00117 std::set<int> graph_self_edges_; 00118 00119 int myProc_; 00120 int base_; 00121 00122 void fill_procmap(); 00123 00130 int My_Number_Objects(int *ierr); 00131 00135 void My_Object_List (int num_gid_entries, int num_lid_entries, 00136 ZOLTAN_ID_PTR global_ids, ZOLTAN_ID_PTR local_ids, 00137 int weight_dim, float * object_weights, int * ierr ); 00138 00143 void My_Number_Edges_Multi (int num_gid_entries, int num_lid_entries, 00144 int num_obj, ZOLTAN_ID_PTR global_ids, ZOLTAN_ID_PTR local_ids, 00145 int *num_edges, int * ierr ); 00146 00151 void My_Edge_List_Multi(int num_gid_entries, int num_lid_entries, 00152 int num_obj, ZOLTAN_ID_PTR global_ids, ZOLTAN_ID_PTR local_ids, 00153 int *num_edges, ZOLTAN_ID_PTR neighbor_global_ids, int * neighbor_procs, 00154 int weight_dim, float * edge_weights, int * ierr ); 00155 00159 void My_HG_Size_CS (int* num_lists, int* num_pins, int* format, 00160 int * ierr ); 00161 00165 void My_HG_CS (int num_gid_entries, int num_row_or_col, int num_pins, 00166 int format, ZOLTAN_ID_PTR vtxedge_GID, int* vtxedge_ptr, ZOLTAN_ID_PTR pin_GID, 00167 int * ierr ); 00168 00169 00173 void My_FGHG_CS (int num_gid_entries, int num_row_or_col, int num_pins, 00174 int format, ZOLTAN_ID_PTR vtxedge_GID, int* vtxedge_ptr, ZOLTAN_ID_PTR pin_GID, 00175 int * ierr ); 00176 00181 void My_HG_Size_Edge_Weights(int* num_edges, int* ierr); 00182 00187 void My_HG_Edge_Weights(int num_gid_entries, int num_lid_entries, int num_edges, int edge_weight_dim, 00188 ZOLTAN_ID_PTR edge_GID, ZOLTAN_ID_PTR edge_LID, float* edge_weights, int* ierr); 00189 00194 int My_Number_Geom(int *ierr); 00195 00199 void My_Geom_Multi(int num_gid_entries, int num_lid_entries, 00200 int num_obj, ZOLTAN_ID_PTR gids, ZOLTAN_ID_PTR lids, int num_dim, 00201 double *geom_vec, int *ierr); 00202 00203 public: 00204 00207 QueryObject( Teuchos::RCP<const Epetra_CrsGraph> graph, 00208 Teuchos::RCP<const Isorropia::Epetra::CostDescriber> costs, 00209 int inputType); 00210 00211 00214 QueryObject( Teuchos::RCP<const Epetra_RowMatrix> matrix, 00215 Teuchos::RCP<const Isorropia::Epetra::CostDescriber> costs, 00216 int inputType); 00217 00220 QueryObject( Teuchos::RCP<const Epetra_MultiVector> coords, 00221 Teuchos::RCP<const Epetra_MultiVector> weights); 00222 00223 00226 QueryObject(Teuchos::RCP<const Epetra_CrsGraph> graph, 00227 Teuchos::RCP<const Isorropia::Epetra::CostDescriber> costs, 00228 Teuchos::RCP<const Epetra_MultiVector> coords, 00229 Teuchos::RCP<const Epetra_MultiVector> weights, 00230 int inputType); 00231 00232 00235 QueryObject(Teuchos::RCP<const Epetra_RowMatrix> matrix, 00236 Teuchos::RCP<const Isorropia::Epetra::CostDescriber> costs, 00237 Teuchos::RCP<const Epetra_MultiVector> coords, 00238 Teuchos::RCP<const Epetra_MultiVector> weights, 00239 int inputType); 00240 00241 00244 QueryObject( Teuchos::RCP<const Epetra_BlockMap> inputMap, 00245 int inputType); 00246 00247 00248 00249 00252 virtual ~QueryObject(); 00253 00259 static const int hgraph_input_ = 1; 00260 00265 static const int hgraph2d_finegrain_input_ = 2; 00266 00272 static const int graph_input_ = 3; 00273 00280 static const int geometric_input_ = 4; 00281 00287 static const int hgraph_graph_input_ = 5; 00288 00294 static const int hgraph_geometric_input_ = 6; 00295 00302 static const int graph_geometric_input_ = 7; 00303 00309 static const int hgraph_graph_geometric_input_ = 8; 00310 00314 static const int simple_input_ = 9; 00315 00316 00320 static const int unspecified_input_ = 10; 00321 00322 00323 00329 int input_type_; 00330 00333 const Epetra_BlockMap &RowMap(void){ return *rowMap_;}; 00334 00338 bool haveVertexWeights(); 00339 00343 bool haveGraphEdgeWeights(); 00344 00348 bool haveHypergraphEdgeWeights(); 00349 00350 // General query functions 00351 00354 static int Number_Objects(void *data, int *ierr); 00355 00358 static void Object_List ( void * data, int num_gid_entries, int num_lid_entries, 00359 ZOLTAN_ID_PTR global_ids, ZOLTAN_ID_PTR local_ids, 00360 int weight_dim, float * object_weights, int * ierr ); 00361 00362 // Query functions for graph partitioning only 00363 00366 static void Number_Edges_Multi ( void * data, int num_gid_entries, int num_lid_entries, 00367 int num_obj, ZOLTAN_ID_PTR global_ids, ZOLTAN_ID_PTR local_ids, 00368 int *num_edges, int * ierr ); 00369 00372 static void Edge_List_Multi( void * data, int num_gid_entries, int num_lid_entries, 00373 int num_obj, ZOLTAN_ID_PTR global_ids, ZOLTAN_ID_PTR local_ids, 00374 int *num_edges, ZOLTAN_ID_PTR neighbor_global_ids, int * neighbor_procs, 00375 int weight_dim, float * edge_weights, int * ierr ); 00376 00377 // Query functions for hypergraph partitioning only 00378 00381 static void HG_Size_CS ( void * data, int* num_lists, int* num_pins, int* format, 00382 int * ierr ); 00385 static void HG_CS ( void * data, int num_gid_entries, int num_row_or_col, int num_pins, 00386 int format, ZOLTAN_ID_PTR vtxedge_GID, int* vtxedge_ptr, ZOLTAN_ID_PTR pin_GID, 00387 int * ierr ); 00390 static void HG_Size_Edge_Weights(void * data, int* num_edges, int* ierr); 00391 00394 static void HG_Edge_Weights(void * data, 00395 int num_gid_entries, int num_lid_entries, int num_edges, int edge_weight_dim, 00396 ZOLTAN_ID_PTR edge_GID, ZOLTAN_ID_PTR edge_LID, float* edge_weights, int* ierr); 00397 00400 static int Number_Geom(void *data, int *ierr); 00401 00404 static void Geom_Multi(void *data, int num_gid_entries, int num_lid_entries, 00405 int num_obj, ZOLTAN_ID_PTR gids, ZOLTAN_ID_PTR lids, int num_dim, 00406 double *geom_vec, int *ierr); 00407 00408 00409 //M.M.W. need to add hierarchical query functions 00410 00411 }; 00412 00413 } //namespace ZoltanLib 00414 } //namespace Epetra 00415 } //namespace Isorropia 00416 00417 #endif //ISORROPIA_EPETRA_ZOLTAN_QUERYOBJECT_H