SIRIUS 7.5.0
Electronic structure library and applications
Public Member Functions | Private Member Functions | Private Attributes | List of all members
sirius::la::dmatrix< T > Class Template Reference

Distributed matrix. More...

#include <dmatrix.hpp>

Inherits sirius::sddk::mdarray< T, 2 >.

Public Member Functions

 dmatrix (int num_rows__, int num_cols__, BLACS_grid const &blacs_grid__, int bs_row__, int bs_col__, sddk::memory_t mem_type__=sddk::memory_t::host)
 
 dmatrix (int num_rows__, int num_cols__, sddk::memory_t mem_type__=sddk::memory_t::host)
 
 dmatrix (int num_rows__, int num_cols__, sddk::memory_pool &mp__, std::string const &label__="")
 
 dmatrix (T *ptr__, int num_rows__, int num_cols__, BLACS_grid const &blacs_grid__, int bs_row__, int bs_col__)
 
 dmatrix (int num_rows__, int num_cols__, BLACS_grid const &blacs_grid__, int bs_row__, int bs_col__, sddk::memory_pool &mp__)
 
 dmatrix (T *ptr__, int num_rows__, int num_cols__)
 
 dmatrix (dmatrix< T > &&src)=default
 
dmatrix< T > & operator= (dmatrix< T > &&src)=default
 
int size () const
 Return size of the square matrix or -1 in case of rectangular matrix. More...
 
int size_local () const
 
int num_rows () const
 Return number of rows in the global matrix. More...
 
int num_rows_local () const
 Return local number of rows for this MPI rank. More...
 
int num_rows_local (int rank) const
 Return local number of rows for a given MPI rank. More...
 
int irow (int irow_loc) const
 Return global row index in the range [0, num_rows) by the local index in the range [0, num_rows_local). More...
 
int num_cols () const
 
int num_cols_local () const
 Local number of columns. More...
 
int num_cols_local (int rank) const
 
int icol (int icol_loc) const
 Inindex of column in global matrix. More...
 
int const * descriptor () const
 
spla::MatrixDistribution & spla_distribution ()
 
void copy_to (sddk::memory_t mem__, int ir0__, int ic0__, int nr__, int nc__)
 
void set (int ir0__, int jc0__, int mr__, int nc__, T *ptr__, int ld__)
 
void set (const int irow_glob, const int icol_glob, T val)
 
void add (const int irow_glob, const int icol_glob, T val)
 
void add (real_type< T > beta__, const int irow_glob, const int icol_glob, T val)
 
void make_real_diag (int n__)
 
sddk::mdarray< T, 1 > get_diag (int n__)
 
auto const & spl_col () const
 
auto const & spl_row () const
 
int rank_row () const
 
int num_ranks_row () const
 
int rank_col () const
 
int num_ranks_col () const
 
int bs_row () const
 Row blocking factor. More...
 
int bs_col () const
 Column blocking factor. More...
 
auto const & blacs_grid () const
 
void save_to_hdf5 (std::string name__, int m__, int n__)
 
auto get_full_matrix () const
 
nlohmann::json serialize_to_json (int m__, int n__) const
 
std::stringstream serialize (std::string name__, int m__, int n__) const
 
checksum (int m__, int n__) const
 
auto const & comm () const
 
costa::grid_layout< T > & grid_layout ()
 
costa::grid_layout< T > grid_layout (int irow0__, int jcol0__, int mrow__, int ncol__)
 
