Isorropia: Partitioning, Load Balancing and more
QueryObject.hpp
Go to the documentation of this file.
1 //@HEADER
2 //************************************************************************
3 //
4 // Isorropia: Partitioning and Load Balancing Package
5 // Copyright (2006) Sandia Corporation
6 //
7 //Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 //license for use of this work by or on behalf of the U.S. Government.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 //************************************************************************
38 //@HEADER
39 
40 #ifndef ISORROPIA_EPETRA_ZOLTAN_QUERYOBJECT_H
41 #define ISORROPIA_EPETRA_ZOLTAN_QUERYOBJECT_H
42 
43 #include "Isorropia_ConfigDefs.hpp"
44 
45 #include <Teuchos_RCP.hpp>
46 
47 #include <zoltan_cpp.h>
48 
49 #include <set>
50 #include <map>
51 
52 class Epetra_BlockMap;
53 class Epetra_CrsGraph;
54 class Epetra_RowMatrix;
55 class Epetra_MultiVector;
56 
57 namespace Isorropia {
58 
59 namespace Epetra {
60 
61  class CostDescriber;
62 
70 namespace ZoltanLib {
71 
82 {
83 
87  const bool haveGraph_;
88 
92  Teuchos::RCP<const Epetra_CrsGraph> graph_;
93 
98  Teuchos::RCP<const Epetra_RowMatrix> matrix_;
99 
105  Teuchos::RCP<const Epetra_MultiVector> coords_;
106 
109  const Epetra_BlockMap *rowMap_;
110 
113  const Epetra_BlockMap *colMap_;
114 
119  Teuchos::RCP<const Isorropia::Epetra::CostDescriber> costs_;
120 
126  Teuchos::RCP<const Epetra_MultiVector> weights_;
127 
128  std::map<int,int> procmap_;
129  std::set<int> graph_self_edges_;
130 
131  unsigned int myProc_;
132  unsigned int base_;
133 
134  void fill_procmap();
135 
142  int My_Number_Objects(int *ierr);
143 
147  void My_Object_List (int num_gid_entries, int num_lid_entries,
148  ZOLTAN_ID_PTR global_ids, ZOLTAN_ID_PTR local_ids,
149  int weight_dim, float * object_weights, int * ierr );
150 
155  void My_Number_Edges_Multi (int num_gid_entries, int num_lid_entries,
156  int num_obj, ZOLTAN_ID_PTR global_ids, ZOLTAN_ID_PTR local_ids,
157  int *num_edges, int * ierr );
158 
163  void My_Edge_List_Multi(int num_gid_entries, int num_lid_entries,
164  int num_obj, ZOLTAN_ID_PTR global_ids, ZOLTAN_ID_PTR local_ids,
165  int *num_edges, ZOLTAN_ID_PTR neighbor_global_ids, int * neighbor_procs,
166  int weight_dim, float * edge_weights, int * ierr );
167 
171  void My_HG_Size_CS (int* num_lists, int* num_pins, int* format,
172  int * ierr );
173 
177  void My_HG_CS (int num_gid_entries, int num_row_or_col, int num_pins,
178  int format, ZOLTAN_ID_PTR vtxedge_GID, int* vtxedge_ptr, ZOLTAN_ID_PTR pin_GID,
179  int * ierr );
180 
181 
185  void My_FGHG_CS (int num_gid_entries, int num_row_or_col, int num_pins,
186  int format, ZOLTAN_ID_PTR vtxedge_GID, int* vtxedge_ptr, ZOLTAN_ID_PTR pin_GID,
187  int * ierr );
188 
193  void My_HG_Size_Edge_Weights(int* num_edges, int* ierr);
194 
199  void My_HG_Edge_Weights(int num_gid_entries, int num_lid_entries, int num_edges, int edge_weight_dim,
200  ZOLTAN_ID_PTR edge_GID, ZOLTAN_ID_PTR edge_LID, float* edge_weights, int* ierr);
201 
206  int My_Number_Geom(int *ierr);
207 
211  void My_Geom_Multi(int num_gid_entries, int num_lid_entries,
212  int num_obj, ZOLTAN_ID_PTR gids, ZOLTAN_ID_PTR lids, int num_dim,
213  double *geom_vec, int *ierr);
214 
215  public:
216 
219  QueryObject( Teuchos::RCP<const Epetra_CrsGraph> graph,
220  Teuchos::RCP<const Isorropia::Epetra::CostDescriber> costs,
221  int inputType);
222 
223 
226  QueryObject( Teuchos::RCP<const Epetra_RowMatrix> matrix,
227  Teuchos::RCP<const Isorropia::Epetra::CostDescriber> costs,
228  int inputType);
229 
232  QueryObject( Teuchos::RCP<const Epetra_MultiVector> coords,
233  Teuchos::RCP<const Epetra_MultiVector> weights);
234 
235 
238  QueryObject(Teuchos::RCP<const Epetra_CrsGraph> graph,
239  Teuchos::RCP<const Isorropia::Epetra::CostDescriber> costs,
240  Teuchos::RCP<const Epetra_MultiVector> coords,
241  Teuchos::RCP<const Epetra_MultiVector> weights,
242  int inputType);
243 
244 
247  QueryObject(Teuchos::RCP<const Epetra_RowMatrix> matrix,
248  Teuchos::RCP<const Isorropia::Epetra::CostDescriber> costs,
249  Teuchos::RCP<const Epetra_MultiVector> coords,
250  Teuchos::RCP<const Epetra_MultiVector> weights,
251  int inputType);
252 
253 
256  QueryObject( Teuchos::RCP<const Epetra_BlockMap> inputMap,
257  int inputType);
258 
259 
260 
261 
264  virtual ~QueryObject();
265 
271  static const int hgraph_input_ = 1;
272 
277  static const int hgraph2d_finegrain_input_ = 2;
278 
284  static const int graph_input_ = 3;
285 
292  static const int geometric_input_ = 4;
293 
299  static const int hgraph_graph_input_ = 5;
300 
306  static const int hgraph_geometric_input_ = 6;
307 
314  static const int graph_geometric_input_ = 7;
315 
321  static const int hgraph_graph_geometric_input_ = 8;
322 
326  static const int simple_input_ = 9;
327 
328 
332  static const int unspecified_input_ = 10;
333 
334 
335 
342 
345  const Epetra_BlockMap &RowMap(void){ return *rowMap_;};
346 
350  bool haveVertexWeights();
351 
355  bool haveGraphEdgeWeights();
356 
361 
362  // General query functions
363 
366  static int Number_Objects(void *data, int *ierr);
367 
370  static void Object_List ( void * data, int num_gid_entries, int num_lid_entries,
371  ZOLTAN_ID_PTR global_ids, ZOLTAN_ID_PTR local_ids,
372  int weight_dim, float * object_weights, int * ierr );
373 
374  // Query functions for graph partitioning only
375 
378  static void Number_Edges_Multi ( void * data, int num_gid_entries, int num_lid_entries,
379  int num_obj, ZOLTAN_ID_PTR global_ids, ZOLTAN_ID_PTR local_ids,
380  int *num_edges, int * ierr );
381 
384  static void Edge_List_Multi( void * data, int num_gid_entries, int num_lid_entries,
385  int num_obj, ZOLTAN_ID_PTR global_ids, ZOLTAN_ID_PTR local_ids,
386  int *num_edges, ZOLTAN_ID_PTR neighbor_global_ids, int * neighbor_procs,
387  int weight_dim, float * edge_weights, int * ierr );
388 
389  // Query functions for hypergraph partitioning only
390 
393  static void HG_Size_CS ( void * data, int* num_lists, int* num_pins, int* format,
394  int * ierr );
397  static void HG_CS ( void * data, int num_gid_entries, int num_row_or_col, int num_pins,
398  int format, ZOLTAN_ID_PTR vtxedge_GID, int* vtxedge_ptr, ZOLTAN_ID_PTR pin_GID,
399  int * ierr );
402  static void HG_Size_Edge_Weights(void * data, int* num_edges, int* ierr);
403 
406  static void HG_Edge_Weights(void * data,
407  int num_gid_entries, int num_lid_entries, int num_edges, int edge_weight_dim,
408  ZOLTAN_ID_PTR edge_GID, ZOLTAN_ID_PTR edge_LID, float* edge_weights, int* ierr);
409 
412  static int Number_Geom(void *data, int *ierr);
413 
416  static void Geom_Multi(void *data, int num_gid_entries, int num_lid_entries,
417  int num_obj, ZOLTAN_ID_PTR gids, ZOLTAN_ID_PTR lids, int num_dim,
418  double *geom_vec, int *ierr);
419 
420 
421  //M.M.W. need to add hierarchical query functions
422 
423 };
424 
425 } //namespace ZoltanLib
426 } //namespace Epetra
427 } //namespace Isorropia
428 
429 #endif //ISORROPIA_EPETRA_ZOLTAN_QUERYOBJECT_H
static void HG_CS(void *data, int num_gid_entries, int num_row_or_col, int num_pins, int format, ZOLTAN_ID_PTR vtxedge_GID, int *vtxedge_ptr, ZOLTAN_ID_PTR pin_GID, int *ierr)
The interface to a particular QueryObject&#39;s My_HG_CS query function.
void My_Geom_Multi(int num_gid_entries, int num_lid_entries, int num_obj, ZOLTAN_ID_PTR gids, ZOLTAN_ID_PTR lids, int num_dim, double *geom_vec, int *ierr)
My_Geom_Multi() is a query function used for geometric partitioning only.
QueryObject(Teuchos::RCP< const Epetra_CrsGraph > graph, Teuchos::RCP< const Isorropia::Epetra::CostDescriber > costs, int inputType)
Constructor.
int My_Number_Objects(int *ierr)
My_Number_Objects() returns the number of objects currently assigned to this process.
void My_FGHG_CS(int num_gid_entries, int num_row_or_col, int num_pins, int format, ZOLTAN_ID_PTR vtxedge_GID, int *vtxedge_ptr, ZOLTAN_ID_PTR pin_GID, int *ierr)
My_FGHG_CS() is a query function used for fine-grain hypergraph partitioning only.
void My_HG_Size_Edge_Weights(int *num_edges, int *ierr)
My_HG_Size_Edge_Weights() is a query function used for hypergraph partitioning only.
static void HG_Size_CS(void *data, int *num_lists, int *num_pins, int *format, int *ierr)
The interface to a particular QueryObject&#39;s My_HG_Size_CS query function.
static void Edge_List_Multi(void *data, int num_gid_entries, int num_lid_entries, int num_obj, ZOLTAN_ID_PTR global_ids, ZOLTAN_ID_PTR local_ids, int *num_edges, ZOLTAN_ID_PTR neighbor_global_ids, int *neighbor_procs, int weight_dim, float *edge_weights, int *ierr)
The interface to a particular QueryObject&#39;s My_Edges_Multi query function.
int My_Number_Geom(int *ierr)
My_Number_Geom() is a query function used for geometric partitioning only.
const Epetra_BlockMap & RowMap(void)
Return the map associated with the object to be partitioned.
Definition: QueryObject.hpp:345
unsigned int myProc_
Definition: QueryObject.hpp:131
Teuchos::RCP< const Epetra_MultiVector > weights_
The MultiVector contains optional object (point) weights for geometric partitioning.
Definition: QueryObject.hpp:126
static const int graph_geometric_input_
input_type_ == graph_geometric_input_ This indicates that the Epetra_MultiVector represents graph and...
Definition: QueryObject.hpp:314
static const int simple_input_
input_type_ == simple_input_ This indicates that a simple method (block, cyclic, or random) will be u...
Definition: QueryObject.hpp:326
QueryObject is a class that contains the query functions required by the Zoltan library.
Definition: QueryObject.hpp:81
Teuchos::RCP< const Epetra_MultiVector > coords_
The MultiVector containing 1, 2 or 3 dimensional coordinates.
Definition: QueryObject.hpp:105
static void Object_List(void *data, int num_gid_entries, int num_lid_entries, ZOLTAN_ID_PTR global_ids, ZOLTAN_ID_PTR local_ids, int weight_dim, float *object_weights, int *ierr)
The interface to a particular QueryObject&#39;s My_Object_List query function.
Teuchos::RCP< const Epetra_RowMatrix > matrix_
The CrsMatrix.
Definition: QueryObject.hpp:98
static const int hgraph_graph_input_
input_type_ == hgraph_graph_input_ This indicates that the Epetra_MultiVector represents a hypergraph...
Definition: QueryObject.hpp:299
static const int hgraph2d_finegrain_input_
input_type_ == hgraph2d_finegrain_input_.
Definition: QueryObject.hpp:277
static const int hgraph_input_
input_type_ == hgraph_input_.
Definition: QueryObject.hpp:271
static const int hgraph_graph_geometric_input_
input_type_ == hgraph_graph_geometric_input_ This indicates that the Epetra_MultiVector represents a ...
Definition: QueryObject.hpp:321
static void Geom_Multi(void *data, int num_gid_entries, int num_lid_entries, int num_obj, ZOLTAN_ID_PTR gids, ZOLTAN_ID_PTR lids, int num_dim, double *geom_vec, int *ierr)
The interface to a particular QueryObject&#39;s My_Geom_Multi query function.
unsigned int base_
Definition: QueryObject.hpp:132
static int Number_Objects(void *data, int *ierr)
The interface to a particular QueryObject&#39;s My_Number_Objects query function.
static void HG_Edge_Weights(void *data, int num_gid_entries, int num_lid_entries, int num_edges, int edge_weight_dim, ZOLTAN_ID_PTR edge_GID, ZOLTAN_ID_PTR edge_LID, float *edge_weights, int *ierr)
The interface to a particular QueryObject&#39;s My_HG_Edge_Weights query function.
std::set< int > graph_self_edges_
Definition: QueryObject.hpp:129
void My_Object_List(int num_gid_entries, int num_lid_entries, ZOLTAN_ID_PTR global_ids, ZOLTAN_ID_PTR local_ids, int weight_dim, float *object_weights, int *ierr)
My_ObjectList() returns to Zoltan the global ID and weight of the objects currently assigned to this ...
static const int geometric_input_
input_type_ == geometric_input_.
Definition: QueryObject.hpp:292
static void HG_Size_Edge_Weights(void *data, int *num_edges, int *ierr)
The interface to a particular QueryObject&#39;s My_HG_Size_Edge_Weights query function.
static int Number_Geom(void *data, int *ierr)
The interface to a particular QueryObject&#39;s My_Number_Geom query function.
Teuchos::RCP< const Epetra_CrsGraph > graph_
The CrsGraph.
Definition: QueryObject.hpp:92
int input_type_
The input_type_ indicates how the object to be partitioned is to be interpreted - as a graph or a hyp...
Definition: QueryObject.hpp:341
static void Number_Edges_Multi(void *data, int num_gid_entries, int num_lid_entries, int num_obj, ZOLTAN_ID_PTR global_ids, ZOLTAN_ID_PTR local_ids, int *num_edges, int *ierr)
The interface to a particular QueryObject&#39;s My_Number_Edges_Multi query function. ...
std::map< int, int > procmap_
Definition: QueryObject.hpp:128
const bool haveGraph_
haveGraph is true if we have CrsGraph, and not a CrsMatrix or a MultiVector.
Definition: QueryObject.hpp:87
bool haveVertexWeights()
Return true if any of the processes in the application have defined vertex weights.
const Epetra_BlockMap * colMap_
The graph or matrix column map.
Definition: QueryObject.hpp:113
void My_HG_CS(int num_gid_entries, int num_row_or_col, int num_pins, int format, ZOLTAN_ID_PTR vtxedge_GID, int *vtxedge_ptr, ZOLTAN_ID_PTR pin_GID, int *ierr)
My_HG_CS() is a query function used for hypergraph partitioning only.
const Epetra_BlockMap * rowMap_
The graph or matrix row map, or the MultiVector map.
Definition: QueryObject.hpp:109
static const int unspecified_input_
input_type_ == unspecified_input_.
Definition: QueryObject.hpp:332
void My_HG_Edge_Weights(int num_gid_entries, int num_lid_entries, int num_edges, int edge_weight_dim, ZOLTAN_ID_PTR edge_GID, ZOLTAN_ID_PTR edge_LID, float *edge_weights, int *ierr)
My_HG_Edge_Weights() is a query function used for hypergraph partitioning only.
void My_Edge_List_Multi(int num_gid_entries, int num_lid_entries, int num_obj, ZOLTAN_ID_PTR global_ids, ZOLTAN_ID_PTR local_ids, int *num_edges, ZOLTAN_ID_PTR neighbor_global_ids, int *neighbor_procs, int weight_dim, float *edge_weights, int *ierr)
My_Edge_List_Multi() is a query function used for graph partitioning only.
bool haveHypergraphEdgeWeights()
Return true if any of the processes in the application have defined hypergraph edge weights...
static const int graph_input_
input_type_ == graph_input_.
Definition: QueryObject.hpp:284
Teuchos::RCP< const Isorropia::Epetra::CostDescriber > costs_
The CostDescriber contains optional vertex and/or edge weights for graph and hypergraph partitioning...
Definition: QueryObject.hpp:119
bool haveGraphEdgeWeights()
Return true if any of the processes in the application have defined graph edge weights.
void My_HG_Size_CS(int *num_lists, int *num_pins, int *format, int *ierr)
My_HG_Size_CS() is a query function used for hypergraph partitioning only.
static const int hgraph_geometric_input_
input_type_ == hgraph_geometric_input_ This indicates that the Epetra_MultiVector represents a hyperg...
Definition: QueryObject.hpp:306
void My_Number_Edges_Multi(int num_gid_entries, int num_lid_entries, int num_obj, ZOLTAN_ID_PTR global_ids, ZOLTAN_ID_PTR local_ids, int *num_edges, int *ierr)
My_Number_Edges_Multi() is a query function used for graph partitioning only.