Zoltan2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Public Member Functions | List of all members
Zoltan2::MatrixAdapter< User, UserCoord > Class Template Referenceabstract

MatrixAdapter defines the adapter interface for matrices. More...

#include <Zoltan2_MatrixAdapter.hpp>

Inheritance diagram for Zoltan2::MatrixAdapter< User, UserCoord >:
Inheritance graph
[legend]
Collaboration diagram for Zoltan2::MatrixAdapter< User, UserCoord >:
Collaboration graph
[legend]

Public Member Functions

enum BaseAdapterType adapterType () const
 Returns the type of adapter. More...
 
 MatrixAdapter ()
 
virtual ~MatrixAdapter ()
 Destructor. More...
 
virtual size_t getLocalNumRows () const =0
 Returns the number of rows on this process. More...
 
virtual size_t getLocalNumColumns () const =0
 Returns the number of columns on this process. More...
 
virtual size_t getLocalNumEntries () const =0
 Returns the number of nonzeros on this process. More...
 
virtual bool CRSViewAvailable () const
 Indicates whether the MatrixAdapter implements a view of the matrix in compressed sparse row (CRS) format. All matrix adapters must implement either getCRSView or getCCSView, but implementation of both is not required. More...
 
virtual void getRowIDsView (const gno_t *&rowIds) const
 Sets pointer to this process' rows' global IDs. More...
 