- Public Member Functions inherited from sirius::sddk::mdarray< T, 2 >
 mdarray ()
 Default constructor. More...
 
 mdarray (std::array< mdarray_index_descriptor, N > const dims__, memory_t memory__=memory_t::host, std::string label__="")
 N-dimensional array with index bounds. More...
 
 mdarray (mdarray_index_descriptor const &d0, memory_t memory__=memory_t::host, std::string label__="")
 1D array with memory allocation. More...
 
 mdarray (mdarray_index_descriptor const &d0, memory_pool &mp__, std::string label__="")
 1D array with memory pool allocation. More...
 
 mdarray (T *ptr__, mdarray_index_descriptor const &d0, std::string label__="")
 1D array with host pointer wrapper. More...
 
 mdarray (T *ptr__, T *ptr_device__, mdarray_index_descriptor const &d0, std::string label__="")
 1D array with host and device pointer wrapper. More...
 
 mdarray (mdarray_index_descriptor const &d0, mdarray_index_descriptor const &d1, memory_t memory__=memory_t::host, std::string label__="")
 2D array with memory allocation. More...
 
 mdarray (mdarray_index_descriptor const &d0, mdarray_index_descriptor const &d1, mdarray_index_descriptor const &d2, memory_t memory__=memory_t::host, std::string label__="")
 3D array with memory allocation. More...
 
 mdarray (mdarray_index_descriptor const &d0, mdarray_index_descriptor const &d1, mdarray_index_descriptor const &d2, mdarray_index_descriptor const &d3, memory_t memory__=memory_t::host, std::string label__="")
 4D array with memory allocation. More...
 
 mdarray (mdarray_index_descriptor const &d0, mdarray_index_descriptor const &d1, mdarray_index_descriptor const &d2, mdarray_index_descriptor const &d3, mdarray_index_descriptor const &d4, memory_t memory__=memory_t::host, std::string label__="")
 5D array with memory allocation. More...
 
 mdarray (mdarray_index_descriptor const &d0, mdarray_index_descriptor const &d1, mdarray_index_descriptor const &d2, mdarray_index_descriptor const &d3, mdarray_index_descriptor const &d4, mdarray_index_descriptor const &d5, memory_t memory__=memory_t::host, std::string label__="")
 6D array with memory allocation. More...
 
 mdarray (T *ptr__, mdarray_index_descriptor const &d0, mdarray_index_descriptor const &d1, std::string label__="")
 Wrap a pointer into 2D array. More...
 
 mdarray (T *ptr__, T *ptr_device__, mdarray_index_descriptor const &d0, mdarray_index_descriptor const &d1, std::string label__="")
 
 mdarray (mdarray_index_descriptor const &d0, mdarray_index_descriptor const &d1, memory_pool &mp__, std::string label__="")
 2D array with memory pool allocation. More...
 
 mdarray (T *ptr__, mdarray_index_descriptor const &d0, mdarray_index_descriptor const &d1, mdarray_index_descriptor const &d2, std::string label__="")
 
 mdarray (T *ptr__, T *ptr_device__, mdarray_index_descriptor const &d0, mdarray_index_descriptor const &d1, mdarray_index_descriptor const &d2, std::string label__="")
 
 mdarray (mdarray_index_descriptor const &d0, mdarray_index_descriptor const &d1, mdarray_index_descriptor const &d2, memory_pool &mp__, std::string label__="")
 3D array with memory pool allocation. More...
 
 mdarray (T *ptr__, mdarray_index_descriptor const &d0, mdarray_index_descriptor const &d1, mdarray_index_descriptor const &d2, mdarray_index_descriptor const &d3, std::string label__="")
 
 mdarray (T *ptr__, mdarray_index_descriptor const &d0, mdarray_index_descriptor const &d1, mdarray_index_descriptor const &d2, mdarray_index_descriptor const &d3, mdarray_index_descriptor const &d4, std::string label__="")
 
 mdarray (T *ptr__, mdarray_index_descriptor const &d0, mdarray_index_descriptor const &d1, mdarray_index_descriptor const &d2, mdarray_index_descriptor const &d3, mdarray_index_descriptor const &d4, mdarray_index_descriptor const &d5, std::string label__="")
 
 mdarray (mdarray< T, N > &&src)
 Move constructor. More...
 
mdarray< T, N > & operator= (mdarray< T, N > &&src)
 Move assignment operator. More...
 
mdarray< T, N > & operator= (std::function< T(void)> f__)
 
mdarray< T, N > & operator= (std::function< T(index_type)> f__)
 
mdarray< T, N > & operator= (std::function< T(index_type, index_type)> f__)
 
 ~mdarray ()
 Destructor. More...
 
mdarray< T, N > & allocate (memory_t memory__)
 Allocate memory for array. More...
 
mdarray< T, N > & allocate (memory_pool &mp__)
 Allocate memory from the pool. More...
 
void deallocate (memory_t memory__)
 Deallocate host or device memory. More...
 
T const & operator() (Args... args) const
 Access operator() for the elements of multidimensional array. More...
 
T & operator() (Args... args)
 Access operator() for the elements of multidimensional array. More...
 
T const & operator[] (size_t const idx__) const
 Access operator[] for the elements of multidimensional array using a linear index in the range [0, size). More...
 
T & operator[] (size_t const idx__)
 Access operator[] for the elements of multidimensional array using a linear index in the range [0, size). More...
 
T const * at (memory_t mem__, Args... args) const
 
T * at (memory_t mem__, Args... args)
 
T const * at (memory_t mem__) const
 Return pointer to the beginning of array. More...
 
T * at (memory_t mem__)
 Return pointer to the beginning of array. More...
 
T * host_data ()
 
const T * host_data () const
 
T * device_data ()
 
const T * device_data () const
 
size_t size () const
 Return total size (number of elements) of the array. More...
 
size_t size (int i) const
 Return size of particular dimension. More...
 
mdarray_index_descriptor dim (int i) const
 Return a descriptor of a dimension. More...
 
uint32_t ld () const
 Return leading dimension size. More...
 
uint64_t hash (uint64_t h__=5381) const
 Compute hash of the array. More...
 
checksum_w (size_t idx0__, size_t size__) const
 Compute weighted checksum. More...
 
checksum (size_t idx0__, size_t size__) const
 Compute checksum. More...
 
checksum () const
 
T * begin ()
 
T const * begin () const
 
T * end ()
 
T const * end () const
 
void zero (memory_t mem__, size_t idx0__, size_t n__)
 Zero n elements starting from idx0. More...
 
void zero (memory_t mem__=memory_t::host)
 Zero the entire array. More...
 
void copy_to (memory_t mem__, size_t idx0__, size_t n__, acc::stream_id sid=acc::stream_id(-1))
 Copy n elements starting from idx0 from one memory type to another. More...
 
void copy_to (memory_t mem__, acc::stream_id sid=acc::stream_id(-1))
 Copy entire array from one memory type to another. More...
 
bool on_device () const
 Check if device pointer is available. More...
 
auto label () const
 
bool on_host () const
 

Private Member Functions

void init ()
 
 dmatrix (dmatrix< T > const &src)=delete
 
dmatrix< T > & operator= (dmatrix< T > const &src)=delete
 

Private Attributes

int num_rows_ {0}
 Global number of matrix rows. More...
 
int num_cols_ {0}
 Global number of matrix columns. More...
 
int bs_row_ {0}
 Row block size. More...
 
int bs_col_ {0}
 Column block size. More...
 
BLACS_grid const * blacs_grid_ {nullptr}
 BLACS grid. More...
 
sirius::splindex_block_cyclic spl_row_
 Split index of matrix rows. More...
 
sirius::splindex_block_cyclic spl_col_
 Split index of matrix columns. More...
 
ftn_int descriptor_ [9]
 ScaLAPACK matrix descriptor. More...
 
spla::MatrixDistribution spla_dist_ {spla::MatrixDistribution::create_mirror(MPI_COMM_SELF)}
 Matrix distribution used for SPLA library functions. More...
 
costa::grid_layout< T > grid_layout_
 

Additional Inherited Members

- Public Types inherited from sirius::sddk::mdarray< T, 2 >
using index_type = mdarray_index_descriptor::index_type
 

Detailed Description

template<typename T>
class sirius::la::dmatrix< T >

