Discontinuous Galerkin Library
#include "dg/algorithm.h"
dg::RowColDistMat< LocalMatrixInner, LocalMatrixOuter, Collective > Struct Template Reference

Distributed memory matrix class, asynchronous communication. More...

Public Types

using value_type = get_value_type< LocalMatrixInner >
 

Public Member Functions

 RowColDistMat ()
 no memory allocation More...
 
 RowColDistMat (const LocalMatrixInner &inside, const LocalMatrixOuter &outside, const Collective &c)
 Constructor. More...
 
template<class OtherMatrixInner , class OtherMatrixOuter , class OtherCollective >
 RowColDistMat (const RowColDistMat< OtherMatrixInner, OtherMatrixOuter, OtherCollective > &src)
 Copy constructor. More...
 
const LocalMatrixInner & inner_matrix () const
 Read access to the inner matrix. More...
 
LocalMatrixInner & inner_matrix ()
 Write access to the inner matrix. More...
 
const LocalMatrixOuter & outer_matrix () const
 Read access to the outer matrix. More...
 
LocalMatrixOuter & outer_matrix ()
 Write access to the outer matrix. More...
 
const Collective & collective () const
 Read access to the communication object. More...
 
template<class ContainerType1 , class ContainerType2 >
void symv (value_type alpha, const ContainerType1 &x, value_type beta, ContainerType2 &y) const
 Matrix Vector product. More...
 
template<class ContainerType1 , class ContainerType2 >
void symv (const ContainerType1 &x, ContainerType2 &y) const
 Matrix Vector product. More...
 

Detailed Description

template<class LocalMatrixInner, class LocalMatrixOuter, class Collective>
struct dg::RowColDistMat< LocalMatrixInner, LocalMatrixOuter, Collective >

Distributed memory matrix class, asynchronous communication.

The idea of this mpi matrix is to separate communication and computation in order to reuse existing optimized matrix formats for the computation. It can be expected that this works particularly well for cases in which the communication to computation ratio is low. This class assumes that the matrix and vector elements are distributed rowwise among mpi processes. The matrix elements are then further separated into columns that are inside the domain and the ones that are outside, i.e.

\[ M=M_i+M_o \]

where \( M_i\) is the inner matrix which requires no communication, while \( M_o\) is the outer matrix containing all elements which require communication from the Collective object.

Template Parameters
LocalMatrixInnerThe class of the matrix for local computations of the inner points. symv(m,x,y) needs to be callable on the container class of the MPI_Vector
LocalMatrixOuterThe class of the matrix for local computations of the outer points. symv(1,m,x,1,y) needs to be callable on the container class of the MPI_Vector
Collectivemust be a NearestNeighborComm The Communication class needs to gather values across processes. The global_gather_init(), global_gather_wait(), allocate_buffer() and isCommunicating() member functions are called. Gather points from other processes that are necessary for the outer computations. If !isCommunicating() the global_gather() function won't be called and only the inner matrix is applied.
Note
This class overlaps communication with computation of the inner matrix

Member Typedef Documentation

◆ value_type

template<class LocalMatrixInner , class LocalMatrixOuter , class Collective >
using dg::RowColDistMat< LocalMatrixInner, LocalMatrixOuter, Collective >::value_type = get_value_type<LocalMatrixInner>

Constructor & Destructor Documentation

◆ RowColDistMat() [1/3]

template<class LocalMatrixInner , class LocalMatrixOuter , class Collective >
dg::RowColDistMat< LocalMatrixInner, LocalMatrixOuter, Collective >::RowColDistMat ( )
inline

no memory allocation

◆ RowColDistMat() [2/3]

template<class LocalMatrixInner , class LocalMatrixOuter , class Collective >
dg::RowColDistMat< LocalMatrixInner, LocalMatrixOuter, Collective >::RowColDistMat ( const LocalMatrixInner &  inside,
const LocalMatrixOuter &  outside,
const Collective &  c 
)
inline

Constructor.

Parameters
insideThe local matrix for the inner elements
outsideA local matrix for the elements from other processes
cThe communication object

◆ RowColDistMat() [3/3]

template<class LocalMatrixInner , class LocalMatrixOuter , class Collective >
template<class OtherMatrixInner , class OtherMatrixOuter , class OtherCollective >
dg::RowColDistMat< LocalMatrixInner, LocalMatrixOuter, Collective >::RowColDistMat ( const RowColDistMat< OtherMatrixInner, OtherMatrixOuter, OtherCollective > &  src)
inline

Copy constructor.

The idea is that a device matrix can be constructed by copying a host matrix.

Template Parameters
OtherMatrixInnerLocalMatrixInner must be copy-constructible from OtherMatrixInner
OtherMatrixOuterLocalMatrixOuter must be copy-constructible from OtherMatrixOuter
OtherCollectiveCollective must be copy-constructible from OtherCollective
Parameters
srcanother Matrix

Member Function Documentation

◆ collective()

template<class LocalMatrixInner , class LocalMatrixOuter , class Collective >
const Collective & dg::RowColDistMat< LocalMatrixInner, LocalMatrixOuter, Collective >::collective ( ) const
inline

Read access to the communication object.

◆ inner_matrix() [1/2]

template<class LocalMatrixInner , class LocalMatrixOuter , class Collective >
LocalMatrixInner & dg::RowColDistMat< LocalMatrixInner, LocalMatrixOuter, Collective >::inner_matrix ( )
inline

Write access to the inner matrix.

◆ inner_matrix() [2/2]

template<class LocalMatrixInner , class LocalMatrixOuter , class Collective >
const LocalMatrixInner & dg::RowColDistMat< LocalMatrixInner, LocalMatrixOuter, Collective >::inner_matrix ( ) const
inline

Read access to the inner matrix.

◆ outer_matrix() [1/2]

template<class LocalMatrixInner , class LocalMatrixOuter , class Collective >
LocalMatrixOuter & dg::RowColDistMat< LocalMatrixInner, LocalMatrixOuter, Collective >::outer_matrix ( )
inline

Write access to the outer matrix.

◆ outer_matrix() [2/2]

template<class LocalMatrixInner , class LocalMatrixOuter , class Collective >
const LocalMatrixOuter & dg::RowColDistMat< LocalMatrixInner, LocalMatrixOuter, Collective >::outer_matrix ( ) const
inline

Read access to the outer matrix.

◆ symv() [1/2]

template<class LocalMatrixInner , class LocalMatrixOuter , class Collective >
template<class ContainerType1 , class ContainerType2 >
void dg::RowColDistMat< LocalMatrixInner, LocalMatrixOuter, Collective >::symv ( const ContainerType1 &  x,
ContainerType2 &  y 
) const
inline

Matrix Vector product.

First the inner elements are computed with a call to doSymv then the collect function of the communication object is called. Finally the outer elements are added with a call to doSymv for the outer matrix

Template Parameters
ContainerTypecontainer class of the vector elements
Parameters
xinput
youtput

◆ symv() [2/2]

template<class LocalMatrixInner , class LocalMatrixOuter , class Collective >
template<class ContainerType1 , class ContainerType2 >
void dg::RowColDistMat< LocalMatrixInner, LocalMatrixOuter, Collective >::symv ( value_type  alpha,
const ContainerType1 &  x,
value_type  beta,
ContainerType2 &  y 
) const
inline

Matrix Vector product.

First the inner elements are computed with a call to doSymv then the global_gather function of the communication object is called. Finally the outer elements are added with a call to doSymv for the outer matrix

Template Parameters
ContainerTypecontainer class of the vector elements
Parameters
alphascalar
xinput
betascalar
youtput

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