virtual void getCRSView (const offset_t *&offsets, 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. More...
 
virtual void getCRSView (const offset_t *&offsets, const gno_t *&colIds, const scalar_t *&values) const
 Sets pointers to this process' matrix entries and their values using compressed sparse row (CRS) format. All matrix adapters must implement either getCRSView or getCCSView, but implementation of both is not required. More...
 
virtual int getNumWeightsPerRow () const
 Returns the number of weights per row (0 or greater). Row weights may be used when partitioning matrix rows. More...
 
virtual void getRowWeightsView (const scalar_t *&weights, int &stride, int idx=0) const
 Provide a pointer to the row weights, if any. More...
 
virtual bool useNumNonzerosAsRowWeight (int idx) const
 Indicate whether row weight with index idx should be the global number of nonzeros in the row. More...
 
virtual bool CCSViewAvailable () const
 Indicates whether the MatrixAdapter implements a view of the matrix in compressed sparse column (CCS) format. All matrix adapters must implement either getCRSView or getCCSView, but implementation of both is not required. More...
 
virtual void getColumnIDsView (const gno_t *&colIds) const
 Sets pointer to this process' columns' global IDs. More...
 
virtual void getCCSView (const offset_t *&offsets, const gno_t *&rowIds) const
 Sets pointers to this process' matrix entries using compressed sparse column (CCS) format. All matrix adapters must implement either getCRSView or getCCSView, but implementation of both is not required. More...
 
virtual void getCCSView (const offset_t *&offsets, const gno_t *&rowIds, const scalar_t *&values) const
 Sets pointers to this process' matrix entries and their values using compressed sparse column (CCS) format. All matrix adapters must implement either getCRSView or getCCSView, but implementation of both is not required. More...
 
virtual int getNumWeightsPerColumn () const
 Returns the number of weights per column (0 or greater). Column weights may be used when partitioning matrix columns. More...
 
virtual void getColumnWeightsView (const scalar_t *&weights, int &stride, int idx=0) const
 Provide a pointer to the column weights, if any. More...
 
virtual bool useNumNonzerosAsColumnWeight (int idx) const
 Indicate whether column weight with index idx should be the global number of nonzeros in the column. More...
 
void setCoordinateInput (VectorAdapter< UserCoord > *coordData)
 Allow user to provide additional data that contains coordinate info associated with the MatrixAdapter's primaryEntityType. Associated data must have the same parallel distribution and ordering of entries as the primaryEntityType. More...
 
bool coordinatesAvailable () const
 Indicate whether coordinate information has been set for this MatrixAdapter. More...
 
VectorAdapter< UserCoord > * getCoordinateInput () const
 Obtain the coordinate data registered by the user. More...
 
enum MatrixEntityType getPrimaryEntityType () const
 Returns the entity to be partitioned, ordered, colored, etc. Valid values are MATRIX_ROW, MATRIX_COLUMN, MATRIX_NONZERO. More...
 
void setPrimaryEntityType (std::string typestr)
 Sets the primary entity type. Called by algorithm based on parameter value in parameter list from application. Also sets to adjacencyEntityType to something reasonable: opposite of primaryEntityType. More...
 
size_t getLocalNumIDs () const
 Returns the number of objects on this process. More...
 
void getIDsView (const gno_t *&Ids) const
 Provide a pointer to this process' identifiers. More...
 
int getNumWeightsPerID () const
 Returns the number of weights per object. Number of weights per object should be zero or greater. If zero, then it is assumed that all objects are equally weighted. Default is zero weights per ID. More...
 
void getWeightsView (const scalar_t *&wgt, int &stride, int idx=0) const
 Provide pointer to a weight array with stride. More...
 
bool useDegreeAsWeight (int idx) const
 
- Public Member Functions inherited from Zoltan2::BaseAdapter< User >
virtual ~BaseAdapter ()
 Destructor. More...
 
virtual void getIDsKokkosView (Kokkos::View< gno_t * > &) const
 Provide a pointer to this process' identifiers. More...
 
virtual void getWeightsKokkosView (Kokkos::View< scalar_t * > &, int=0) const
 Provide pointer to a weight View. More...
 
void getPartsView (const part_t *&inputPart) const
 Provide pointer to an array containing the input part assignment for each ID. The input part information may be used for re-partitioning to reduce data movement, or for mapping parts to processes. Adapters may return NULL for this pointer (the default behavior); if NULL is returned, algorithms will assume the rank. More...
 
template<typename Adapter >
void applyPartitioningSolution (const User &in, User *&out, const PartitioningSolution< Adapter > &solution) const
 Apply a PartitioningSolution to an input. More...
 
- Public Member Functions inherited from Zoltan2::BaseAdapterRoot
virtual ~BaseAdapterRoot ()
 

Additional Inherited Members

- Public Types inherited from Zoltan2::BaseAdapter< User >
typedef InputTraits< User >::lno_t lno_t
 
typedef InputTraits< User >::gno_t gno_t
 
typedef InputTraits< User >
::scalar_t 
scalar_t
 
typedef InputTraits< User >::part_t part_t
 
typedef InputTraits< User >
::offset_t 
offset_t
 
- Protected Member Functions inherited from Zoltan2::BaseAdapter< User >
void generateWeightFileOnly (const char *fileprefix, const Teuchos::Comm< int > &comm) const
 

Detailed Description

template<typename User, typename UserCoord = User>
class Zoltan2::MatrixAdapter< User, UserCoord >

MatrixAdapter defines the adapter interface for matrices.

Adapter objects provide access for Zoltan2 to the user's data. Many built-in adapters are already defined for common data structures, such as Tpetra and Epetra objects and C-language pointers to arrays.

Data types:

The Kokkos node type can be safely ignored.

The template parameter User is a user-defined data type which, through a traits mechanism, provides the actual data types with which the Zoltan2 library will be compiled. User may be the actual class or structure used by application to represent a vector, or it may be the helper class BasicUserTypes. See InputTraits for more information.

The scalar_t type, representing use data such as matrix values, is used by Zoltan2 for weights, coordinates, part sizes and quality metrics. Some User types (like Tpetra::CrsMatrix) have an inherent scalar type, and some (like Tpetra::CrsGraph) do not. For such objects, the scalar type is set by Zoltan2 to float. If you wish to change it to double, set the second template parameter to double.

Todo:

Create BasicCrsMatrixAdapter subclass

Do we want to require adapters to give us the global number of rows, columns etc? We can figure that out.

This is a row-oriented matrix. Do we need a column-oriented matrix? In particular - we assumed coordinates are for rows.

If the user can tell us there are no diagonal entries in a square matrix, it can save time if we have to remove them for the algorithm. Should we have a set method in subclasses for setMatrixHasDiagonalEntries yes, no and maybe?

Definition at line 106 of file Zoltan2_MatrixAdapter.hpp.

Constructor & Destructor Documentation

template<typename User, typename UserCoord = User>
Zoltan2::MatrixAdapter< User, UserCoord >::MatrixAdapter ( )
inline

Definition at line 129 of file Zoltan2_MatrixAdapter.hpp.

template<typename User, typename UserCoord = User>
virtual Zoltan2::MatrixAdapter< User, UserCoord >::~MatrixAdapter ( )
inlinevirtual

Destructor.

Definition at line 135 of file Zoltan2_MatrixAdapter.hpp.

Member Function Documentation

template<typename User, typename UserCoord = User>
enum BaseAdapterType Zoltan2::MatrixAdapter< User, UserCoord >::adapterType ( ) const
inlinevirtual

Returns the type of adapter.

Implements Zoltan2::BaseAdapter< User >.

Definition at line 126 of file Zoltan2_MatrixAdapter.hpp.

template<typename User, typename UserCoord = User>
virtual size_t Zoltan2::MatrixAdapter< User, UserCoord >::getLocalNumRows ( ) const
pure virtual

Returns the number of rows on this process.

Implemented in Zoltan2::XpetraCrsMatrixAdapter< User, UserCoord >, and Zoltan2::TpetraRowMatrixAdapter< User, UserCoord >.

template<typename User, typename UserCoord = User>
virtual size_t Zoltan2::MatrixAdapter< User, UserCoord >::getLocalNumColumns ( ) const
pure virtual

Returns the number of columns on this process.

Implemented in Zoltan2::XpetraCrsMatrixAdapter< User, UserCoord >, and Zoltan2::TpetraRowMatrixAdapter< User, UserCoord >.

template<typename User, typename UserCoord = User>
virtual size_t Zoltan2::MatrixAdapter< User, UserCoord >::getLocalNumEntries ( ) const
pure virtual

Returns the number of nonzeros on this process.

Implemented in Zoltan2::XpetraCrsMatrixAdapter< User, UserCoord >, and Zoltan2::TpetraRowMatrixAdapter< User, UserCoord >.

template<typename User, typename UserCoord = User>
virtual bool Zoltan2::MatrixAdapter< User, UserCoord >::CRSViewAvailable ( ) const
inlinevirtual

Indicates whether the MatrixAdapter implements a view of the matrix in compressed sparse row (CRS) format. All matrix adapters must implement either getCRSView or getCCSView, but implementation of both is not required.

Reimplemented in Zoltan2::XpetraCrsMatrixAdapter< User, UserCoord >, and Zoltan2::TpetraRowMatrixAdapter< User, UserCoord >.

Definition at line 156 of file Zoltan2_MatrixAdapter.hpp.

template<typename User, typename UserCoord = User>
virtual void Zoltan2::MatrixAdapter< User, UserCoord >::getRowIDsView ( const gno_t *&  rowIds) const
inlinevirtual

Sets pointer to this process' rows' global IDs.

Parameters
rowIdswill on return a pointer to row global Ids

Reimplemented in Zoltan2::TpetraRowMatrixAdapter< User, UserCoord >.

Definition at line 161 of file Zoltan2_MatrixAdapter.hpp.

template<typename User, typename UserCoord = User>
virtual void Zoltan2::MatrixAdapter< User, UserCoord >::getCRSView ( const offset_t *&  offsets,
const gno_t *&  colIds 
) const
inlinevirtual

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.

Parameters
offsetsis an array of size numRows + 1. The column Ids for rowIds[i] (returned by getRowIDsView) begin at colIds[offsets[i]]. The last element of offsets is the size of the colIds array.
colIdson return will point to the global column Ids for the non-zeros for each row.

Definition at line 178 of file Zoltan2_MatrixAdapter.hpp.

template<typename User, typename UserCoord = User>
virtual void Zoltan2::MatrixAdapter< User, UserCoord >::getCRSView ( const offset_t *&  offsets,
const gno_t *&  colIds,
const scalar_t *&  values 
) const
inlinevirtual

Sets pointers to this process' matrix entries and their values using compressed sparse row (CRS) format. All matrix adapters must implement either getCRSView or getCCSView, but implementation of both is not required.

Parameters
offsetsis an array of size numRows + 1. The column Ids for rowIds[i] (returned by getRowIDsView) begin at colIds[offsets[i]]. The last element of offsets is the size of the colIds array.
colIdson return will point to the global column Ids for the non-zeros for each row.
valueson return will point to the values stored in the non-zeros for each row.

Definition at line 200 of file Zoltan2_MatrixAdapter.hpp.

template<typename User, typename UserCoord = User>
virtual int Zoltan2::MatrixAdapter< User, UserCoord >::getNumWeightsPerRow ( ) const
inlinevirtual

Returns the number of weights per row (0 or greater). Row weights may be used when partitioning matrix rows.

Reimplemented in Zoltan2::XpetraCrsMatrixAdapter< User, UserCoord >, and Zoltan2::TpetraRowMatrixAdapter< User, UserCoord >.

Definition at line 214 of file Zoltan2_MatrixAdapter.hpp.

template<typename User, typename UserCoord = User>
virtual void Zoltan2::MatrixAdapter< User, UserCoord >::getRowWeightsView ( const scalar_t *&  weights,
int &  stride,
int  idx = 0 
) const
inlinevirtual

Provide a pointer to the row weights, if any.

Parameters
weightsis the list of weights with a given index for the rows returned in getRowIDsView().
strideThe k'th weight is located at weights[stride*k]
idxranges from zero to one less than getNumWeightsPerRow().

Definition at line 222 of file Zoltan2_MatrixAdapter.hpp.

template<typename User, typename UserCoord = User>
virtual bool Zoltan2::MatrixAdapter< User, UserCoord >::useNumNonzerosAsRowWeight ( int  idx) const
inlinevirtual

Indicate whether row weight with index idx should be the global number of nonzeros in the row.

Reimplemented in Zoltan2::XpetraCrsMatrixAdapter< User, UserCoord >, and Zoltan2::TpetraRowMatrixAdapter< User, UserCoord >.

Definition at line 234 of file Zoltan2_MatrixAdapter.hpp.

template<typename User, typename UserCoord = User>
virtual bool Zoltan2::MatrixAdapter< User, UserCoord >::CCSViewAvailable ( ) const
inlinevirtual

Indicates whether the MatrixAdapter implements a view of the matrix in compressed sparse column (CCS) format. All matrix adapters must implement either getCRSView or getCCSView, but implementation of both is not required.

Definition at line 244 of file Zoltan2_MatrixAdapter.hpp.

template<typename User, typename UserCoord = User>
virtual void Zoltan2::MatrixAdapter< User, UserCoord >::getColumnIDsView ( const gno_t *&  colIds) const
inlinevirtual

Sets pointer to this process' columns' global IDs.

Parameters
colIdswill on return a pointer to column global Ids

Definition at line 249 of file Zoltan2_MatrixAdapter.hpp.

template<typename User, typename UserCoord = User>
virtual void Zoltan2::MatrixAdapter< User, UserCoord >::getCCSView ( const offset_t *&  offsets,
const gno_t *&  rowIds 
) const
inlinevirtual

Sets pointers to this process' matrix entries using compressed sparse column (CCS) format. All matrix adapters must implement either getCRSView or getCCSView, but implementation of both is not required.

Parameters
offsetsis an array of size numCols + 1. The row Ids for colIds[i] (returned by getColumnIDsView) begin at rowIds[offsets[i]]. The last element of offsets is the size of the rowIds array.
rowIdson return will point to the global row Ids for the non-zeros for each column.

Definition at line 266 of file Zoltan2_MatrixAdapter.hpp.

template<typename User, typename UserCoord = User>
virtual void Zoltan2::MatrixAdapter< User, UserCoord >::getCCSView ( const offset_t *&  offsets,
const gno_t *&  rowIds,
const scalar_t *&  values 
) const
inlinevirtual

Sets pointers to this process' matrix entries and their values using compressed sparse column (CCS) format. All matrix adapters must implement either getCRSView or getCCSView, but implementation of both is not required.

Parameters
offsetsis an array of size numCols + 1. The row Ids for colIds[i] (returned by getColumnIDsView) begin at rowIds[offsets[i]]. The last element of offsets is the size of the rowIds array.
rowIdson return will point to the global row Ids for the non-zeros for each column.
valueson return will point to the values stored in the non-zeros for each column.

Definition at line 289 of file Zoltan2_MatrixAdapter.hpp.

template<typename User, typename UserCoord = User>
virtual int Zoltan2::MatrixAdapter< User, UserCoord >::getNumWeightsPerColumn ( ) const
inlinevirtual

Returns the number of weights per column (0 or greater). Column weights may be used when partitioning matrix columns.

Definition at line 303 of file Zoltan2_MatrixAdapter.hpp.

template<typename User, typename UserCoord = User>
virtual void Zoltan2::MatrixAdapter< User, UserCoord >::getColumnWeightsView ( const scalar_t *&  weights,
int &  stride,
int  idx = 0 
) const
inlinevirtual

Provide a pointer to the column weights, if any.

Parameters
weightsis the list of weights with a given index for the columns returned in getColumnIDsView().
strideThe k'th weight is located at weights[stride*k]
idxranges from zero to one less than getNumWeightsPerColumn().

Definition at line 311 of file Zoltan2_MatrixAdapter.hpp.

template<typename User, typename UserCoord = User>
virtual bool Zoltan2::MatrixAdapter< User, UserCoord >::useNumNonzerosAsColumnWeight ( int  idx) const
inlinevirtual

Indicate whether column weight with index idx should be the global number of nonzeros in the column.

Definition at line 323 of file Zoltan2_MatrixAdapter.hpp.

template<typename User, typename UserCoord = User>
void Zoltan2::MatrixAdapter< User, UserCoord >::setCoordinateInput ( VectorAdapter< UserCoord > *  coordData)
inline

Allow user to provide additional data that contains coordinate info associated with the MatrixAdapter's primaryEntityType. Associated data must have the same parallel distribution and ordering of entries as the primaryEntityType.

Parameters
coordDatais a pointer to a VectorAdapter with the user's coordinate data.

Definition at line 341 of file Zoltan2_MatrixAdapter.hpp.

template<typename User, typename UserCoord = User>
bool Zoltan2::MatrixAdapter< User, UserCoord >::coordinatesAvailable ( ) const
inline

Indicate whether coordinate information has been set for this MatrixAdapter.

Definition at line 350 of file Zoltan2_MatrixAdapter.hpp.

template<typename User, typename UserCoord = User>
VectorAdapter<UserCoord>* Zoltan2::MatrixAdapter< User, UserCoord >::getCoordinateInput ( ) const
inline

Obtain the coordinate data registered by the user.

Returns
pointer a VectorAdapter with the user's coordinate data.

Definition at line 355 of file Zoltan2_MatrixAdapter.hpp.

template<typename User, typename UserCoord = User>
enum MatrixEntityType Zoltan2::MatrixAdapter< User, UserCoord >::getPrimaryEntityType ( ) const
inline

Returns the entity to be partitioned, ordered, colored, etc. Valid values are MATRIX_ROW, MATRIX_COLUMN, MATRIX_NONZERO.

Definition at line 366 of file Zoltan2_MatrixAdapter.hpp.

template<typename User, typename UserCoord = User>
void Zoltan2::MatrixAdapter< User, UserCoord >::setPrimaryEntityType ( std::string  typestr)
inline

Sets the primary entity type. Called by algorithm based on parameter value in parameter list from application. Also sets to adjacencyEntityType to something reasonable: opposite of primaryEntityType.

Definition at line 376 of file Zoltan2_MatrixAdapter.hpp.

template<typename User, typename UserCoord = User>
size_t Zoltan2::MatrixAdapter< User, UserCoord >::getLocalNumIDs ( ) const
inlinevirtual

Returns the number of objects on this process.

Objects may be coordinates, graph vertices, matrix rows, etc. They are the objects to be partitioned, ordered, or colored.

Implements Zoltan2::BaseAdapterRoot.

Definition at line 397 of file Zoltan2_MatrixAdapter.hpp.

template<typename User, typename UserCoord = User>
void Zoltan2::MatrixAdapter< User, UserCoord >::getIDsView ( const gno_t *&  ids) const
inlinevirtual

Provide a pointer to this process' identifiers.

Parameters
idswill on return point to the list of the global Ids for this process.

Reimplemented from Zoltan2::BaseAdapter< User >.

Definition at line 411 of file Zoltan2_MatrixAdapter.hpp.

template<typename User, typename UserCoord = User>
int Zoltan2::MatrixAdapter< User, UserCoord >::getNumWeightsPerID ( ) const
inlinevirtual

Returns the number of weights per object. Number of weights per object should be zero or greater. If zero, then it is assumed that all objects are equally weighted. Default is zero weights per ID.

Reimplemented from Zoltan2::BaseAdapterRoot.

Definition at line 434 of file Zoltan2_MatrixAdapter.hpp.

template<typename User, typename UserCoord = User>
void Zoltan2::MatrixAdapter< User, UserCoord >::getWeightsView ( const scalar_t *&  wgt,
int &  stride,
int  idx = 0 
) const
inlinevirtual

Provide pointer to a weight array with stride.

Parameters
wgton return a pointer to the weights for this idx
strideon return, the value such that the nth weight should be found at wgt[n*stride] .
idxthe weight index, zero or greater This function must be implemented in derived adapter if getNumWeightsPerID > 0. This function should not be called if getNumWeightsPerID is zero.

Reimplemented from Zoltan2::BaseAdapter< User >.

Definition at line 448 of file Zoltan2_MatrixAdapter.hpp.

template<typename User, typename UserCoord = User>
bool Zoltan2::MatrixAdapter< User, UserCoord >::useDegreeAsWeight ( int  idx) const
inline

Definition at line 472 of file Zoltan2_MatrixAdapter.hpp.


The documentation for this class was generated from the following file: