14 #ifndef _ZOLTAN2_MATRIXADAPTER_HPP_
15 #define _ZOLTAN2_MATRIXADAPTER_HPP_
69 template <
typename User,
typename UserCoord=User>
74 bool haveCoordinateInput_;
78 #ifndef DOXYGEN_SHOULD_SKIP_THIS
86 using userCoord_t = UserCoord;
88 using device_t =
typename node_t::device_type;
96 haveCoordinateInput_(false) {}
149 virtual void getCRSView(ArrayRCP<const offset_t> &offsets, ArrayRCP<const gno_t> &colIds)
const
152 offsets = ArrayRCP<const offset_t>();
153 colIds = ArrayRCP<const gno_t>();
185 ArrayRCP<const gno_t> &colIds,
186 ArrayRCP<const scalar_t> &values)
const
189 offsets = ArrayRCP<const offset_t>();
190 colIds = ArrayRCP<const gno_t>();
191 values = ArrayRCP<const scalar_t>();
294 ArrayRCP<const gno_t> &rowIds)
const
297 offsets = ArrayRCP<const offset_t>();
298 rowIds = ArrayRCP<const gno_t>();
317 ArrayRCP<const gno_t> &rowIds,
318 ArrayRCP<const scalar_t> &values)
const
321 offsets = ArrayRCP<const offset_t>();
322 rowIds = ArrayRCP<const gno_t>();
323 values = ArrayRCP<const scalar_t>();
370 #ifdef FUTURE_FEATURE
375 virtual bool symmetricStorage()
const {
return false;}
388 coordinateInput_ = coordData;
389 haveCoordinateInput_ =
true;
402 return coordinateInput_;
413 return this->primaryEntityType_;
423 if (typestr ==
"row") {
426 else if (typestr ==
"column") {
429 else if (typestr ==
"nonzero") {
433 std::ostringstream emsg;
434 emsg << __FILE__ <<
"," << __LINE__
435 <<
" error: Invalid MatrixEntityType " << typestr << std::endl;
436 emsg <<
"Valid values are 'row', 'column' and 'nonzero'." << std::endl;
437 throw std::runtime_error(emsg.str());
468 std::ostringstream emsg;
469 emsg << __FILE__ <<
"," << __LINE__
470 <<
" error: getIDsView not yet supported for matrix nonzeros."
472 throw std::runtime_error(emsg.str());
490 std::ostringstream emsg;
491 emsg << __FILE__ <<
"," << __LINE__
492 <<
" error: getIDsView not yet supported for matrix nonzeros."
494 throw std::runtime_error(emsg.str());
512 std::ostringstream emsg;
513 emsg << __FILE__ <<
"," << __LINE__
514 <<
" error: getIDsView not yet supported for matrix nonzeros."
516 throw std::runtime_error(emsg.str());
538 int idx = 0)
const override
551 std::ostringstream emsg;
552 emsg << __FILE__ <<
"," << __LINE__
553 <<
" error: getWeightsView not yet supported for matrix nonzeros."
555 throw std::runtime_error(emsg.str());
574 std::ostringstream emsg;
575 emsg << __FILE__ <<
"," << __LINE__
576 <<
" error: getWeightsView not yet supported for matrix nonzeros."
578 throw std::runtime_error(emsg.str());
585 int idx = 0)
const override {
597 std::ostringstream emsg;
598 emsg << __FILE__ <<
"," << __LINE__
599 <<
" error: getWeightsView not yet supported for matrix nonzeros."
601 throw std::runtime_error(emsg.str());
619 std::ostringstream emsg;
620 emsg << __FILE__ <<
"," << __LINE__
621 <<
" error: getWeightsView not yet supported for matrix nonzeros."
623 throw std::runtime_error(emsg.str());
630 int idx = 0)
const override {
642 std::ostringstream emsg;
643 emsg << __FILE__ <<
"," << __LINE__
644 <<
" error: getWeightsView not yet supported for matrix nonzeros."
646 throw std::runtime_error(emsg.str());
657 std::ostringstream emsg;
658 emsg << __FILE__ <<
"," << __LINE__
659 <<
" error: useDegreeAsWeight is currently supported only for rows"
661 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