|
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_TPETRA_ZOLTAN_QUERYOBJECT_H 00041 #define ISORROPIA_TPETRA_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 00053 #include <Kokkos_DefaultNode.hpp> 00054 #include <Tpetra_CrsGraph_decl.hpp> 00055 #include <Tpetra_RowMatrix.hpp> 00056 #include <Tpetra_MultiVector_decl.hpp> 00057 00058 #include <Isorropia_TpetraCostDescriber.hpp> 00059 00060 namespace Isorropia { 00061 00062 namespace Tpetra { 00063 00064 00065 00073 namespace ZoltanLib { 00074 00086 template <typename Node = KokkosClassic::DefaultNode::DefaultNodeType > 00087 class QueryObject 00088 { 00089 00093 const bool haveGraph_; 00094 00098 Teuchos::RCP<const ::Tpetra::CrsGraph<int,int,Node> > graph_; 00099 00104 Teuchos::RCP<const ::Tpetra::RowMatrix<double,int,int,Node> > matrix_; 00105 00111 Teuchos::RCP<const ::Tpetra::MultiVector<double,int,int,Node> > coords_; 00112 00115 const ::Tpetra::Map<int,int,Node> *rowMap_; 00116 00119 const ::Tpetra::Map<int,int,Node> *colMap_; 00120 00125 Teuchos::RCP<const Isorropia::Tpetra::CostDescriber<Node> > costs_; 00126 00132 Teuchos::RCP<const ::Tpetra::MultiVector<double,int,int,Node> > weights_; 00133 00134 std::map<int,int> procmap_; 00135 std::set<int> graph_self_edges_; 00136 00137 int myProc_; 00138 int base_; 00139 00140 void fill_procmap(); 00141 00148 int My_Number_Objects(int *ierr); 00149 00153 void My_Object_List (int num_gid_entries, int num_lid_entries, 00154 ZOLTAN_ID_PTR global_ids, ZOLTAN_ID_PTR local_ids, 00155 int weight_dim, float * object_weights, int * ierr ); 00156 00161 void My_Number_Edges_Multi (int num_gid_entries, int num_lid_entries, 00162 int num_obj, ZOLTAN_ID_PTR global_ids, ZOLTAN_ID_PTR local_ids, 00163 int *num_edges, int * ierr ); 00164 00169 void My_Edge_List_Multi(int num_gid_entries, int num_lid_entries, 00170 int num_obj, ZOLTAN_ID_PTR global_ids, ZOLTAN_ID_PTR local_ids, 00171 int *num_edges, ZOLTAN_ID_PTR neighbor_global_ids, int * neighbor_procs, 00172 int weight_dim, float * edge_weights, int * ierr ); 00173 00177 void My_HG_Size_CS (int* num_lists, int* num_pins, int* format, 00178 int * ierr ); 00179 00183 void My_HG_CS (int num_gid_entries, int num_row_or_col, int num_pins, 00184 int format, ZOLTAN_ID_PTR vtxedge_GID, int* vtxedge_ptr, ZOLTAN_ID_PTR pin_GID, 00185 int * ierr ); 00186 00187 00191 void My_FGHG_CS (int num_gid_entries, int num_row_or_col, int num_pins, 00192 int format, ZOLTAN_ID_PTR vtxedge_GID, int* vtxedge_ptr, ZOLTAN_ID_PTR pin_GID, 00193 int * ierr ); 00194 00199 void My_HG_Size_Edge_Weights(int* num_edges, int* ierr); 00200 00205 void My_HG_Edge_Weights(int num_gid_entries, int num_lid_entries, int num_edges, int edge_weight_dim, 00206 ZOLTAN_ID_PTR edge_GID, ZOLTAN_ID_PTR edge_LID, float* edge_weights, int* ierr); 00207 00212 int My_Number_Geom(int *ierr); 00213 00217 void My_Geom_Multi(int num_gid_entries, int num_lid_entries, 00218 int num_obj, ZOLTAN_ID_PTR gids, ZOLTAN_ID_PTR lids, int num_dim, 00219 double *geom_vec, int *ierr); 00220 00221 public: 00222 00225 QueryObject( Teuchos::RCP<const ::Tpetra::CrsGraph<int,int,Node> > graph, 00226 Teuchos::RCP<const Isorropia::Tpetra::CostDescriber<Node> > costs, 00227 int inputType); 00228 00229 00232 QueryObject( Teuchos::RCP<const ::Tpetra::RowMatrix<double,int,int,Node> > matrix, 00233 Teuchos::RCP<const Isorropia::Tpetra::CostDescriber<Node> > costs, 00234 int inputType); 00235 00238 QueryObject( Teuchos::RCP<const ::Tpetra::MultiVector<double,int,int,Node> > coords, 00239 Teuchos::RCP<const ::Tpetra::MultiVector<double,int,int,Node> > weights); 00240 00241 00244 QueryObject(Teuchos::RCP<const ::Tpetra::CrsGraph<int,int,Node> > graph, 00245 Teuchos::RCP<const Isorropia::Tpetra::CostDescriber<Node> > costs, 00246 Teuchos::RCP<const ::Tpetra::MultiVector<double,int,int,Node> > coords, 00247 Teuchos::RCP<const ::Tpetra::MultiVector<double,int,int,Node> > weights, 00248 int inputType); 00249 00250 00253 QueryObject(Teuchos::RCP<const ::Tpetra::RowMatrix<double,int,int,Node> > matrix, 00254 Teuchos::RCP<const Isorropia::Tpetra::CostDescriber<Node> > costs, 00255 Teuchos::RCP<const ::Tpetra::MultiVector<double,int,int,Node> > coords, 00256 Teuchos::RCP<const ::Tpetra::MultiVector<double,int,int,Node> > weights, 00257 int inputType); 00258 00259 00262 QueryObject( Teuchos::RCP<const ::Tpetra::Map<int,int,Node> > inputMap, 00263 int inputType); 00264 00265 00266 00267 00270 virtual ~QueryObject(); 00271 00277 static const int hgraph_input_ = 1; 00278 00283 static const int hgraph2d_finegrain_input_ = 2; 00284 00290 static const int graph_input_ = 3; 00291 00298 static const int geometric_input_ = 4; 00299 00305 static const int hgraph_graph_input_ = 5; 00306 00312 static const int hgraph_geometric_input_ = 6; 00313 00320 static const int graph_geometric_input_ = 7; 00321 00327 static const int hgraph_graph_geometric_input_ = 8; 00328 00332 static const int simple_input_ = 9; 00333 00334 00338 static const int unspecified_input_ = 10; 00339 00340 00341 00347 int input_type_; 00348 00351 const ::Tpetra::Map<int,int,Node> &RowMap(void){ return *rowMap_;}; 00352 00356 bool haveVertexWeights(); 00357 00361 bool haveGraphEdgeWeights(); 00362 00366 bool haveHypergraphEdgeWeights(); 00367 00368 // General query functions 00369 00372 static int Number_Objects(void *data, int *ierr); 00373 00376 static void Object_List ( void * data, int num_gid_entries, int num_lid_entries, 00377 ZOLTAN_ID_PTR global_ids, ZOLTAN_ID_PTR local_ids, 00378 int weight_dim, float * object_weights, int * ierr ); 00379 00380 // Query functions for graph partitioning only 00381 00384 static void Number_Edges_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, int * ierr ); 00387 00390 static void Edge_List_Multi( void * data, int num_gid_entries, int num_lid_entries, 00391 int num_obj, ZOLTAN_ID_PTR global_ids, ZOLTAN_ID_PTR local_ids, 00392 int *num_edges, ZOLTAN_ID_PTR neighbor_global_ids, int * neighbor_procs, 00393 int weight_dim, float * edge_weights, int * ierr ); 00394 00395 // Query functions for hypergraph partitioning only 00396 00399 static void HG_Size_CS ( void * data, int* num_lists, int* num_pins, int* format, 00400 int * ierr ); 00403 static void HG_CS ( void * data, int num_gid_entries, int num_row_or_col, int num_pins, 00404 int format, ZOLTAN_ID_PTR vtxedge_GID, int* vtxedge_ptr, ZOLTAN_ID_PTR pin_GID, 00405 int * ierr ); 00408 static void HG_Size_Edge_Weights(void * data, int* num_edges, int* ierr); 00409 00412 static void HG_Edge_Weights(void * data, 00413 int num_gid_entries, int num_lid_entries, int num_edges, int edge_weight_dim, 00414 ZOLTAN_ID_PTR edge_GID, ZOLTAN_ID_PTR edge_LID, float* edge_weights, int* ierr); 00415 00418 static int Number_Geom(void *data, int *ierr); 00419 00422 static void Geom_Multi(void *data, int num_gid_entries, int num_lid_entries, 00423 int num_obj, ZOLTAN_ID_PTR gids, ZOLTAN_ID_PTR lids, int num_dim, 00424 double *geom_vec, int *ierr); 00425 00426 00427 //M.M.W. need to add hierarchical query functions 00428 00429 }; 00430 00431 } //namespace ZoltanLib 00432 } //namespace Tpetra 00433 } //namespace Isorropia 00434 00435 #endif //ISORROPIA_TPETRA_ZOLTAN_QUERYOBJECT_H