Distributed matrix.

Definition at line 55 of file dmatrix.hpp.

Constructor & Destructor Documentation

◆ dmatrix() [1/7]

template<typename T >
sirius::la::dmatrix< T >::dmatrix ( )
inline

Definition at line 108 of file dmatrix.hpp.

◆ dmatrix() [2/7]

template<typename T >
sirius::la::dmatrix< T >::dmatrix ( int  num_rows__,
int  num_cols__,
BLACS_grid const &  blacs_grid__,
int  bs_row__,
int  bs_col__,
sddk::memory_t  mem_type__ = sddk::memory_t::host 
)

Definition at line 32 of file dmatrix.cpp.

◆ dmatrix() [3/7]

template<typename T >
sirius::la::dmatrix< T >::dmatrix ( int  num_rows__,
int  num_cols__,
sddk::memory_t  mem_type__ = sddk::memory_t::host 
)

Definition at line 75 of file dmatrix.cpp.

◆ dmatrix() [4/7]

template<typename T >
sirius::la::dmatrix< T >::dmatrix ( int  num_rows__,
int  num_cols__,
sddk::memory_pool mp__,
std::string const &  label__ = "" 
)

Definition at line 87 of file dmatrix.cpp.

◆ dmatrix() [5/7]

template<typename T >
sirius::la::dmatrix< T >::dmatrix ( T *  ptr__,
int  num_rows__,
int  num_cols__,
BLACS_grid const &  blacs_grid__,
int  bs_row__,
int  bs_col__ 
)

Definition at line 53 of file dmatrix.cpp.

◆ dmatrix() [6/7]

template<typename T >
sirius::la::dmatrix< T >::dmatrix ( int  num_rows__,
int  num_cols__,
BLACS_grid const &  blacs_grid__,
int  bs_row__,
int  bs_col__,
sddk::memory_pool mp__ 
)

Definition at line 113 of file dmatrix.cpp.

◆ dmatrix() [7/7]

template<typename T >
sirius::la::dmatrix< T >::dmatrix ( T *  ptr__,
int  num_rows__,
int  num_cols__ 
)

Definition at line 100 of file dmatrix.cpp.

Member Function Documentation

◆ init()

template<typename T >
void sirius::la::dmatrix< T >::init ( )
inlineprivate

Definition at line 87 of file dmatrix.hpp.

◆ size()

template<typename T >
int sirius::la::dmatrix< T >::size ( ) const
inline

Return size of the square matrix or -1 in case of rectangular matrix.

Definition at line 131 of file dmatrix.hpp.

◆ size_local()

template<typename T >
int sirius::la::dmatrix< T >::size_local ( ) const
inline

Definition at line 139 of file dmatrix.hpp.

◆ num_rows()

template<typename T >
int sirius::la::dmatrix< T >::num_rows ( ) const
inline

Return number of rows in the global matrix.

Definition at line 145 of file dmatrix.hpp.

◆ num_rows_local() [1/2]

template<typename T >
int sirius::la::dmatrix< T >::num_rows_local ( ) const
inline

Return local number of rows for this MPI rank.

Definition at line 151 of file dmatrix.hpp.

◆ num_rows_local() [2/2]

template<typename T >
int sirius::la::dmatrix< T >::num_rows_local ( int  rank) const
inline

Return local number of rows for a given MPI rank.

Definition at line 157 of file dmatrix.hpp.

◆ irow()

template<typename T >
int sirius::la::dmatrix< T >::irow ( int  irow_loc) const
inline

Return global row index in the range [0, num_rows) by the local index in the range [0, num_rows_local).

Definition at line 163 of file dmatrix.hpp.

◆ num_cols()

template<typename T >
int sirius::la::dmatrix< T >::num_cols ( ) const
inline

Definition at line 168 of file dmatrix.hpp.

◆ num_cols_local() [1/2]

template<typename T >
int sirius::la::dmatrix< T >::num_cols_local ( ) const
inline

