Zoltan2
Zoltan2_CommGraphModel.hpp
Go to the documentation of this file.
1 // @HEADER
2 //
3 // ***********************************************************************
4 //
5 // Zoltan2: A package of combinatorial algorithms for scientific computing
6 // Copyright 2012 Sandia Corporation
7 //
8 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
9 // the U.S. Government retains certain rights in this software.
10 //
11 // Redistribution and use in source and binary forms, with or without
12 // modification, are permitted provided that the following conditions are
13 // met:
14 //
15 // 1. Redistributions of source code must retain the above copyright
16 // notice, this list of conditions and the following disclaimer.
17 //
18 // 2. Redistributions in binary form must reproduce the above copyright
19 // notice, this list of conditions and the following disclaimer in the
20 // documentation and/or other materials provided with the distribution.
21 //
22 // 3. Neither the name of the Corporation nor the names of the
23 // contributors may be used to endorse or promote products derived from
24 // this software without specific prior written permission.
25 //
26 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 //
38 // Questions? Contact Karen Devine (kddevin@sandia.gov)
39 // Erik Boman (egboman@sandia.gov)
40 // Siva Rajamanickam (srajama@sandia.gov)
41 //
42 // ***********************************************************************
43 //
44 // @HEADER
45 
60 #ifndef _ZOLTAN2_COMMGRAPHMODEL_HPP_
61 #define _ZOLTAN2_COMMGRAPHMODEL_HPP_
62 
63 #include <Zoltan2_Model.hpp>
64 #include <Zoltan2_ModelHelpers.hpp>
65 #include <Zoltan2_InputTraits.hpp>
67 #include <Zoltan2_GraphAdapter.hpp>
71 #include <Zoltan2_MeshAdapter.hpp>
72 #include <Zoltan2_StridedData.hpp>
73 #include <unordered_map>
74 
75 namespace Zoltan2 {
76 
78 
90 template <typename Adapter>
91 class CommGraphModel : public Model<Adapter>
92 {
93 public:
94 
95 #ifndef DOXYGEN_SHOULD_SKIP_THIS
96  typedef typename Adapter::scalar_t scalar_t;
97  typedef typename Adapter::gno_t gno_t;
98  typedef typename Adapter::lno_t lno_t;
99  typedef typename Adapter::node_t node_t;
100  typedef typename Adapter::user_t user_t;
101  typedef typename Adapter::userCoord_t userCoord_t;
102  typedef StridedData<lno_t, scalar_t> input_t;
103  typedef typename Adapter::offset_t offset_t;
104 #endif
105 
108 
119  const RCP<const Environment> &env, const RCP<const Comm<int> > &comm)
120  {
121  throw std::runtime_error("CommGraphModel is not implemented for MatrixAdapter yet.");
122  }
123 
124  CommGraphModel(const RCP<const GraphAdapter<user_t,userCoord_t> > &ia,
125  const RCP<const Environment> &env, const RCP<const Comm<int> > &comm);
126 
127  CommGraphModel(const RCP<const MeshAdapter<user_t> > &ia,
128  const RCP<const Environment> &env, const RCP<const Comm<int> > &comm)
129  {
130  throw std::runtime_error("CommGraphModel is not implemented for MeshAdapter yet.");
131  }
132 
133  CommGraphModel(const RCP<const VectorAdapter<userCoord_t> > &/* ia */,
134  const RCP<const Environment> &/* env */, const RCP<const Comm<int> > &/* comm */)
135  {
136  throw std::runtime_error("cannot build CommGraphModel from VectorAdapter");
137  }
138 
140  const RCP<const Environment> &env, const RCP<const Comm<int> > &comm)
141  {
142  throw std::runtime_error("cannot build GraphModel from IdentifierAdapter");
143  }
144 
147  const RCP<const Comm<int> > getComm() { return comm_; }
148 
151  size_t getLocalNumVertices() const { return nLocalVertices_; }
152 
155  size_t getGlobalNumVertices() const { return nGlobalVertices_; }
156 
160  size_t getLocalNumEdges() const { return nLocalEdges_; }
161 
165  size_t getGlobalNumEdges() const { return nGlobalEdges_; }
166 
169  int getNumWeightsPerVertex() const { return nWeightsPerVertex_; }
170 
173  int getNumWeightsPerEdge() const { return nWeightsPerEdge_; }
174 
175 
184  ArrayView<const gno_t> &Ids,
185  ArrayView<input_t> &wgts) const
186  {
187  Ids = vGids_.view(0, nLocalVertices_);
188  wgts = vWeights_.view(0, nWeightsPerVertex_);
189  return nLocalVertices_;
190  }
191 
192  // Implied Vertex LNOs from getVertexList are used as indices to offsets
193  // array.
194  // Vertex GNOs are returned as neighbors in edgeIds.
195 
196  size_t getEdgeList( ArrayView<const gno_t> &edgeIds,
197  ArrayView<const offset_t> &offsets,
198  ArrayView<input_t> &wgts) const
199  {
200  edgeIds = eGids_.view(0, nLocalEdges_);
201  offsets = eOffsets_.view(0, nLocalVertices_+1);
202  wgts = eWeights_.view(0, nWeightsPerEdge_);
203  return nLocalEdges_;
204  }
205 
210  inline void getVertexDist(ArrayView<size_t> &vtxdist) const
211  {
212  vtxdist = vtxDist_();
213  if (vtxDist_.size() == 0) {
214  throw std::runtime_error("getVertexDist is available only "
215  "when consecutiveIdsRequired");
216  }
217  }
218 
220  // The Model interface.
222 
223  size_t getLocalNumObjects() const { return nLocalVertices_; }
224 
225  size_t getGlobalNumObjects() const { return nGlobalVertices_; }
226 
228  // Migration-related functions.
230 
231  int getNumActiveRanks() const { return nActiveRanks_; }
232 
233  int getDestinationRank() const { return destRank_; }
234 
235  int getStartRank() const { return startRank_; }
236 
237  int getEndRank() const { return endRank_; }
238 
239 private:
240 
241  void print(); // For debugging
242  void migrateGraph(); // For debugging
243 
244  const RCP<const Environment > env_;
245  const RCP<const Comm<int> > comm_;
246 
247  int threshold_; // threshold on #vertices each rank stores post-migration
248  int nActiveRanks_ ; // # ranks for the small graph to be partitioned on
249  int destRank_, startRank_, endRank_;
250 
251 
252  size_t nLocalVertices_; // # local vertices in built graph
253  size_t nGlobalVertices_; // # global vertices in built graph
254  ArrayRCP<gno_t> vGids_; // vertices of graph built in model;
255  // may be same as adapter's input
256  // or may be renumbered 0 to (N-1).
257 
258  int nWeightsPerVertex_;
259  ArrayRCP<input_t> vWeights_;
260 
261  // Note: in some cases, size of these arrays
262  // may be larger than nLocalEdges_. So do not use .size().
263  // Use nLocalEdges_, nGlobalEdges_
264 
265  size_t nLocalEdges_; // # local edges in built graph
266  size_t nGlobalEdges_; // # global edges in built graph
267  ArrayRCP<gno_t> eGids_; // edges of graph built in model
268  ArrayRCP<offset_t> eOffsets_; // edge offsets build in model
269  // May be same as adapter's input
270  // or may differ
271  // due to renumbering, self-edge
272  // removal, or local graph.
273 
274  int nWeightsPerEdge_;
275  ArrayRCP<input_t> eWeights_; // edge weights in built graph
276  // May be same as adapter's input
277  // or may differ due to self-edge
278  // removal, or local graph.
279 
280  ArrayRCP<size_t> vtxDist_; // If consecutiveIdsRequired,
281  // vtxDist (as needed by ParMETIS
282  // and Scotch) is also created.
283  // Otherwise, it is Teuchos::null.
284 };
285 
286 
288 // GraphModel from GraphAdapter
289 template <typename Adapter>
291  const RCP<const GraphAdapter<user_t,userCoord_t> > &bia,
292  const RCP<const Environment> &env,
293  const RCP<const Comm<int> > &comm):
294  env_(env),
295  comm_(comm),
296  nLocalVertices_(0),
297  nGlobalVertices_(0),
298  vGids_(),
299  nWeightsPerVertex_(0),
300  vWeights_(),
301  nLocalEdges_(0),
302  nGlobalEdges_(0),
303  eGids_(),
304  eOffsets_(),
305  nWeightsPerEdge_(0),
306  eWeights_(),
307  vtxDist_()
308 {
309  int commSize = comm_->getSize();
310 
311  // Get XpetraCrsGraphAdapter from GraphAdapter
312  RCP<XpetraCrsGraphAdapter<user_t, userCoord_t>> ia;
313  try{
314  RCP<GraphAdapter<user_t, userCoord_t>> tmp =
315  rcp_const_cast<GraphAdapter<user_t, userCoord_t>>(bia);
316  ia = rcp_dynamic_cast<XpetraCrsGraphAdapter<user_t, userCoord_t>>(tmp);
317  }
319 
320  // Get the graph from the input adapter
321  auto inGraph = ia->getXpetraGraph();
322 
323  // Get the importer of the graph
324  auto imp = inGraph->getImporter();
325 
326  // Identify nbor PIDs and number of entries sent per PID
327  std::map<int,double> exportpidmap;
328  auto exportpids = imp->getExportPIDs();
329  size_t nexportpids = imp->getNumExportIDs();
330  for (size_t i = 0; i < nexportpids; i++) {
331  int k = exportpids[i];
332  if (exportpidmap.find(k) != exportpidmap.end())
333  exportpidmap[k] = exportpidmap[k] + 1.;
334  else
335  exportpidmap[k] = 1.;
336  }
337 
338  // Set sizes
339  // There is only one vertex in each rank
340  nLocalVertices_ = 1;
341  nLocalEdges_ = exportpidmap.size();
342 
343  // Allocate space
344  vGids_ = arcp(new gno_t[nLocalVertices_],
345  0, nLocalVertices_, true);
346  eGids_ = arcp(new gno_t[nLocalEdges_],
347  0, nLocalEdges_, true);
348  eOffsets_ = arcp(new offset_t[nLocalVertices_+1],
349  0, nLocalVertices_+1, true);
350  scalar_t *wgts2 = new scalar_t [nLocalEdges_];
351 
352  // Form the vertices
353  vGids_[0] = comm->getRank();
354 
355  // Form the edges
356  size_t ptr = 0;
357  eOffsets_[0] = ptr;
358  for (std::map<int,double>::iterator it = exportpidmap.begin();
359  it != exportpidmap.end(); it++) {
360  eGids_[ptr] = it->first;
361  wgts2[ptr++] = it->second;
362  }
363  eOffsets_[nLocalVertices_] = ptr;
364 
365  // Edge weights
366  nWeightsPerEdge_ = 1;
367  input_t *wgts = new input_t [nWeightsPerEdge_];
368  eWeights_ = arcp(wgts, 0, nWeightsPerEdge_, true);
369 
370  for (int w=0; w < nWeightsPerEdge_; w++){
371  int stride=0;
372  ArrayRCP<const scalar_t> wgtArray = arcp(wgts2, 0, nLocalEdges_, true);
373  eWeights_[w] = input_t(wgtArray, stride);
374  }
375 
376  // Vertex weights
377  nWeightsPerVertex_ = 1;
378  input_t *weightInfo = new input_t [nWeightsPerVertex_];
379 
380  for (int idx=0; idx < nWeightsPerVertex_; idx++){
381  scalar_t *wgt = new scalar_t [nLocalVertices_];
382  wgt[0] = inGraph->getNodeNumEntries();
383  ArrayRCP<const scalar_t> wgtArray = arcp(wgt, 0, nLocalVertices_, true);
384  weightInfo[idx] = input_t(wgtArray, 1);
385  }
386 
387  vWeights_ = arcp<input_t>(weightInfo, 0, nWeightsPerVertex_, true);
388 
389  reduceAll<int, size_t>(*comm_, Teuchos::REDUCE_SUM, 1,
390  &nLocalVertices_, &nGlobalVertices_);
391  reduceAll<int, size_t>(*comm_, Teuchos::REDUCE_SUM, 1,
392  &nLocalEdges_, &nGlobalEdges_);
393 
394  // Build vtxDist_ array starting with vGid on each rank
395  vtxDist_ = arcp(new size_t[commSize+1], 0, commSize+1, true);
396  vtxDist_[0] = 0;
397  Teuchos::gatherAll(*comm_, 1, &nLocalVertices_, commSize, &vtxDist_[1]);
398  for (int i = 0; i < commSize; i++)
399  vtxDist_[i+1] += vtxDist_[i];
400 
401  // Migrate the quotient graph into smaller number of MPI ranks (active ranks)
402  migrateGraph();
403 }
404 
405 template <typename Adapter>
407 {
408 
409  // Set default threshold for migration
410  threshold_ = 1024;
411 
412  // Check if the user set the threshold value
413  const ParameterList &pl = env_->getParameters();
414  const Teuchos::ParameterEntry *pe = pl.getEntryPtr("quotient_threshold");
415  if (pe)
416  threshold_ = pe->getValue<int>(&threshold_);
417 
418  // Compute the sizes of/in the new distribution
419  nActiveRanks_ = std::ceil((double) nGlobalVertices_ / threshold_);
420  size_t avgVertexShare = nGlobalVertices_ / nActiveRanks_;
421  size_t myVertexShare = 0;
422 
423  int me = comm_->getRank();
424  int commSize = comm_->getSize();
425 
426  // Save the original pointers
427  ArrayRCP<offset_t> old_eOffsets_ = eOffsets_;
428  ArrayRCP<gno_t> old_eGids_ = eGids_;
429  size_t old_nLocalEdges_ = nLocalEdges_;
430  ArrayRCP<input_t> old_vWeights_ = vWeights_;
431  ArrayRCP<input_t> old_eWeights_ = eWeights_;
432 
433  // Compute whom to send to
434  destRank_ = me / (int) avgVertexShare;
435  if(destRank_ >= nActiveRanks_)
436  destRank_ = nActiveRanks_ - 1;
437 
438  // Start with sending the size of the edge list
439  RCP<CommRequest<int>> *requests;
440  if(me < nActiveRanks_) {
441 
442  // Determine the range of ranks to receive edges from
443  // Needs to be updated when chunks are introduced
444  startRank_ = me * static_cast<int>(avgVertexShare);
445  endRank_ = (me+1) * static_cast<int>(avgVertexShare);
446  if(me == nActiveRanks_ - 1 ) // Last rank gets the surplus
447  endRank_ = static_cast<int>(nGlobalVertices_);
448  myVertexShare = endRank_ - startRank_;
449 
450  eOffsets_ = arcp(new offset_t[myVertexShare+1], 0, myVertexShare+1, true);
451  eOffsets_[0] = 0;
452 
453  // Receive the sizes of their edge list
454  requests = new RCP<CommRequest<int>>[myVertexShare];
455  for(int i = startRank_; i < endRank_; i++) {
456  requests[i-startRank_] = Teuchos::ireceive<int, offset_t>(*comm_,
457  arcp(&eOffsets_[i-startRank_+1], 0, 1, false),
458  i);
459  }
460 
461  // Send adjacency size even though this rank will remain active
462  Teuchos::send<int, offset_t>(*comm_, 1, &old_eOffsets_[nLocalVertices_], destRank_);
463 
464  // Wait
465  Teuchos::waitAll<int>(*comm_, Teuchos::arrayView(requests, myVertexShare));
466 
467  // Prefix sum over the offsets
468  for(size_t i = 1; i <= myVertexShare; i++)
469  eOffsets_[i] += eOffsets_[i-1];
470 
471  // Recompute the number of local edges
472  nLocalEdges_ = eOffsets_[myVertexShare];
473 
474  // Reallocate the adjacency array
475  eGids_ = arcp(new gno_t[nLocalEdges_], 0, nLocalEdges_, true);
476 
477 
478  // Receive the adjacency lists
479  for(int i = startRank_; i < endRank_; i++) {
480  offset_t adjStartRank_ = eOffsets_[i-startRank_];
481  offset_t adjSize = eOffsets_[i-startRank_+1] - adjStartRank_;
482  requests[i-startRank_] = Teuchos::ireceive<int, gno_t>(*comm_,
483  arcp(&eGids_[adjStartRank_], 0, adjSize, false),
484  i);
485  }
486 
487  // Send adjacency even though this rank will remain active
488  Teuchos::send<int, gno_t>(*comm_, old_nLocalEdges_, &old_eGids_[0], destRank_);
489  Teuchos::waitAll<int>(*comm_, Teuchos::arrayView(requests, myVertexShare));
490 
491 
492  // Migrate vertex weights arrays
493  scalar_t *wgts = new scalar_t [myVertexShare];
494  for(int i = startRank_; i < endRank_; i++) {
495  requests[i-startRank_] = Teuchos::ireceive<int, scalar_t>(*comm_,
496  arcp(&wgts[i-startRank_], 0, 1, false), // assumes one vertex per rank
497  i);
498  }
499 
500  const scalar_t *wPtr;
501  size_t wLen = 0;
502  int stride = 0;
503  old_vWeights_[0].getStridedList(wLen, wPtr, stride);
504  Teuchos::send<int, scalar_t>(*comm_, nLocalVertices_, wPtr, destRank_);
505 
506  Teuchos::waitAll<int>(*comm_, Teuchos::arrayView(requests, myVertexShare));
507 
508  input_t *weightInfo = new input_t [nWeightsPerVertex_];
509  for (int idx=0; idx < nWeightsPerVertex_; idx++){
510  ArrayRCP<const scalar_t> wgtArray = arcp(wgts, 0, myVertexShare, true);
511  weightInfo[idx] = input_t(wgtArray, 1);
512  }
513  vWeights_ = arcp<input_t>(weightInfo, 0, nWeightsPerVertex_, true);
514 
515  // Migrate edge weights arrays
516  scalar_t *ewgts = new scalar_t [nLocalEdges_];
517  for(int i = startRank_; i < endRank_; i++) {
518  offset_t adjStartRank_ = eOffsets_[i-startRank_];
519  offset_t adjSize = eOffsets_[i-startRank_+1] - adjStartRank_;
520  requests[i-startRank_] = Teuchos::ireceive<int, scalar_t>(*comm_,
521  arcp(&ewgts[adjStartRank_], 0, adjSize, false), // assumes one vertex per rank
522  i);
523  }
524 
525  old_eWeights_[0].getStridedList(wLen, wPtr, stride);
526  Teuchos::send<int, scalar_t>(*comm_, old_nLocalEdges_, wPtr, destRank_);
527 
528  Teuchos::waitAll<int>(*comm_, Teuchos::arrayView(requests, myVertexShare));
529 
530  input_t *eweightInfo = new input_t [nWeightsPerEdge_];
531  for (int idx=0; idx < nWeightsPerEdge_; idx++){
532  ArrayRCP<const scalar_t> ewgtArray = arcp(ewgts, 0, nLocalEdges_, true);
533  eweightInfo[idx] = input_t(ewgtArray, 1);
534  }
535  eWeights_ = arcp<input_t>(eweightInfo, 0, nWeightsPerEdge_, true);
536 
537 
538  // Finalize the migration
539  vGids_ = arcp(new gno_t[myVertexShare], 0, myVertexShare, true);
540  for(int i = startRank_; i < endRank_; i++)
541  vGids_[i-startRank_] = i;
542 
543  nLocalVertices_ = myVertexShare;
544 
545 
546  }
547  else {
548 
549  // Send adjacency size
550  Teuchos::send<int, offset_t>(*comm_, 1, &eOffsets_[nLocalVertices_], destRank_);
551 
552  // Send adjacency list
553  Teuchos::send<int, gno_t>(*comm_, nLocalEdges_, &eGids_[0], destRank_);
554 
555  // Send vertex weights list
556  const scalar_t *wPtr;
557  size_t wLen = 0;
558  int stride = 0;
559  vWeights_[0].getStridedList(wLen, wPtr, stride);
560  Teuchos::send<int, scalar_t>(*comm_, nLocalVertices_, wPtr, destRank_);
561 
562  // Send edge weights list
563  eWeights_[0].getStridedList(wLen, wPtr, stride);
564  Teuchos::send<int, scalar_t>(*comm_, nLocalEdges_, wPtr, destRank_);
565 
566  nLocalVertices_ = 0;
567  }
568 
569  for (int i = 0; i <= commSize; i++)
570  vtxDist_[i] = 0;
571 
572  Teuchos::gatherAll(*comm_, 1, &nLocalVertices_, commSize, &vtxDist_[1]);
573  for (int i = 0; i < commSize; i++)
574  vtxDist_[i+1] += vtxDist_[i];
575 
576 }
577 
579 template <typename Adapter>
580 void CommGraphModel<Adapter>::print()
581 {
582  std::ostream *os = env_->getDebugOStream();
583 
584  int me = comm_->getRank();
585 
586  *os << me
587  << " Nvtx " << nLocalVertices_
588  << " Nedge " << nLocalEdges_
589  << " NVWgt " << nWeightsPerVertex_
590  << " NEWgt " << nWeightsPerEdge_
591  << std::endl;
592 
593  for (size_t i = 0; i < nLocalVertices_; i++) {
594  *os << me << " " << i << " GID " << vGids_[i] << ": ";
595  for (offset_t j = eOffsets_[i]; j < eOffsets_[i+1]; j++)
596  *os << eGids_[j] << " " ;
597  *os << std::endl;
598  }
599 
600  if (nWeightsPerVertex_) {
601  for (size_t i = 0; i < nLocalVertices_; i++) {
602  *os << me << " " << i << " VWGTS " << vGids_[i] << ": ";
603  for (int j = 0; j < nWeightsPerVertex_; j++)
604  *os << vWeights_[j][i] << " ";
605  *os << std::endl;
606  }
607  }
608 
609  if (nWeightsPerEdge_) {
610  for (size_t i = 0; i < nLocalVertices_; i++) {
611  *os << me << " " << i << " EWGTS " << vGids_[i] << ": ";
612  for (offset_t j = eOffsets_[i]; j < eOffsets_[i+1]; j++) {
613  *os << eGids_[j] << " (";
614  for (int w = 0; w < nWeightsPerEdge_; w++)
615  *os << eWeights_[w][j] << " ";
616  *os << ") ";
617  }
618  *os << std::endl;
619  }
620  }
621 
622 }
623 
624 } // namespace Zoltan2
625 
626 
627 #endif
628 
Zoltan2::BasicUserTypes< zscalar_t, zlno_t, zgno_t > user_t
Definition: Metric.cpp:74
#define Z2_FORWARD_EXCEPTIONS
Forward an exception back through call stack.
Defines the GraphAdapter interface.
Defines the IdentifierAdapter interface.
Traits for application input objects.
Defines the MatrixAdapter interface.
Defines the MeshAdapter interface.
Defines helper functions for use in the models.
Defines the Model interface.
This file defines the StridedData class.
Defines the VectorAdapter interface.
Defines XpetraCrsGraphAdapter class.
CommGraphModel defines the interface required for communication graph.
CommGraphModel(const RCP< const VectorAdapter< userCoord_t > > &, const RCP< const Environment > &, const RCP< const Comm< int > > &)
size_t getVertexList(ArrayView< const gno_t > &Ids, ArrayView< input_t > &wgts) const
Sets pointers to this process' vertex Ids and their weights.
size_t getGlobalNumEdges() const
Returns the global number edges. For local graphs, the number of global edges is the number of local ...
size_t getGlobalNumObjects() const
Return the global number of objects.
size_t getLocalNumEdges() const
Returns the number of edges on this process. In global or subset graphs, includes off-process edges.
size_t getLocalNumVertices() const
Returns the number vertices on this process.
int getNumWeightsPerEdge() const
Returns the number (0 or greater) of weights per edge.
CommGraphModel(const RCP< const MatrixAdapter< user_t, userCoord_t > > &ia, const RCP< const Environment > &env, const RCP< const Comm< int > > &comm)
Constructor.
void getVertexDist(ArrayView< size_t > &vtxdist) const
Return the vtxDist array Array of size comm->getSize() + 1 Array[n+1] - Array[n] is number of vertice...
CommGraphModel(const RCP< const IdentifierAdapter< user_t > > &ia, const RCP< const Environment > &env, const RCP< const Comm< int > > &comm)
size_t getGlobalNumVertices() const
Returns the global number vertices.
CommGraphModel(const RCP< const MeshAdapter< user_t > > &ia, const RCP< const Environment > &env, const RCP< const Comm< int > > &comm)
const RCP< const Comm< int > > getComm()
Return the communicator used by the model.
int getNumWeightsPerVertex() const
Returns the number (0 or greater) of weights per vertex.
size_t getLocalNumObjects() const
Return the local number of objects.
size_t getEdgeList(ArrayView< const gno_t > &edgeIds, ArrayView< const offset_t > &offsets, ArrayView< input_t > &wgts) const
GraphAdapter defines the interface for graph-based user data.
IdentifierAdapter defines the interface for identifiers.
MatrixAdapter defines the adapter interface for matrices.
MeshAdapter defines the interface for mesh input.
The base class for all model classes.
The StridedData class manages lists of weights or coordinates.
VectorAdapter defines the interface for vector input.
map_t::local_ordinal_type lno_t
Definition: mapRemotes.cpp:17
map_t::global_ordinal_type gno_t
Definition: mapRemotes.cpp:18
Created by mbenlioglu on Aug 31, 2020.