Isorropia: Partitioning, Load Balancing and more
Isorropia_TpetraQueryObject.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_TPETRA_ZOLTAN_QUERYOBJECT_H
41 #define ISORROPIA_TPETRA_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 
53 #include <Kokkos_DefaultNode.hpp>
54 #include <Tpetra_CrsGraph_decl.hpp>
55 #include <Tpetra_RowMatrix.hpp>
56 #include <Tpetra_MultiVector_decl.hpp>
57 
59 
60 namespace Isorropia {
61 
62 namespace Tpetra {
63 
64 
65 
73 namespace ZoltanLib {
74 
86 template <typename Node = ::Tpetra::Map<int,int>::node_type >
88 {
89 
93  const bool haveGraph_;
94 
98  Teuchos::RCP<const ::Tpetra::CrsGraph<int,int,Node> > graph_;
99 
104  Teuchos::RCP<const ::Tpetra::RowMatrix<double,int,int,Node> > matrix_;
105 
111  Teuchos::RCP<const ::Tpetra::MultiVector<double,int,int,Node> > coords_;
112 
115  const ::Tpetra::Map<int,int,Node> *rowMap_;
116 
119  const ::Tpetra::Map<int,int,Node> *colMap_;
120 
125  Teuchos::RCP<const Isorropia::Tpetra::CostDescriber<Node> > costs_;
126 
132  Teuchos::RCP<const ::Tpetra::MultiVector<double,int,int,Node> > weights_;
133 
134  std::map<int,int> procmap_;
135  std::set<int> graph_self_edges_;
136 
137  int myProc_;
138  int base_;
139 
140  void fill_procmap();
141 
148  int My_Number_Objects(int *ierr);
149 
153  void My_Object_List (int num_gid_entries, int num_lid_entries,
154  ZOLTAN_ID_PTR global_ids, ZOLTAN_ID_PTR local_ids,
155  int weight_dim, float * object_weights, int * ierr );
156 
161  void My_Number_Edges_Multi (int num_gid_entries, int num_lid_entries,
162  int num_obj, ZOLTAN_ID_PTR global_ids, ZOLTAN_ID_PTR local_ids,
163  int *num_edges, int * ierr );
164 
169  void My_Edge_List_Multi(int num_gid_entries, int num_lid_entries,
170  int num_obj, ZOLTAN_ID_PTR global_ids, ZOLTAN_ID_PTR local_ids,
171  int *num_edges, ZOLTAN_ID_PTR neighbor_global_ids, int * neighbor_procs,
172  int weight_dim, float * edge_weights, int * ierr );
173 
177  void My_HG_Size_CS (int* num_lists, int* num_pins, int* format,
178  int * ierr );
179 
183  void My_HG_CS (int num_gid_entries, int num_row_or_col, int num_pins,
184  int format, ZOLTAN_ID_PTR vtxedge_GID, int* vtxedge_ptr, ZOLTAN_ID_PTR pin_GID,
185  int * ierr );
186 
187 
191  void My_FGHG_CS (int num_gid_entries, int num_row_or_col, int num_pins,
192  int format, ZOLTAN_ID_PTR vtxedge_GID, int* vtxedge_ptr, ZOLTAN_ID_PTR pin_GID,
193  int * ierr );
194 
199  void My_HG_Size_Edge_Weights(int* num_edges, int* ierr);
200 
205  void My_HG_Edge_Weights(int num_gid_entries, int num_lid_entries, int num_edges, int edge_weight_dim,
206  ZOLTAN_ID_PTR edge_GID, ZOLTAN_ID_PTR edge_LID, float* edge_weights, int* ierr);
207 
212  int My_Number_Geom(int *ierr);
213 
217  void My_Geom_Multi(int num_gid_entries, int num_lid_entries,
218  int num_obj, ZOLTAN_ID_PTR gids, ZOLTAN_ID_PTR lids, int num_dim,
219  double *geom_vec, int *ierr);
220 
221  public:
222 
225  QueryObject( Teuchos::RCP<const ::Tpetra::CrsGraph<int,int,Node> > graph,
226  Teuchos::RCP<const Isorropia::Tpetra::CostDescriber<Node> > costs,
227  int inputType);
228 
229 
232  QueryObject( Teuchos::RCP<const ::Tpetra::RowMatrix<double,int,int,Node> > matrix,
233  Teuchos::RCP<const Isorropia::Tpetra::CostDescriber<Node> > costs,
234  int inputType);
235 
238  QueryObject( Teuchos::RCP<const ::Tpetra::MultiVector<double,int,int,Node> > coords,
239  Teuchos::RCP<const ::Tpetra::MultiVector<double,int,int,Node> > weights);
240 
241 
244  QueryObject(Teuchos::RCP<const ::Tpetra::CrsGraph<int,int,Node> > graph,
245  Teuchos::RCP<const Isorropia::Tpetra::CostDescriber<Node> > costs,
246  Teuchos::RCP<const ::Tpetra::MultiVector<double,int,int,Node> > coords,
247  Teuchos::RCP<const ::Tpetra::MultiVector<double,int,int,Node> > weights,
248  int inputType);
249 
250 
253  QueryObject(Teuchos::RCP<const ::Tpetra::RowMatrix<double,int,int,Node> > matrix,
254  Teuchos::RCP<const Isorropia::Tpetra::CostDescriber<Node> > costs,
255  Teuchos::RCP<const ::Tpetra::MultiVector<double,int,int,Node> > coords,
256  Teuchos::RCP<const ::Tpetra::MultiVector<double,int,int,Node> > weights,
257  int inputType);
258 
259 
262  QueryObject( Teuchos::RCP<const ::Tpetra::Map<int,int,Node> > inputMap,
263  int inputType);
264 
265 
266 
267 
270  virtual ~QueryObject();
271 
277  static const int hgraph_input_ = 1;
278 
283  static const int hgraph2d_finegrain_input_ = 2;
284 
290  static const int graph_input_ = 3;
291 
298  static const int geometric_input_ = 4;
299 
305  static const int hgraph_graph_input_ = 5;
306 
312  static const int hgraph_geometric_input_ = 6;
313 
320  static const int graph_geometric_input_ = 7;
321 
327  static const int hgraph_graph_geometric_input_ = 8;
328 
332  static const int simple_input_ = 9;
333 
334 
338  static const int unspecified_input_ = 10;
339 
340 
341 
348 
351  const ::Tpetra::Map<int,int,Node> &RowMap(void){ return *rowMap_;};
352 
356  bool haveVertexWeights();
357 
361  bool haveGraphEdgeWeights();
362 
367 
368  // General query functions
369 
372  static int Number_Objects(void *data, int *ierr);
373 
376  static void Object_List ( void * data, int num_gid_entries, int num_lid_entries,
377  ZOLTAN_ID_PTR global_ids, ZOLTAN_ID_PTR local_ids,
378  int weight_dim, float * object_weights, int * ierr );
379 
380  // Query functions for graph partitioning only
381 
384  static void Number_Edges_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, int * ierr );
387 
390  static void Edge_List_Multi( void * data, int num_gid_entries, int num_lid_entries,
391  int num_obj, ZOLTAN_ID_PTR global_ids, ZOLTAN_ID_PTR local_ids,
392  int *num_edges, ZOLTAN_ID_PTR neighbor_global_ids, int * neighbor_procs,
393  int weight_dim, float * edge_weights, int * ierr );
394 
395  // Query functions for hypergraph partitioning only
396 
399  static void HG_Size_CS ( void * data, int* num_lists, int* num_pins, int* format,
400  int * ierr );
403  static void HG_CS ( void * data, int num_gid_entries, int num_row_or_col, int num_pins,
404  int format, ZOLTAN_ID_PTR vtxedge_GID, int* vtxedge_ptr, ZOLTAN_ID_PTR pin_GID,
405  int * ierr );
408  static void HG_Size_Edge_Weights(void * data, int* num_edges, int* ierr);
409 
412  static void HG_Edge_Weights(void * data,
413  int num_gid_entries, int num_lid_entries, int num_edges, int edge_weight_dim,
414  ZOLTAN_ID_PTR edge_GID, ZOLTAN_ID_PTR edge_LID, float* edge_weights, int* ierr);
415 
418  static int Number_Geom(void *data, int *ierr);
419 
422  static void Geom_Multi(void *data, int num_gid_entries, int num_lid_entries,
423  int num_obj, ZOLTAN_ID_PTR gids, ZOLTAN_ID_PTR lids, int num_dim,
424  double *geom_vec, int *ierr);
425 
426 
427  //M.M.W. need to add hierarchical query functions
428 
429 };
430 
431 } //namespace ZoltanLib
432 } //namespace Tpetra
433 } //namespace Isorropia
434 
435 #endif //ISORROPIA_TPETRA_ZOLTAN_QUERYOBJECT_H
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.
static const int simple_input_
input_type_ == simple_input_ This indicates that a simple method (block, cyclic, or random) will be u...
Definition: Isorropia_TpetraQueryObject.hpp:332
bool haveGraphEdgeWeights()
Return true if any of the processes in the application have defined graph edge weights.
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.
int input_type_
The input_type_ indicates how the object to be partitioned is to be interpreted - as a graph or a hyp...
Definition: Isorropia_TpetraQueryObject.hpp:347
static const int graph_input_
input_type_ == graph_input_.
Definition: Isorropia_TpetraQueryObject.hpp:290
int My_Number_Objects(int *ierr)
My_Number_Objects() returns the number of objects currently assigned to this process.
Isorropia is the namespace that contains general definitions that apply to all partitioners and that ...
Definition: Isorropia_Epetra.hpp:60
QueryObject(Teuchos::RCP< const ::Tpetra::CrsGraph< int, int, Node > > graph, Teuchos::RCP< const Isorropia::Tpetra::CostDescriber< Node > > costs, int inputType)
Constructor.
bool haveVertexWeights()
Return true if any of the processes in the application have defined vertex weights.
static int Number_Objects(void *data, int *ierr)
The interface to a particular QueryObject&#39;s My_Number_Objects query function.
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.
const ::Tpetra::Map< int, int, Node > * rowMap_
The graph or matrix row map, or the MultiVector map.
Definition: Isorropia_TpetraQueryObject.hpp:115
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.
static const int geometric_input_
input_type_ == geometric_input_.
Definition: Isorropia_TpetraQueryObject.hpp:298
const bool haveGraph_
haveGraph is true if we have CrsGraph, and not a CrsMatrix or a MultiVector.
Definition: Isorropia_TpetraQueryObject.hpp:93
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 graph_geometric_input_
input_type_ == graph_geometric_input_ This indicates that the Tpetra::MultiVector represents graph an...
Definition: Isorropia_TpetraQueryObject.hpp:320
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.
Teuchos::RCP< const Isorropia::Tpetra::CostDescriber< Node > > costs_
The CostDescriber contains optional vertex and/or edge weights for graph and hypergraph partitioning...
Definition: Isorropia_TpetraQueryObject.hpp:125
static int Number_Geom(void *data, int *ierr)
The interface to a particular QueryObject&#39;s My_Number_Geom query function.
int My_Number_Geom(int *ierr)
My_Number_Geom() is a query function used for geometric partitioning only.
std::set< int > graph_self_edges_
Definition: Isorropia_TpetraQueryObject.hpp:135
std::map< int, int > procmap_
Definition: Isorropia_TpetraQueryObject.hpp:134
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 const int hgraph_geometric_input_
input_type_ == hgraph_geometric_input_ This indicates that the Tpetra::MultiVector represents a hyper...
Definition: Isorropia_TpetraQueryObject.hpp:312
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.
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.
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 const int hgraph_graph_input_
input_type_ == hgraph_graph_input_ This indicates that the Tpetra::MultiVector represents a hypergrap...
Definition: Isorropia_TpetraQueryObject.hpp:305
QueryObject is a class that contains the query functions required by the Zoltan library.
Definition: Isorropia_TpetraQueryObject.hpp:87
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. ...
static const int unspecified_input_
input_type_ == unspecified_input_.
Definition: Isorropia_TpetraQueryObject.hpp:338
bool haveHypergraphEdgeWeights()
Return true if any of the processes in the application have defined hypergraph edge weights...
int myProc_
Definition: Isorropia_TpetraQueryObject.hpp:137
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.
int base_
Definition: Isorropia_TpetraQueryObject.hpp:138
const ::Tpetra::Map< int, int, Node > * colMap_
The graph or matrix column map.
Definition: Isorropia_TpetraQueryObject.hpp:119
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.
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.
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.
static const int hgraph_graph_geometric_input_
input_type_ == hgraph_graph_geometric_input_ This indicates that the Tpetra::MultiVector represents a...
Definition: Isorropia_TpetraQueryObject.hpp:327
Teuchos::RCP< const ::Tpetra::RowMatrix< double, int, int, Node > > matrix_
The CrsMatrix.
Definition: Isorropia_TpetraQueryObject.hpp:104
const ::Tpetra::Map< int, int, Node > & RowMap(void)
Return the map associated with the object to be partitioned.
Definition: Isorropia_TpetraQueryObject.hpp:351
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.
static const int hgraph_input_
input_type_ == hgraph_input_.
Definition: Isorropia_TpetraQueryObject.hpp:277
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 ...
Teuchos::RCP< const ::Tpetra::MultiVector< double, int, int, Node > > weights_
The MultiVector contains optional object (point) weights for geometric partitioning.
Definition: Isorropia_TpetraQueryObject.hpp:132
Teuchos::RCP< const ::Tpetra::CrsGraph< int, int, Node > > graph_
The CrsGraph.
Definition: Isorropia_TpetraQueryObject.hpp:98
static const int hgraph2d_finegrain_input_
input_type_ == hgraph2d_finegrain_input_.
Definition: Isorropia_TpetraQueryObject.hpp:283
Teuchos::RCP< const ::Tpetra::MultiVector< double, int, int, Node > > coords_
The MultiVector containing 1, 2 or 3 dimensional coordinates.
Definition: Isorropia_TpetraQueryObject.hpp:111