Local number of columns.

Definition at line 174 of file dmatrix.hpp.

◆ num_cols_local() [2/2]

template<typename T >
int sirius::la::dmatrix< T >::num_cols_local ( int  rank) const
inline

Definition at line 179 of file dmatrix.hpp.

◆ icol()

template<typename T >
int sirius::la::dmatrix< T >::icol ( int  icol_loc) const
inline

Inindex of column in global matrix.

Definition at line 185 of file dmatrix.hpp.

◆ descriptor()

template<typename T >
int const * sirius::la::dmatrix< T >::descriptor ( ) const
inline

Definition at line 190 of file dmatrix.hpp.

◆ spla_distribution()

template<typename T >
spla::MatrixDistribution & sirius::la::dmatrix< T >::spla_distribution ( )
inline

Definition at line 195 of file dmatrix.hpp.

◆ copy_to()

template<typename T >
void sirius::la::dmatrix< T >::copy_to ( sddk::memory_t  mem__,
int  ir0__,
int  ic0__,
int  nr__,
int  nc__ 
)
inline

Definition at line 223 of file dmatrix.hpp.

◆ set() [1/2]

template<typename T >
void sirius::la::dmatrix< T >::set ( int  ir0__,
int  jc0__,
int  mr__,
int  nc__,
T *  ptr__,
int  ld__ 
)

Definition at line 134 of file dmatrix.cpp.

◆ set() [2/2]

template<typename T >
void sirius::la::dmatrix< T >::set ( const int  irow_glob,
const int  icol_glob,
val 
)

Definition at line 169 of file dmatrix.cpp.

◆ add() [1/2]

template<typename T >
void sirius::la::dmatrix< T >::add ( const int  irow_glob,
const int  icol_glob,
val 
)

Definition at line 185 of file dmatrix.cpp.

◆ add() [2/2]

template<typename T >
void sirius::la::dmatrix< T >::add ( real_type< T >  beta__,
const int  irow_glob,
const int  icol_glob,
val 
)

Definition at line 197 of file dmatrix.cpp.

◆ make_real_diag()

template<typename T >
void sirius::la::dmatrix< T >::make_real_diag ( int  n__)

Definition at line 209 of file dmatrix.cpp.

◆ get_diag()

template<typename T >
sddk::mdarray< T, 1 > sirius::la::dmatrix< T >::get_diag ( int  n__)

Definition at line 224 of file dmatrix.cpp.

◆ spl_col()

template<typename T >
auto const & sirius::la::dmatrix< T >::spl_col ( ) const
inline

Definition at line 270 of file dmatrix.hpp.

◆ spl_row()

template<typename T >
auto const & sirius::la::dmatrix< T >::spl_row ( ) const
inline

Definition at line 275 of file dmatrix.hpp.

◆ rank_row()

template<typename T >
int sirius::la::dmatrix< T >::rank_row ( ) const
inline

Definition at line 280 of file dmatrix.hpp.

◆ num_ranks_row()

template<typename T >
int sirius::la::dmatrix< T >::num_ranks_row ( ) const
inline

Definition at line 285 of file dmatrix.hpp.

◆ rank_col()

template<typename T >
int sirius::la::dmatrix< T >::rank_col ( ) const
inline

Definition at line 290 of file dmatrix.hpp.

◆ num_ranks_col()

template<typename T >
int sirius::la::dmatrix< T >::num_ranks_col ( ) const
inline

Definition at line 295 of file dmatrix.hpp.

◆ bs_row()

template<typename T >
int sirius::la::dmatrix< T >::bs_row ( ) const
inline

Row blocking factor.

Definition at line 301 of file dmatrix.hpp.

◆ bs_col()

template<typename T >
int sirius::la::dmatrix< T >::bs_col ( ) const
inline

Column blocking factor.

Definition at line 307 of file dmatrix.hpp.

◆ blacs_grid()

template<typename T >
auto const & sirius::la::dmatrix< T >::blacs_grid ( ) const
inline

