8#include <kernel/lafem/container.hpp>  
    9#include <kernel/global/gate.hpp> 
   10#include <kernel/global/vector.hpp> 
   11#include <kernel/global/synch_mat.hpp> 
   38    template<
typename LocalMatrix_, 
typename RowMirror_, 
typename ColMirror_>
 
   42      typedef LocalMatrix_ LocalMatrixType;
 
   43      typedef RowMirror_ RowMirrorType;
 
   44      typedef ColMirror_ ColMirrorType;
 
   46      typedef typename LocalMatrix_::DataType DataType;
 
   47      typedef typename LocalMatrix_::IndexType IndexType;
 
   49      typedef typename LocalMatrix_::VectorTypeL LocalVectorTypeL;
 
   50      typedef typename LocalMatrix_::VectorTypeR LocalVectorTypeR;
 
   59      template <
typename LocalMatrix2_, 
typename RowMirror2_ = RowMirror_, 
typename ColMirror2_ = ColMirror_>
 
   63      template <
typename DataType2_, 
typename IndexType2_>
 
   66        typename RowMirror_::template MirrorType<DataType2_, IndexType2_>,
 
   67        typename ColMirror_::template MirrorType<DataType2_, IndexType2_> >;
 
  108      template<
typename... Args_>
 
  112        _matrix(std::forward<Args_>(args)...)
 
  141      template<
typename OtherGlobalMatrix_>
 
  142      void convert(GateRowType* row_gate, GateColType* col_gate, 
const OtherGlobalMatrix_ & other)
 
  144        this->_row_gate = row_gate;
 
  145        this->_col_gate = col_gate;
 
  146        this->_matrix.
convert(other.local());
 
  222      template<LAFEM::Perspective perspective_ = LAFEM::Perspective::pod>
 
  225        return _col_gate->template get_num_global_dofs<perspective_>();
 
  238      template<LAFEM::Perspective perspective_ = LAFEM::Perspective::pod>
 
  241        return _row_gate->template get_num_global_dofs<perspective_>();
 
  254      template<LAFEM::Perspective perspective_ = LAFEM::Perspective::pod>
 
  257        Index my_used_elements(
_matrix.template used_elements<perspective_>());
 
  259        if((comm != 
nullptr) && (comm->
size() > 1))
 
  261        return my_used_elements;
 
  267        size_t my_bytes(
_matrix.bytes());
 
  269        if((comm != 
nullptr) && (comm->
size() > 1))
 
  357        _matrix.apply(r.local(), x.local());
 
  358        return r.sync_0_async();
 
  380        _matrix.apply_transposed(r.local(), x.local());
 
  381        return r.sync_0_async();
 
  558        XASSERTM(lump.
local().size() == 
_matrix.rows(), 
"lump vector size does not match matrix row count!");
 
  656      void convert_to_1(LocalMatrix_& matrix_sync_1, 
bool full_copy = 
true)
 const 
  658        matrix_sync_1.copy(this->
local(), full_copy);
 
  662          synch.
init(matrix_sync_1);
 
  663          synch.
exec(matrix_sync_1);
 
  670        return _matrix.get_checkpoint_size(config);
 
  676        _matrix.restore_from_checkpoint_data(data);
 
  682        return _matrix.set_checkpoint_data(data, config);
 
