Isorropia: Partitioning, Load Balancing and more Version 3.0
Isorropia_TpetraQueryObject.hpp
Go to the documentation of this file.
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_TPETRA_ZOLTAN_QUERYOBJECT_H
00029 #define ISORROPIA_TPETRA_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 
00041 #include <Kokkos_DefaultNode.hpp>
00042 #include <Tpetra_CrsGraph_decl.hpp>
00043 #include <Tpetra_RowMatrix.hpp>
00044 #include <Tpetra_MultiVector_decl.hpp>
00045 
00046 #include <Isorropia_TpetraCostDescriber.hpp>
00047 
00048 namespace Isorropia {
00049 
00050 namespace Tpetra {
00051 
00052 
00053 
00061 namespace ZoltanLib {
00062 
00074 template <typename Node = Kokkos::DefaultNode::DefaultNodeType >
00075 class QueryObject 
00076 {
00077 
00081   const bool haveGraph_;
00082 
00086   Teuchos::RCP<const ::Tpetra::CrsGraph<int,int,Node> > graph_;
00087 
00092   Teuchos::RCP<const ::Tpetra::RowMatrix<double,int,int,Node> > matrix_;
00093 
00099   Teuchos::RCP<const ::Tpetra::MultiVector<double,int,int,Node> > coords_;
00100 
00103   const ::Tpetra::Map<int,int,Node> *rowMap_;
00104 
00107   const ::Tpetra::Map<int,int,Node> *colMap_;
00108 
00113   Teuchos::RCP<const Isorropia::Tpetra::CostDescriber<Node> > costs_;
00114 
00120   Teuchos::RCP<const ::Tpetra::MultiVector<double,int,int,Node> > weights_;
00121 
00122   std::map<int,int> procmap_;
00123   std::set<int> graph_self_edges_;
00124 
00125   int myProc_;
00126   int base_;
00127 
00128   void fill_procmap();
00129 
00136   int My_Number_Objects(int *ierr);
00137 
00141   void My_Object_List  (int num_gid_entries, int num_lid_entries,
00142          ZOLTAN_ID_PTR global_ids, ZOLTAN_ID_PTR local_ids,
00143          int weight_dim, float * object_weights, int * ierr );
00144 
00149   void My_Number_Edges_Multi  (int num_gid_entries, int num_lid_entries,
00150          int num_obj, ZOLTAN_ID_PTR global_ids, ZOLTAN_ID_PTR local_ids,
00151          int *num_edges, int * ierr );
00152 
00157   void My_Edge_List_Multi(int num_gid_entries, int num_lid_entries,
00158          int num_obj, ZOLTAN_ID_PTR global_ids, ZOLTAN_ID_PTR local_ids,
00159          int *num_edges, ZOLTAN_ID_PTR neighbor_global_ids, int * neighbor_procs,
00160          int weight_dim, float * edge_weights, int * ierr );
00161 
00165   void My_HG_Size_CS (int* num_lists, int* num_pins, int* format,
00166         int * ierr );
00167 
00171   void My_HG_CS (int num_gid_entries, int num_row_or_col, int num_pins,
00172      int format, ZOLTAN_ID_PTR vtxedge_GID, int* vtxedge_ptr, ZOLTAN_ID_PTR pin_GID,
00173                int * ierr );
00174 
00175 
00179   void My_FGHG_CS (int num_gid_entries, int num_row_or_col, int num_pins,
00180      int format, ZOLTAN_ID_PTR vtxedge_GID, int* vtxedge_ptr, ZOLTAN_ID_PTR pin_GID,
00181                int * ierr );
00182 
00187   void My_HG_Size_Edge_Weights(int* num_edges, int* ierr);
00188   
00193   void My_HG_Edge_Weights(int num_gid_entries, int num_lid_entries, int num_edges, int edge_weight_dim,
00194         ZOLTAN_ID_PTR edge_GID, ZOLTAN_ID_PTR edge_LID, float* edge_weights, int* ierr);
00195 
00200   int My_Number_Geom(int *ierr);
00201 
00205   void My_Geom_Multi(int num_gid_entries, int num_lid_entries,
00206         int num_obj, ZOLTAN_ID_PTR gids, ZOLTAN_ID_PTR lids, int num_dim,
00207         double *geom_vec, int *ierr);
00208 
00209  public:
00210 
00213   QueryObject( Teuchos::RCP<const ::Tpetra::CrsGraph<int,int,Node> > graph,
00214          Teuchos::RCP<const Isorropia::Tpetra::CostDescriber<Node> > costs,
00215          int inputType);
00216 
00217 
00220   QueryObject( Teuchos::RCP<const ::Tpetra::RowMatrix<double,int,int,Node> > matrix,
00221          Teuchos::RCP<const Isorropia::Tpetra::CostDescriber<Node> > costs,
00222          int inputType);
00223 
00226   QueryObject( Teuchos::RCP<const ::Tpetra::MultiVector<double,int,int,Node> > coords,
00227                Teuchos::RCP<const ::Tpetra::MultiVector<double,int,int,Node> > weights);
00228 
00229 
00232   QueryObject(Teuchos::RCP<const ::Tpetra::CrsGraph<int,int,Node> > graph,
00233         Teuchos::RCP<const Isorropia::Tpetra::CostDescriber<Node> > costs, 
00234               Teuchos::RCP<const ::Tpetra::MultiVector<double,int,int,Node> > coords,
00235               Teuchos::RCP<const ::Tpetra::MultiVector<double,int,int,Node> > weights,
00236               int inputType);
00237 
00238 
00241   QueryObject(Teuchos::RCP<const ::Tpetra::RowMatrix<double,int,int,Node> > matrix,
00242         Teuchos::RCP<const Isorropia::Tpetra::CostDescriber<Node> > costs,
00243               Teuchos::RCP<const ::Tpetra::MultiVector<double,int,int,Node> > coords,
00244               Teuchos::RCP<const ::Tpetra::MultiVector<double,int,int,Node> > weights,
00245               int inputType);
00246 
00247 
00250   QueryObject( Teuchos::RCP<const ::Tpetra::Map<int,int,Node> > inputMap,
00251          int inputType);
00252 
00253 
00254 
00255 
00258   virtual ~QueryObject();
00259 
00265   static const int hgraph_input_ = 1;
00266 
00271   static const int hgraph2d_finegrain_input_ = 2;
00272 
00278   static const int graph_input_ = 3;
00279 
00286   static const int geometric_input_ = 4;
00287 
00293   static const int hgraph_graph_input_ = 5;
00294 
00300   static const int hgraph_geometric_input_ = 6;
00301 
00308   static const int graph_geometric_input_ = 7;
00309 
00315   static const int hgraph_graph_geometric_input_ = 8;
00316 
00320   static const int simple_input_ = 9;
00321 
00322 
00326   static const int unspecified_input_ = 10;
00327 
00328 
00329 
00335   int input_type_;
00336 
00339   const ::Tpetra::Map<int,int,Node> &RowMap(void){ return *rowMap_;};
00340 
00344   bool haveVertexWeights();
00345 
00349   bool haveGraphEdgeWeights();
00350 
00354   bool haveHypergraphEdgeWeights();
00355 
00356   // General query functions
00357 
00360   static int Number_Objects(void *data, int *ierr);
00361   
00364   static void Object_List  ( void * data, int num_gid_entries, int num_lid_entries,
00365          ZOLTAN_ID_PTR global_ids, ZOLTAN_ID_PTR local_ids,
00366          int weight_dim, float * object_weights, int * ierr );
00367 
00368   // Query functions for graph partitioning only
00369   
00372   static void Number_Edges_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, int * ierr );
00375 
00378   static void Edge_List_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, ZOLTAN_ID_PTR neighbor_global_ids, int * neighbor_procs,
00381          int weight_dim, float * edge_weights, int * ierr );
00382 
00383   // Query functions for hypergraph partitioning only
00384   
00387   static void HG_Size_CS ( void * data, int* num_lists, int* num_pins, int* format,
00388         int * ierr );
00391   static void HG_CS ( void * data, int num_gid_entries, int num_row_or_col, int num_pins,
00392      int format, ZOLTAN_ID_PTR vtxedge_GID, int* vtxedge_ptr, ZOLTAN_ID_PTR pin_GID,
00393                int * ierr );
00396   static void HG_Size_Edge_Weights(void * data, int* num_edges, int* ierr);
00397   
00400   static void HG_Edge_Weights(void * data,
00401         int num_gid_entries, int num_lid_entries, int num_edges, int edge_weight_dim,
00402         ZOLTAN_ID_PTR edge_GID, ZOLTAN_ID_PTR edge_LID, float* edge_weights, int* ierr);
00403 
00406   static int Number_Geom(void *data, int *ierr);
00407 
00410   static void Geom_Multi(void *data, int num_gid_entries, int num_lid_entries,
00411         int num_obj, ZOLTAN_ID_PTR gids, ZOLTAN_ID_PTR lids, int num_dim,
00412         double *geom_vec, int *ierr);
00413 
00414 
00415   //M.M.W. need to add hierarchical query functions
00416 
00417 };
00418 
00419 } //namespace ZoltanLib
00420 } //namespace Tpetra
00421 } //namespace Isorropia
00422 
00423 #endif //ISORROPIA_TPETRA_ZOLTAN_QUERYOBJECT_H