Definition at line 312 of file dmatrix.hpp.

◆ save_to_hdf5()

template<typename T >
void sirius::la::dmatrix< T >::save_to_hdf5 ( std::string  name__,
int  m__,
int  n__ 
)

Definition at line 243 of file dmatrix.cpp.

◆ get_full_matrix()

template<typename T >
auto sirius::la::dmatrix< T >::get_full_matrix ( ) const
inline

Definition at line 320 of file dmatrix.hpp.

◆ serialize_to_json()

template<typename T >
nlohmann::json sirius::la::dmatrix< T >::serialize_to_json ( int  m__,
int  n__ 
) const
inline

Definition at line 336 of file dmatrix.hpp.

◆ serialize()

template<typename T >
std::stringstream sirius::la::dmatrix< T >::serialize ( std::string  name__,
int  m__,
int  n__ 
) const
inline

Definition at line 360 of file dmatrix.hpp.

◆ checksum()

template<typename T >
T sirius::la::dmatrix< T >::checksum ( int  m__,
int  n__ 
) const
inline

Definition at line 389 of file dmatrix.hpp.

◆ comm()

template<typename T >
auto const & sirius::la::dmatrix< T >::comm ( ) const
inline

Definition at line 414 of file dmatrix.hpp.

◆ grid_layout() [1/2]

template<typename T >
costa::grid_layout< T > & sirius::la::dmatrix< T >::grid_layout ( )
inline

Definition at line 423 of file dmatrix.hpp.

◆ grid_layout() [2/2]

template<typename T >
costa::grid_layout< T > sirius::la::dmatrix< T >::grid_layout ( int  irow0__,
int  jcol0__,
int  mrow__,
int  ncol__ 
)
inline

Definition at line 428 of file dmatrix.hpp.

Member Data Documentation

◆ num_rows_

template<typename T >
int sirius::la::dmatrix< T >::num_rows_ {0}
private

Global number of matrix rows.

Definition at line 59 of file dmatrix.hpp.

◆ num_cols_

template<typename T >
int sirius::la::dmatrix< T >::num_cols_ {0}
private

Global number of matrix columns.

Definition at line 62 of file dmatrix.hpp.

◆ bs_row_

template<typename T >
int sirius::la::dmatrix< T >::bs_row_ {0}
private

Row block size.

Definition at line 65 of file dmatrix.hpp.

◆ bs_col_

template<typename T >
int sirius::la::dmatrix< T >::bs_col_ {0}
private

Column block size.

Definition at line 68 of file dmatrix.hpp.

◆ blacs_grid_

template<typename T >
BLACS_grid const* sirius::la::dmatrix< T >::blacs_grid_ {nullptr}
private

BLACS grid.

Definition at line 71 of file dmatrix.hpp.

◆ spl_row_

template<typename T >
sirius::splindex_block_cyclic sirius::la::dmatrix< T >::spl_row_
private

Split index of matrix rows.

Definition at line 74 of file dmatrix.hpp.

◆ spl_col_

template<typename T >
sirius::splindex_block_cyclic sirius::la::dmatrix< T >::spl_col_
private

Split index of matrix columns.

Definition at line 77 of file dmatrix.hpp.

◆ descriptor_

template<typename T >
ftn_int sirius::la::dmatrix< T >::descriptor_[9]
private

ScaLAPACK matrix descriptor.

Definition at line 80 of file dmatrix.hpp.

◆ spla_dist_

template<typename T >
spla::MatrixDistribution sirius::la::dmatrix< T >::spla_dist_ {spla::MatrixDistribution::create_mirror(MPI_COMM_SELF)}
private

Matrix distribution used for SPLA library functions.

Definition at line 83 of file dmatrix.hpp.

◆ grid_layout_

template<typename T >
costa::grid_layout<T> sirius::la::dmatrix< T >::grid_layout_
private

Definition at line 85 of file dmatrix.hpp.


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