#define ASSERTM(expr, msg)
Debug-Assertion macro definition with custom message.
#define XASSERT(expr)
Assertion macro definition.
#define XASSERTM(expr, msg)
Assertion macro definition with custom message.
void allreduce(const void *sendbuf, void *recvbuf, std::size_t count, const Datatype &datatype, const Operation &op) const
Blocking All-Reduce.
int size() const
Returns the size of this communicator.
Global gate implementation.
void convert(const Gate< LVT2_, MT2_ > &other)
Conversion function for same vector container type but with different MDI-Type.
const Dist::Comm * get_comm() const
Returns a const pointer to the underlying communicator.
std::vector< Mirror_ > _mirrors
vector mirrors
const Dist::Comm * _comm
our communicator
std::vector< int > _ranks
communication ranks
Global Matrix wrapper class template.
Matrix(GateRowType *row_gate, GateColType *col_gate, Args_ &&... args)
Forwarding constructor.
GateRowType * _row_gate
a pointer to the row gate responsible for synchronization
GateColType * _col_gate
a pointer to the column gate responsible for synchronization
static constexpr bool is_local
this is not a local matrix class
void restore_from_checkpoint_data(std::vector< char > &data)
Extract object from checkpoint.
Matrix clone(LAFEM::CloneMode mode=LAFEM::CloneMode::Weak) const
Creates and returns a clone of this global matrix.
LocalMatrix_ _matrix
the internal local matrix object
const LocalMatrix_ & local() const
Returns a const reference to the internal local LAFEM matrix object.
VectorTypeR create_vector_r() const
Creates and returns a new R-compatible global vector object.
std::size_t bytes() const
Returns the total amount of bytes allocated.
void apply(VectorTypeL &r, const VectorTypeR &x, const VectorTypeL &y, const DataType alpha=DataType(1)) const
Performs a matrix-vector multiplication: r <- y + alpha*A*x.
VectorTypeL create_vector_l() const
Creates and returns a new L-compatible global vector object.
std::uint64_t get_checkpoint_size(LAFEM::SerialConfig &config)
Calculate size.
std::uint64_t set_checkpoint_data(std::vector< char > &data, LAFEM::SerialConfig &config)
Index columns() const
Gets the total number of columns in this distributed matrix.
void apply_transposed(VectorTypeR &r, const VectorTypeL &x, const VectorTypeR &y, const DataType alpha=DataType(1)) const
Performs a matrix-vector multiplication: r <- y + alpha*A^T*x.
LocalMatrix_ convert_to_1() const
Computes and returns the type-1 conversion of this matrix as a local matrix.
Matrix()
standard constructor
const GateRowType * get_row_gate() const
Returns a const pointer to the internal row gate of the matrix.
void apply_transposed(VectorTypeR &r, const VectorTypeL &x) const
Performs a matrix-vector multiplication: r <- A^T*x.
auto apply_async(VectorTypeL &r, const VectorTypeR &x) const -> decltype(r.sync_0_async())
Performs a matrix-vector multiplication: r <- A*x.
VectorTypeL lump_rows(bool sync=true) const
Computes and returns the lumped rows of the matrix as a vector.
Index used_elements() const
Returns the total number of non-zeros in this distributed matrix.
void convert_to_1(LocalMatrix_ &matrix_sync_1, bool full_copy=true) const
Computes and returns the type-1 conversion of this matrix as a local matrix.
const GateColType * get_col_gate() const
Returns a const pointer to the internal column gate of the matrix.
static constexpr bool is_global
this is a global matrix class
Index rows() const
Returns the total number of rows in this distributed matrix.
void extract_diag(VectorTypeL &diag, bool sync=true) const
Extracts the main diagonal of the matrix as a vector.
void lump_rows(VectorTypeL &lump, bool sync=true) const
Computes the lumped rows of the matrix as a vector.
auto apply_async(VectorTypeL &r, const VectorTypeR &x, const VectorTypeL &y, const DataType alpha=DataType(1)) const -> decltype(r.sync_0_async())
Performs a matrix-vector multiplication: r <- y + alpha*A*x.
auto apply_transposed_async(VectorTypeR &r, const VectorTypeL &x) const -> decltype(r.sync_0_async())
Performs a matrix-vector multiplication: r <- A^T*x.
void apply(VectorTypeL &r, const VectorTypeR &x) const
Performs a matrix-vector multiplication: r <- A*x.
auto apply_transposed_async(VectorTypeR &r, const VectorTypeL &x, const VectorTypeR &y, const DataType alpha=DataType(1)) const -> decltype(r.sync_0_async())
Performs a matrix-vector multiplication: r <- y + alpha*A^T*x.
const Dist::Comm * get_comm() const
Returns a const pointer to the internal communicator of the gates of the matrix.
LocalMatrix_ & local()
Returns a reference to the internal local LAFEM matrix object.
Ticket class for asynchronous global matrix conversion.
void exec(MT_ &matrix)
Converts a type-0 matrix to a type-1 matrix.
void init(const MT_ &matrix)
Initializes the internal buffers for synchronization.
Global vector wrapper class template.
void copy(const Vector &x)
Copies the contents of another vector into this vector.
void from_1_to_0()
Converts a type-1 vector into a type-0 vector.
auto sync_0_async() -> decltype(_gate->sync_0_async(_vector))
Performs a type-0 synchronization of the vector, i.e. sums up all local DOF contributions.
LocalVector_ & local()
Returns a reference to the internal local LAFEM vector object.
void sync_0()
Performs a type-0 synchronization of the vector, i.e. sums up all local DOF contributions.
Config class for serialize parameter.
const Operation op_sum(MPI_SUM)
Operation wrapper for MPI_SUM.
std::uint64_t Index
Index data type.