50 #ifndef _ZOLTAN2_MATRIXADAPTER_HPP_
51 #define _ZOLTAN2_MATRIXADAPTER_HPP_
105 template <
typename User,
typename UserCoord=User>
110 bool haveCoordinateInput_;
114 #ifndef DOXYGEN_SHOULD_SKIP_THIS
122 using userCoord_t = UserCoord;
124 using device_t =
typename node_t::device_type;
132 haveCoordinateInput_(false) {}
185 virtual void getCRSView(ArrayRCP<const offset_t> &offsets, ArrayRCP<const gno_t> &colIds)
const
188 offsets = ArrayRCP<const offset_t>();
189 colIds = ArrayRCP<const gno_t>();
221 ArrayRCP<const gno_t> &colIds,
222 ArrayRCP<const scalar_t> &values)
const
225 offsets = ArrayRCP<const offset_t>();
226 colIds = ArrayRCP<const gno_t>();
227 values = ArrayRCP<const scalar_t>();
330 ArrayRCP<const gno_t> &rowIds)
const
333 offsets = ArrayRCP<const offset_t>();
334 rowIds = ArrayRCP<const gno_t>();
353 ArrayRCP<const gno_t> &rowIds,
354 ArrayRCP<const scalar_t> &values)
const
357 offsets = ArrayRCP<const offset_t>();
358 rowIds = ArrayRCP<const gno_t>();
359 values = ArrayRCP<const scalar_t>();
406 #ifdef FUTURE_FEATURE
411 virtual bool symmetricStorage()
const {
return false;}
424 coordinateInput_ = coordData;
425 haveCoordinateInput_ =
true;
438 return coordinateInput_;
449 return this->primaryEntityType_;
459 if (typestr ==
"row") {
462 else if (typestr ==
"column") {
465 else if (typestr ==
"nonzero") {
469 std::ostringstream emsg;
470 emsg << __FILE__ <<
"," << __LINE__
471 <<
" error: Invalid MatrixEntityType " << typestr << std::endl;
472 emsg <<
"Valid values are 'row', 'column' and 'nonzero'." << std::endl;
473 throw std::runtime_error(emsg.str());
504 std::ostringstream emsg;
505 emsg << __FILE__ <<
"," << __LINE__
506 <<
" error: getIDsView not yet supported for matrix nonzeros."
508 throw std::runtime_error(emsg.str());
526 std::ostringstream emsg;
527 emsg << __FILE__ <<
"," << __LINE__
528 <<
" error: getIDsView not yet supported for matrix nonzeros."
530 throw std::runtime_error(emsg.str());
548 std::ostringstream emsg;
549 emsg << __FILE__ <<
"," << __LINE__
550 <<
" error: getIDsView not yet supported for matrix nonzeros."
552 throw std::runtime_error(emsg.str());
574 int idx = 0)
const override
587 std::ostringstream emsg;
588 emsg << __FILE__ <<
"," << __LINE__
589 <<
" error: getWeightsView not yet supported for matrix nonzeros."
591 throw std::runtime_error(emsg.str());
610 std::ostringstream emsg;
611 emsg << __FILE__ <<
"," << __LINE__
612 <<
" error: getWeightsView not yet supported for matrix nonzeros."
614 throw std::runtime_error(emsg.str());
621 int idx = 0)
const override {
633 std::ostringstream emsg;
634 emsg << __FILE__ <<
"," << __LINE__
635 <<
" error: getWeightsView not yet supported for matrix nonzeros."
637 throw std::runtime_error(emsg.str());
655 std::ostringstream emsg;
656 emsg << __FILE__ <<
"," << __LINE__
657 <<
" error: getWeightsView not yet supported for matrix nonzeros."
659 throw std::runtime_error(emsg.str());
666 int idx = 0)
const override {
678 std::ostringstream emsg;
679 emsg << __FILE__ <<
"," << __LINE__
680 <<
" error: getWeightsView not yet supported for matrix nonzeros."
682 throw std::runtime_error(emsg.str());
693 std::ostringstream emsg;
694 emsg << __FILE__ <<
"," << __LINE__
695 <<
" error: useDegreeAsWeight is currently supported only for rows"
697 throw std::runtime_error(emsg.str());
Zoltan2::BaseAdapter< userTypes_t > base_adapter_t
VectorAdapter< UserCoord > * getCoordinateInput() const override
Obtain the coordinate data registered by the user.
size_t getLocalNumIDs() const override
Returns the number of objects on this process.
void setPrimaryEntityType(std::string typestr)
Sets the primary entity type. Called by algorithm based on parameter value in parameter list from app...
virtual void getCCSView(ArrayRCP< const offset_t > &offsets, ArrayRCP< const gno_t > &rowIds) const
Sets pointers to this process' matrix entries using compressed sparse column (CCS) format...
virtual void getRowIDsDeviceView(typename BaseAdapter< User >::ConstIdsDeviceView &rowIds) const
typename InputTraits< User >::scalar_t scalar_t
MatrixAdapter defines the adapter interface for matrices.
Kokkos::View< scalar_t *, device_t > WeightsDeviceView1D
virtual bool useNumNonzerosAsColumnWeight(int idx) const
Indicate whether column weight with index idx should be the global number of nonzeros in the column...
void getWeightsHostView(typename BaseAdapter< User >::WeightsHostView1D &hostWgts, int idx=0) const override
virtual void getColumnWeightsDeviceView(typename BaseAdapter< User >::WeightsDeviceView &weights) const
bool coordinatesAvailable() const
Indicate whether coordinate information has been set for this MatrixAdapter.
virtual int getNumWeightsPerColumn() const
Returns the number of weights per column (0 or greater). Column weights may be used when partitioning...
Defines the VectorAdapter interface.
enum MatrixEntityType getPrimaryEntityType() const
Returns the entity to be partitioned, ordered, colored, etc. Valid values are MATRIX_ROW, MATRIX_COLUMN, MATRIX_NONZERO.
virtual void getRowWeightsView(const scalar_t *&weights, int &stride, int idx=0) const
Provide a pointer to the row weights, if any.
#define Z2_THROW_NOT_IMPLEMENTED
virtual void getCRSDeviceView(typename BaseAdapter< User >::ConstOffsetsDeviceView &offsets, typename BaseAdapter< User >::ConstIdsDeviceView &colIds, typename BaseAdapter< User >::ConstScalarsDeviceView &values) const
typename node_t::device_type device_t
typename InputTraits< User >::part_t part_t
Kokkos::View< const gno_t *, device_t > ConstIdsDeviceView
void getWeightsDeviceView(typename BaseAdapter< User >::WeightsDeviceView &deviceWgts) const override
typename ConstScalarsDeviceView::HostMirror ConstScalarsHostView
void getIDsView(const gno_t *&Ids) const override
Provide a pointer to this process' identifiers.
virtual void getRowWeightsDeviceView(typename BaseAdapter< User >::WeightsDeviceView1D &weights, int=0) const
virtual void getColumnIDsHostView(typename BaseAdapter< User >::ConstIdsHostView &colIds) const
virtual void getCRSHostView(typename BaseAdapter< User >::ConstOffsetsHostView &offsets, typename BaseAdapter< User >::ConstIdsHostView &colIds) const
typename WeightsDeviceView::HostMirror WeightsHostView
virtual size_t getLocalNumColumns() const =0
Returns the number of columns on this process.
virtual void getCRSView(ArrayRCP< const offset_t > &offsets, ArrayRCP< const gno_t > &colIds, ArrayRCP< const scalar_t > &values) const
Sets pointers to this process' matrix entries and their values using compressed sparse row (CRS) form...
Kokkos::View< const scalar_t *, device_t > ConstScalarsDeviceView
void getIDsDeviceView(typename BaseAdapter< User >::ConstIdsDeviceView &ids) const override
typename InputTraits< User >::node_t node_t
typename ConstOffsetsDeviceView::HostMirror ConstOffsetsHostView
virtual bool useNumNonzerosAsRowWeight(int idx) const
Indicate whether row weight with index idx should be the global number of nonzeros in the row...
virtual void getRowIDsHostView(typename BaseAdapter< User >::ConstIdsHostView &rowIds) const
virtual bool CCSViewAvailable() const
Indicates whether the MatrixAdapter implements a view of the matrix in compressed sparse column (CCS)...
typename InputTraits< User >::gno_t gno_t
typename ConstIdsDeviceView::HostMirror ConstIdsHostView
virtual void getRowWeightsDeviceView(typename BaseAdapter< User >::WeightsDeviceView &weights) const
BaseAdapterType
An enum to identify general types of adapters.
virtual void getRowWeightsHostView(typename BaseAdapter< User >::WeightsHostView &weights) const
virtual int getNumWeightsPerRow() const
Returns the number of weights per row (0 or greater). Row weights may be used when partitioning matri...
enum BaseAdapterType adapterType() const override
Returns the type of adapter.
virtual void getColumnWeightsView(const scalar_t *&weights, int &stride, int idx=0) const
Provide a pointer to the column weights, if any.
virtual void getRowWeightsHostView(typename BaseAdapter< User >::WeightsHostView1D &weights, int=0) const
virtual void getCRSHostView(typename BaseAdapter< User >::ConstOffsetsHostView &offsets, typename BaseAdapter< User >::ConstIdsHostView &colIds, typename BaseAdapter< User >::ConstScalarsHostView &values) const
void getIDsHostView(typename BaseAdapter< User >::ConstIdsHostView &ids) const override
typename InputTraits< User >::offset_t offset_t
typename WeightsDeviceView1D::HostMirror WeightsHostView1D
int getNumWeightsPerID() const override
Returns the number of weights per object. Number of weights per object should be zero or greater...
virtual void getColumnWeightsDeviceView(typename BaseAdapter< User >::WeightsDeviceView1D &weights, int=0) const
void getWeightsHostView(typename BaseAdapter< User >::WeightsHostView &hostWgts) const override
bool useDegreeAsWeight(int idx) const
Kokkos::View< scalar_t **, device_t > WeightsDeviceView
virtual void getCCSView(ArrayRCP< const offset_t > &offsets, ArrayRCP< const gno_t > &rowIds, ArrayRCP< const scalar_t > &values) const
Sets pointers to this process' matrix entries and their values using compressed sparse column (CCS) f...
void setCoordinateInput(VectorAdapter< UserCoord > *coordData) override
Allow user to provide additional data that contains coordinate info associated with the MatrixAdapter...
virtual void getRowIDsView(const gno_t *&rowIds) const
Sets pointer to this process' rows' global IDs.
virtual bool CRSViewAvailable() const
Indicates whether the MatrixAdapter implements a view of the matrix in compressed sparse row (CRS) fo...
virtual void getCRSView(ArrayRCP< const offset_t > &offsets, ArrayRCP< const gno_t > &colIds) const
Sets pointers to this process' matrix entries using compressed sparse row (CRS) format. All matrix adapters must implement either getCRSView or getCCSView, but implementation of both is not required.
virtual size_t getLocalNumRows() const =0
Returns the number of rows on this process.
void getWeightsView(const scalar_t *&wgt, int &stride, int idx=0) const override
Provide pointer to a weight array with stride.
virtual void getColumnIDsDeviceView(typename BaseAdapter< User >::ConstIdsDeviceView &colIds) const
virtual size_t getLocalNumEntries() const =0
Returns the number of nonzeros on this process.
Kokkos::View< const offset_t *, device_t > ConstOffsetsDeviceView
virtual void getCRSDeviceView(typename BaseAdapter< User >::ConstOffsetsDeviceView &offsets, typename BaseAdapter< User >::ConstIdsDeviceView &colIds) const
void getWeightsDeviceView(typename BaseAdapter< User >::WeightsDeviceView1D &deviceWgts, int idx=0) const override
typename InputTraits< User >::lno_t lno_t
virtual void getColumnWeightsHostView(typename BaseAdapter< User >::WeightsHostView1D &weights, int=0) const
virtual void getColumnIDsView(const gno_t *&colIds) const
Sets pointer to this process' columns' global IDs.
virtual void getColumnWeightsHostView(typename BaseAdapter< User >::WeightsHostView &weights) const