Zoltan2
Loading...
Searching...
No Matches
Zoltan2_TpetraRowGraphAdapter.hpp
Go to the documentation of this file.
1// @HEADER
2// *****************************************************************************
3// Zoltan2: A package of combinatorial algorithms for scientific computing
4//
5// Copyright 2012 NTESS and the Zoltan2 contributors.
6// SPDX-License-Identifier: BSD-3-Clause
7// *****************************************************************************
8// @HEADER
9
14#ifndef _ZOLTAN2_TPETRAROWGRAPHADAPTER_HPP_
15#define _ZOLTAN2_TPETRAROWGRAPHADAPTER_HPP_
16
17#include "Kokkos_DualView.hpp"
18#include "Kokkos_UnorderedMap.hpp"
19#include <Tpetra_RowGraph.hpp>
23#include <string>
24
25namespace Zoltan2 {
26
48template <typename User, typename UserCoord = User>
49class TpetraRowGraphAdapter : public GraphAdapter<User, UserCoord> {
50
51public:
52#ifndef DOXYGEN_SHOULD_SKIP_THIS
55 using lno_t = typename InputTraits<User>::lno_t;
56 using gno_t = typename InputTraits<User>::gno_t;
57 using part_t = typename InputTraits<User>::part_t;
58 using node_t = typename InputTraits<User>::node_t;
59 using user_t = User;
60 using userCoord_t = UserCoord;
61
63#endif
64
74 TpetraRowGraphAdapter(const RCP<const User> &ingraph, int nVtxWeights = 0,
75 int nEdgeWeights = 0);
76
89 void setWeights(const scalar_t *val, int stride, int idx);
90
99 void setWeightsDevice(typename Base::ConstWeightsDeviceView1D val, int idx);
100
109 void setWeightsHost(typename Base::ConstWeightsHostView1D val, int idx);
110
126 void setVertexWeights(const scalar_t *val, int stride, int idx);
127
139 void setVertexWeightsDevice(typename Base::ConstWeightsDeviceView1D val,
140 int idx);
141
153 void setVertexWeightsHost(typename Base::ConstWeightsHostView1D val, int idx);
154
160 void setWeightIsDegree(int idx);
161
168
191 void setEdgeWeights(const scalar_t *val, int stride, int idx);
192
198 void setEdgeWeightsDevice(typename Base::ConstWeightsDeviceView1D val,
199 int idx);
200
206 void setEdgeWeightsHost(typename Base::ConstWeightsHostView1D val, int idx);
207
209 // The GraphAdapter interface.
211
212 // TODO: Assuming rows == objects;
213 // TODO: Need to add option for columns or nonzeros?
214 size_t getLocalNumVertices() const override;
215
216 void getVertexIDsView(const gno_t *&ids) const override;
217
218 void
219 getVertexIDsDeviceView(typename Base::ConstIdsDeviceView &ids) const override;
220
221 void
222 getVertexIDsHostView(typename Base::ConstIdsHostView &ids) const override;
223
224 size_t getLocalNumEdges() const override;
225
226 void getEdgesView(const offset_t *&offsets,
227 const gno_t *&adjIds) const override;
228
229 void
230 getEdgesDeviceView(typename Base::ConstOffsetsDeviceView &offsets,
231 typename Base::ConstIdsDeviceView &adjIds) const override;
232
233 void getEdgesHostView(typename Base::ConstOffsetsHostView &offsets,
234 typename Base::ConstIdsHostView &adjIds) const override;
235
236 int getNumWeightsPerVertex() const override;
237
238 void getVertexWeightsView(const scalar_t *&weights, int &stride,
239 int idx) const override;
240
241 void getVertexWeightsDeviceView(typename Base::WeightsDeviceView1D &weights,
242 int idx = 0) const override;
243
245 typename Base::WeightsDeviceView &weights) const override;
246
247 void getVertexWeightsHostView(typename Base::WeightsHostView1D &weights,
248 int idx = 0) const override;
249
251 typename Base::WeightsHostView &weights) const override;
252
253 bool useDegreeAsVertexWeight(int idx) const override;
254
255 int getNumWeightsPerEdge() const override;
256
257 void getEdgeWeightsView(const scalar_t *&weights, int &stride,
258 int idx) const override;
259
260 void getEdgeWeightsDeviceView(typename Base::WeightsDeviceView1D &weights,
261 int idx = 0) const override;
262
264 typename Base::WeightsDeviceView &weights) const override;
265
266 void getEdgeWeightsHostView(typename Base::WeightsHostView1D &weights,
267 int idx = 0) const override;
268
270 typename Base::WeightsHostView &weights) const override;
271
272 template <typename Adapter>
274 const User &in, User *&out,
275 const PartitioningSolution<Adapter> &solution) const;
276
277 template <typename Adapter>
279 const User &in, RCP<User> &out,
280 const PartitioningSolution<Adapter> &solution) const;
281
282protected:
283 // Useb by TpetraCrsGraphAdapter
284 TpetraRowGraphAdapter(int nVtxWgts, int nEdgeWgts,
285 const RCP<const User> &graph)
286 : graph_(graph), nWeightsPerVertex_(nVtxWgts),
287 nWeightsPerEdge_(nEdgeWgts) {}
288
289 RCP<const User> graph_;
290
291 typename Base::ConstOffsetsHostView offsHost_;
292 typename Base::ConstIdsHostView adjIdsHost_;
293
294 typename Base::ConstIdsDeviceView adjIdsDevice_;
295 typename Base::ConstOffsetsDeviceView offsDevice_;
296
298 ArrayRCP<StridedData<lno_t, scalar_t>> vertexWeights_;
299 typename Base::WeightsDeviceView vertexWeightsDevice_;
300 typename Base::VtxDegreeHostView vertexDegreeWeightsHost_;
301
303 ArrayRCP<StridedData<lno_t, scalar_t>> edgeWeights_;
304 typename Base::WeightsDeviceView edgeWeightsDevice_;
305
306 virtual RCP<User> doMigration(const User &from, size_t numLocalRows,
307 const gno_t *myNewRows) const;
308};
309
311// Definitions
313
314template <typename User, typename UserCoord>
316 const RCP<const User> &ingraph, int nVtxWgts, int nEdgeWgts)
317 : graph_(ingraph), nWeightsPerVertex_(nVtxWgts),
318 nWeightsPerEdge_(nEdgeWgts), edgeWeights_() {
319 using strided_t = StridedData<lno_t, scalar_t>;
320 using localInds_t = typename User::nonconst_local_inds_host_view_type;
321
322 const auto nvtx = graph_->getLocalNumRows();
323 const auto nedges = graph_->getLocalNumEntries();
324 // Diff from CrsMatrix
325 const auto maxNumEntries = graph_->getLocalMaxNumRowEntries();
326
327 // Unfortunately we have to copy the offsets and edge Ids
328 // because edge Ids are not usually stored in vertex id order.
329
330 adjIdsHost_ = typename Base::ConstIdsHostView("adjIdsHost_", nedges);
331 offsHost_ = typename Base::ConstOffsetsHostView("offsHost_", nvtx + 1);
332
333 localInds_t nbors("nbors", maxNumEntries);
334
335 for (size_t v = 0; v < nvtx; v++) {
336 size_t numColInds = 0;
337 graph_->getLocalRowCopy(v, nbors, numColInds); // Diff from CrsGraph
338
339 offsHost_(v + 1) = offsHost_(v) + numColInds;
340 for (offset_t e = offsHost_(v), i = 0; e < offsHost_(v + 1); e++) {
341 adjIdsHost_(e) = graph_->getColMap()->getGlobalElement(nbors(i++));
342 }
343 }
344
345 // Since there's no direct getter of offsets and edges in device view,
346 // we have to deep copy here
348 Kokkos::create_mirror_view_and_copy(typename Base::device_t(), offsHost_);
349 adjIdsDevice_ = Kokkos::create_mirror_view_and_copy(typename Base::device_t(),
351
352 if (nWeightsPerVertex_ > 0) {
354 arcp(new strided_t[nWeightsPerVertex_], 0, nWeightsPerVertex_, true);
355
356 vertexWeightsDevice_ = typename Base::WeightsDeviceView(
357 "vertexWeightsDevice_", nvtx, nWeightsPerVertex_);
358
359 vertexDegreeWeightsHost_ = typename Base::VtxDegreeHostView(
360 "vertexDegreeWeightsHost_", nWeightsPerVertex_);
361
362 for (int i = 0; i < nWeightsPerVertex_; ++i) {
363 vertexDegreeWeightsHost_(i) = false;
364 }
365 }
366
367 if (nWeightsPerEdge_ > 0) {
369 arcp(new strided_t[nWeightsPerEdge_], 0, nWeightsPerEdge_, true);
370
371 edgeWeightsDevice_ = typename Base::WeightsDeviceView(
372 "nWeightsPerEdge_", graph_->getLocalNumRows(), nWeightsPerEdge_);
373 }
374}
375
377template <typename User, typename UserCoord>
379 const scalar_t *weightVal, int stride, int idx) {
380 if (this->getPrimaryEntityType() == GRAPH_VERTEX)
381 setVertexWeights(weightVal, stride, idx);
382 else
383 setEdgeWeights(weightVal, stride, idx);
384}
385
387template <typename User, typename UserCoord>
389 typename Base::ConstWeightsDeviceView1D val, int idx) {
390 if (this->getPrimaryEntityType() == GRAPH_VERTEX)
391 setVertexWeightsDevice(val, idx);
392 else
393 setEdgeWeightsDevice(val, idx);
394}
395
397template <typename User, typename UserCoord>
399 typename Base::ConstWeightsHostView1D val, int idx) {
400 if (this->getPrimaryEntityType() == GRAPH_VERTEX)
401 setVertexWeightsHost(val, idx);
402 else
403 setEdgeWeightsHost(val, idx);
404}
405
407template <typename User, typename UserCoord>
409 const scalar_t *weightVal, int stride, int idx) {
410 AssertCondition((idx >= 0) and (idx < nWeightsPerVertex_),
411 "Invalid vertex weight index: " + std::to_string(idx));
412
413 size_t nvtx = getLocalNumVertices();
414 ArrayRCP<const scalar_t> weightV(weightVal, 0, nvtx * stride, false);
415 vertexWeights_[idx] = input_t(weightV, stride);
416}
417
419template <typename User, typename UserCoord>
421 typename Base::ConstWeightsDeviceView1D weights, int idx) {
422
423 AssertCondition((idx >= 0) and (idx < nWeightsPerVertex_),
424 "Invalid vertex weight index: " + std::to_string(idx));
425
426 AssertCondition(vertexWeightsDevice_.extent(0) == weights.extent(0),
427 "Invalid sizes!");
428
429 auto vertexWeightsDevice = this->vertexWeightsDevice_;
430 Kokkos::parallel_for(
431 vertexWeightsDevice.extent(0), KOKKOS_LAMBDA(const int vertexID) {
432 vertexWeightsDevice(vertexID, idx) = weights(vertexID);
433 });
434
435 Kokkos::fence();
436}
437
439template <typename User, typename UserCoord>
441 typename Base::ConstWeightsHostView1D weightsHost, int idx) {
442 AssertCondition((idx >= 0) and (idx < nWeightsPerVertex_),
443 "Invalid vertex weight index: " + std::to_string(idx));
444
445 auto weightsDevice = Kokkos::create_mirror_view_and_copy(
446 typename Base::device_t(), weightsHost);
447
448 setVertexWeightsDevice(weightsDevice, idx);
449}
450
452template <typename User, typename UserCoord>
454 AssertCondition(this->getPrimaryEntityType() == GRAPH_VERTEX,
455 "setWeightIsNumberOfNonZeros is supported only for vertices");
456
457 setVertexWeightIsDegree(idx);
458}
459
461template <typename User, typename UserCoord>
463 AssertCondition((idx >= 0) and (idx < nWeightsPerVertex_),
464 "Invalid vertex weight index.");
465
466 vertexDegreeWeightsHost_(idx) = true;
467}
468
470template <typename User, typename UserCoord>
472 const scalar_t *weightVal, int stride, int idx) {
473 typedef StridedData<lno_t, scalar_t> input_t;
474
475 AssertCondition((idx >= 0) and (idx < nWeightsPerEdge_),
476 "Invalid edge weight index" + std::to_string(idx));
477
478 size_t nedges = getLocalNumEdges();
479 ArrayRCP<const scalar_t> weightV(weightVal, 0, nedges * stride, false);
480 edgeWeights_[idx] = input_t(weightV, stride);
481}
482
484template <typename User, typename UserCoord>
486 typename Base::ConstWeightsDeviceView1D weights, int idx) {
487 AssertCondition((idx >= 0) and (idx < nWeightsPerVertex_),
488 "Invalid edge weight index.");
489
490 AssertCondition(edgeWeightsDevice_.extent(0) == weights.extent(0),
491 "Invalid sizes!");
492
493 auto edgeWeightsDevice = this->edgeWeightsDevice_;
494 Kokkos::parallel_for(
495 edgeWeightsDevice.extent(0), KOKKOS_LAMBDA(const int vertexID) {
496 edgeWeightsDevice(vertexID, idx) = weights(vertexID);
497 });
498
499 Kokkos::fence();
500}
501
503template <typename User, typename UserCoord>
505 typename Base::ConstWeightsHostView1D weightsHost, int idx) {
506 AssertCondition((idx >= 0) and (idx < nWeightsPerVertex_),
507 "Invalid edge weight index.");
508
509 auto weightsDevice = Kokkos::create_mirror_view_and_copy(
510 typename Base::device_t(), weightsHost);
511
512 setEdgeWeightsDevice(weightsDevice);
513}
514
516template <typename User, typename UserCoord>
518 return graph_->getLocalNumRows();
519}
520
522template <typename User, typename UserCoord>
524 const gno_t *&ids) const {
525 ids = NULL;
526 if (getLocalNumVertices())
527 ids = graph_->getRowMap()->getLocalElementList().getRawPtr();
528}
529
531template <typename User, typename UserCoord>
533 typename Base::ConstIdsDeviceView &ids) const {
534
535 // TODO: Making a ConstIdsDeviceView LayoutLeft would proably remove the
536 // need of creating tmpIds
537 auto idsDevice = graph_->getRowMap()->getMyGlobalIndices();
538 auto tmpIds = typename Base::IdsDeviceView("", idsDevice.extent(0));
539
540 Kokkos::deep_copy(tmpIds, idsDevice);
541
542 ids = tmpIds;
543}
544
546template <typename User, typename UserCoord>
548 typename Base::ConstIdsHostView &ids) const {
549 // TODO: Making a ConstIdsDeviceView LayoutLeft would proably remove the
550 // need of creating tmpIds
551 auto idsDevice = graph_->getRowMap()->getMyGlobalIndices();
552 auto tmpIds = typename Base::IdsHostView("", idsDevice.extent(0));
553
554 Kokkos::deep_copy(tmpIds, idsDevice);
555
556 ids = tmpIds;
557}
558
560template <typename User, typename UserCoord>
562 return graph_->getLocalNumEntries();
563}
564
566template <typename User, typename UserCoord>
568 const offset_t *&offsets, const gno_t *&adjIds) const {
569 offsets = offsHost_.data();
570 adjIds = (getLocalNumEdges() ? adjIdsHost_.data() : NULL);
571}
572
574template <typename User, typename UserCoord>
576 typename Base::ConstOffsetsDeviceView &offsets,
577 typename Base::ConstIdsDeviceView &adjIds) const {
578
579 offsets = offsDevice_;
580 adjIds = adjIdsDevice_;
581}
582
584template <typename User, typename UserCoord>
586 typename Base::ConstOffsetsHostView &offsets,
587 typename Base::ConstIdsHostView &adjIds) const {
588
589 auto hostIDs = Kokkos::create_mirror_view(adjIdsDevice_);
590 Kokkos::deep_copy(hostIDs, adjIdsDevice_);
591 adjIds = hostIDs;
592
593 auto hostOffsets = Kokkos::create_mirror_view(offsDevice_);
594 Kokkos::deep_copy(hostOffsets, offsDevice_);
595 offsets = hostOffsets;
596}
597
599template <typename User, typename UserCoord>
601 return nWeightsPerVertex_;
602}
603
605template <typename User, typename UserCoord>
607 const scalar_t *&weights, int &stride, int idx) const {
608
609 AssertCondition((idx >= 0) and (idx < nWeightsPerVertex_),
610 "Invalid vertex weight index.");
611
612 size_t length;
613 vertexWeights_[idx].getStridedList(length, weights, stride);
614}
615
617template <typename User, typename UserCoord>
619 typename Base::WeightsDeviceView1D &weights, int idx) const {
620 AssertCondition((idx >= 0) and (idx < nWeightsPerVertex_),
621 "Invalid vertex weight index.");
622
623 const auto size = vertexWeightsDevice_.extent(0);
624 weights = typename Base::WeightsDeviceView1D("weights", size);
625
626 auto vertexWeightsDevice = this->vertexWeightsDevice_;
627 Kokkos::parallel_for(
628 size, KOKKOS_LAMBDA(const int id) {
629 weights(id) = vertexWeightsDevice(id, idx);
630 });
631
632 Kokkos::fence();
633}
634
636template <typename User, typename UserCoord>
638 typename Base::WeightsDeviceView &weights) const {
639
640 weights = vertexWeightsDevice_;
641}
642
644template <typename User, typename UserCoord>
646 typename Base::WeightsHostView1D &weights, int idx) const {
647 AssertCondition((idx >= 0) and (idx < nWeightsPerVertex_),
648 "Invalid vertex weight index.");
649
650 auto weightsDevice = typename Base::WeightsDeviceView1D(
651 "weights", vertexWeightsDevice_.extent(0));
652 getVertexWeightsDeviceView(weightsDevice, idx);
653
654 weights = Kokkos::create_mirror_view(weightsDevice);
655 Kokkos::deep_copy(weights, weightsDevice);
656}
657
659template <typename User, typename UserCoord>
661 typename Base::WeightsHostView &weights) const {
662
663 weights = Kokkos::create_mirror_view(vertexWeightsDevice_);
664 Kokkos::deep_copy(weights, vertexWeightsDevice_);
665}
666
668template <typename User, typename UserCoord>
670 int idx) const {
671 return vertexDegreeWeightsHost_(idx);
672}
673
675template <typename User, typename UserCoord>
677 return nWeightsPerEdge_;
678}
679
681template <typename User, typename UserCoord>
683 const scalar_t *&weights, int &stride, int idx) const {
684 AssertCondition((idx >= 0) and (idx < nWeightsPerEdge_),
685 "Invalid edge weight index.");
686
687 size_t length;
688 edgeWeights_[idx].getStridedList(length, weights, stride);
689}
690
692template <typename User, typename UserCoord>
694 typename Base::WeightsDeviceView1D &weights, int idx) const {
695
696 weights = Kokkos::subview(edgeWeightsDevice_, Kokkos::ALL, idx);
697}
698
700template <typename User, typename UserCoord>
702 typename Base::WeightsDeviceView &weights) const {
703
704 weights = edgeWeightsDevice_;
705}
706
708template <typename User, typename UserCoord>
710 typename Base::WeightsHostView1D &weights, int idx) const {
711
712 auto weightsDevice = Kokkos::subview(edgeWeightsDevice_, Kokkos::ALL, idx);
713 weights = Kokkos::create_mirror_view(weightsDevice);
714 Kokkos::deep_copy(weights, weightsDevice);
715}
716
718template <typename User, typename UserCoord>
720 typename Base::WeightsHostView &weights) const {
721
722 weights = Kokkos::create_mirror_view(edgeWeightsDevice_);
723 Kokkos::deep_copy(weights, edgeWeightsDevice_);
724}
725
727template <typename User, typename UserCoord>
728template <typename Adapter>
730 const User &in, User *&out,
731 const PartitioningSolution<Adapter> &solution) const {
732 // Get an import list (rows to be received)
733 size_t numNewVtx;
734 ArrayRCP<gno_t> importList;
735 try {
736 numNewVtx =
737 Zoltan2::getImportList<Adapter, TpetraRowGraphAdapter<User, UserCoord>>(
738 solution, this, importList);
739 }
741
742 // Move the rows, creating a new graph.
743 RCP<User> outPtr = doMigration(in, numNewVtx, importList.getRawPtr());
744 out = outPtr.get();
745 outPtr.release();
746}
747
749template <typename User, typename UserCoord>
750template <typename Adapter>
752 const User &in, RCP<User> &out,
753 const PartitioningSolution<Adapter> &solution) const {
754 // Get an import list (rows to be received)
755 size_t numNewVtx;
756 ArrayRCP<gno_t> importList;
757 try {
758 numNewVtx =
759 Zoltan2::getImportList<Adapter, TpetraRowGraphAdapter<User, UserCoord>>(
760 solution, this, importList);
761 }
763
764 // Move the rows, creating a new graph.
765 out = doMigration(in, numNewVtx, importList.getRawPtr());
766}
767
769template <typename User, typename UserCoord>
771 const User &from, size_t numLocalRows, const gno_t *myNewRows) const {
772 typedef Tpetra::Map<lno_t, gno_t, node_t> map_t;
773 typedef Tpetra::CrsGraph<lno_t, gno_t, node_t> tcrsgraph_t;
774
775 // We cannot create a Tpetra::RowGraph, unless the underlying type is
776 // something we know (like Tpetra::CrsGraph).
777 // If the underlying type is something different, the user probably doesn't
778 // want a Tpetra::CrsGraph back, so we throw an error.
779
780 // Try to cast "from" graph to a TPetra::CrsGraph
781 // If that fails we throw an error.
782 // We could cast as a ref which will throw std::bad_cast but with ptr
783 // approach it might be clearer what's going on here
784 const tcrsgraph_t *pCrsGraphSrc = dynamic_cast<const tcrsgraph_t *>(&from);
785
786 if (!pCrsGraphSrc) {
787 throw std::logic_error("TpetraRowGraphAdapter cannot migrate data for "
788 "your RowGraph; it can migrate data only for "
789 "Tpetra::CrsGraph. "
790 "You can inherit from TpetraRowGraphAdapter and "
791 "implement migration for your RowGraph.");
792 }
793
794 // source map
795 const RCP<const map_t> &smap = from.getRowMap();
796 int oldNumElts = smap->getLocalNumElements();
797 gno_t numGlobalRows = smap->getGlobalNumElements();
798 gno_t base = smap->getMinAllGlobalIndex();
799
800 // target map
801 ArrayView<const gno_t> rowList(myNewRows, numLocalRows);
802 const RCP<const Teuchos::Comm<int>> &comm = from.getComm();
803 RCP<const map_t> tmap = rcp(new map_t(numGlobalRows, rowList, base, comm));
804
805 // importer
806 Tpetra::Import<lno_t, gno_t, node_t> importer(smap, tmap);
807
808 // number of entries in my new rows
809 typedef Tpetra::Vector<gno_t, lno_t, gno_t, node_t> vector_t;
810 vector_t numOld(smap);
811 vector_t numNew(tmap);
812 for (int lid = 0; lid < oldNumElts; lid++) {
813 numOld.replaceGlobalValue(smap->getGlobalElement(lid),
814 from.getNumEntriesInLocalRow(lid));
815 }
816 numNew.doImport(numOld, importer, Tpetra::INSERT);
817
818 size_t numElts = tmap->getLocalNumElements();
819 ArrayRCP<const gno_t> nnz;
820 if (numElts > 0)
821 nnz = numNew.getData(0); // hangs if vector len == 0
822
823 ArrayRCP<const size_t> nnz_size_t;
824
825 if (numElts && sizeof(gno_t) != sizeof(size_t)) {
826 size_t *vals = new size_t[numElts];
827 nnz_size_t = arcp(vals, 0, numElts, true);
828 for (size_t i = 0; i < numElts; i++) {
829 vals[i] = static_cast<size_t>(nnz[i]);
830 }
831 } else {
832 nnz_size_t = arcp_reinterpret_cast<const size_t>(nnz);
833 }
834
835 // target graph
836 RCP<tcrsgraph_t> G = rcp(new tcrsgraph_t(tmap, nnz_size_t()));
837
838 G->doImport(*pCrsGraphSrc, importer, Tpetra::INSERT);
839 G->fillComplete();
840 return Teuchos::rcp_dynamic_cast<User>(G);
841}
842
843} // namespace Zoltan2
844
845#endif
#define Z2_FORWARD_EXCEPTIONS
Forward an exception back through call stack.
Defines the GraphAdapter interface.
Helper functions for Partitioning Problems.
This file defines the StridedData class.
typename InputTraits< User >::node_t node_t
typename InputTraits< User >::scalar_t scalar_t
typename InputTraits< User >::gno_t gno_t
typename InputTraits< User >::offset_t offset_t
typename InputTraits< User >::part_t part_t
GraphAdapter defines the interface for graph-based user data.
A PartitioningSolution is a solution to a partitioning problem.
The StridedData class manages lists of weights or coordinates.
Provides access for Zoltan2 to Tpetra::RowGraph data.
void getEdgeWeightsHostView(typename Base::WeightsHostView &weights) const override
Provide a host view of the edge weights, if any.
ArrayRCP< StridedData< lno_t, scalar_t > > vertexWeights_
void setEdgeWeightsHost(typename Base::ConstWeightsHostView1D val, int idx)
Provide a host view to edge weights.
ArrayRCP< StridedData< lno_t, scalar_t > > edgeWeights_
void getEdgesHostView(typename Base::ConstOffsetsHostView &offsets, typename Base::ConstIdsHostView &adjIds) const override
Gets adjacency lists for all vertices in a compressed sparse row (CSR) format.
size_t getLocalNumVertices() const override
Returns the number of vertices on this process.
void getEdgesView(const offset_t *&offsets, const gno_t *&adjIds) const override
Gets adjacency lists for all vertices in a compressed sparse row (CSR) format.
void setEdgeWeights(const scalar_t *val, int stride, int idx)
Provide a pointer to edge weights.
void getVertexWeightsHostView(typename Base::WeightsHostView &weights) const override
Provide a host view of the vertex weights, if any.
void getVertexWeightsView(const scalar_t *&weights, int &stride, int idx) const override
Provide a pointer to the vertex weights, if any.
void getVertexIDsHostView(typename Base::ConstIdsHostView &ids) const override
Sets pointers to this process' graph entries.
TpetraRowGraphAdapter(int nVtxWgts, int nEdgeWgts, const RCP< const User > &graph)
void getVertexWeightsDeviceView(typename Base::WeightsDeviceView &weights) const override
Provide a device view of the vertex weights, if any.
void getVertexWeightsHostView(typename Base::WeightsHostView1D &weights, int idx=0) const override
Provide a host view of the vertex weights, if any.
void getEdgeWeightsDeviceView(typename Base::WeightsDeviceView &weights) const override
Provide a device view of the edge weights, if any.
void applyPartitioningSolution(const User &in, RCP< User > &out, const PartitioningSolution< Adapter > &solution) const
void setWeightIsDegree(int idx)
Specify an index for which the weight should be the degree of the entity.
void setWeightsDevice(typename Base::ConstWeightsDeviceView1D val, int idx)
Provide a device view of weights for the primary entity type.
void applyPartitioningSolution(const User &in, User *&out, const PartitioningSolution< Adapter > &solution) const
void getEdgeWeightsView(const scalar_t *&weights, int &stride, int idx) const override
Provide a pointer to the edge weights, if any.
void getVertexWeightsDeviceView(typename Base::WeightsDeviceView1D &weights, int idx=0) const override
Provide a device view of the vertex weights, if any.
void getVertexIDsDeviceView(typename Base::ConstIdsDeviceView &ids) const override
Sets pointers to this process' graph entries.
virtual RCP< User > doMigration(const User &from, size_t numLocalRows, const gno_t *myNewRows) const
void getEdgeWeightsHostView(typename Base::WeightsHostView1D &weights, int idx=0) const override
Provide a host view of the edge weights, if any.
void setWeightsHost(typename Base::ConstWeightsHostView1D val, int idx)
Provide a host view of weights for the primary entity type.
void setWeights(const scalar_t *val, int stride, int idx)
Provide a pointer to weights for the primary entity type.
void getVertexIDsView(const gno_t *&ids) const override
Sets pointers to this process' graph entries.
void setVertexWeightsDevice(typename Base::ConstWeightsDeviceView1D val, int idx)
Provide a device view to vertex weights.
int getNumWeightsPerEdge() const override
Returns the number (0 or greater) of edge weights.
int getNumWeightsPerVertex() const override
Returns the number (0 or greater) of weights per vertex.
size_t getLocalNumEdges() const override
Returns the number of edges on this process.
void setVertexWeights(const scalar_t *val, int stride, int idx)
Provide a pointer to vertex weights.
TpetraRowGraphAdapter(const RCP< const User > &ingraph, int nVtxWeights=0, int nEdgeWeights=0)
Constructor for graph with no weights or coordinates.
bool useDegreeAsVertexWeight(int idx) const override
Indicate whether vertex weight with index idx should be the global degree of the vertex.
void setVertexWeightIsDegree(int idx)
Specify an index for which the vertex weight should be the degree of the vertex.
void setEdgeWeightsDevice(typename Base::ConstWeightsDeviceView1D val, int idx)
Provide a device view to edge weights.
void getEdgeWeightsDeviceView(typename Base::WeightsDeviceView1D &weights, int idx=0) const override
Provide a device view of the edge weights, if any.
void getEdgesDeviceView(typename Base::ConstOffsetsDeviceView &offsets, typename Base::ConstIdsDeviceView &adjIds) const override
Gets adjacency lists for all vertices in a compressed sparse row (CSR) format.
void setVertexWeightsHost(typename Base::ConstWeightsHostView1D val, int idx)
Provide a host view to vertex weights.
map_t::local_ordinal_type lno_t
Tpetra::Map map_t
Created by mbenlioglu on Aug 31, 2020.
static void AssertCondition(bool condition, const std::string &message, const char *file=__FILE__, int line=__LINE__)
static ArrayRCP< ArrayRCP< zscalar_t > > weights
default_offset_t offset_t
The data type to represent offsets.
default_gno_t gno_t
The ordinal type (e.g., int, long, int64_t) that can represent global counts and identifiers.
default_node_t node_t
The Kokkos node type. This is only meaningful for users of Tpetra objects.
default_lno_t lno_t
The ordinal type (e.g., int, long, int64_t) that represents local counts and local indices.
default_part_t part_t
The data type to represent part numbers.
default_scalar_t scalar_t
The data type for weights and coordinates.