ChaseMpiProperties¶
-
template<class T>
class ChaseMpiProperties¶ A class to setup MPI properties and matrix distribution scheme for the implementation of ChASE on distributed-memory systems.
The ChaseMpiProperties class creates a 2D grid of MPI nodes with fixed width and height. It defines also the scheme to distribute an Hermitian matrix
Aof sideNover this 2D grid of MPI nodes. Currently, two data distribution fashion are supported in ChASE.Block distribution scheme in which one submatrix of
Ais assigned to one single MPI node;Block-Cyclic distribution scheme, which distributes a series of submatrices of
Ato the MPI nodes in a round-robin manner so that each MPI rank gets several non-adjacent blocks. More details about this distribution can be found on Netlib.
- Template Parameters:
T – the scalar type used for the application. ChASE is templated for real and complex scalars with both Single Precision and Double Precision, thus
Tcan be one offloat,double,std::complex<float>andstd::complex<double>.
Public Functions
-
inline ChaseMpiProperties(std::size_t N, std::size_t mb, std::size_t nb, std::size_t nev, std::size_t nex, int row_dim, int col_dim, char *grid_major, int irsrc, int icsrc, MPI_Comm comm)¶
A constructor of the class ChaseMpiProperties which distributes matrix
Ain Block-Cyclic Distribution.It constructs a 2D grid of MPI ranks within the MPI communicator
comm_.The dimension of this 2D grid is determined by explicit values
row_dimandcol_dim, thusrow_dim * col_dim.The major to index the coordinations of the MPI ranks is determined by the value of
grid_major: ifgrid_major="C", they are indexed bycolumn major, ifgrid_major="R", they are indexed byRow major.It distributes the Hermitian matrix
Ain a Block-Dsitribution scheme.
This constructor requires the explicit values for the initalization of the size
Nof the matrix A, the number of sought after extremal eigenvaluesnev, and the number of extra eigenvaluenexwhich defines, together withnev, the search space, and the working MPI communicatorcomm_for the construction of eigenproblem. For the distribution in block-cyclic scheme, it requires also the dimensions of 2D gridrow_dimandcol_dim, the row and column blocking factorsmbandnb, the major of grid indexinggrid_major, and the process row/column over which the first row/column of the global matrixAis distributed.The parameters related to Block-Cyclic Distribution conforms equally with the Array Descriptor of in-core Dense Matrices in ScaLAPACK.
All the private members are either initialized directly by these parameters, or setup within the construction of this constructor.
- Parameters:
N – Size of the square matrix defining the eigenproblem.
mb – Row blocking factor for Block-Cyclic Distribution.
nb – Column blocking factor for Block-Cyclic Distribution
. \param nev Number of desired extremal eigenvalues. \param nex Number of eigenvalues augmenting the search space. Usually a relatively small fraction ofnev. \param row_dim number of row in the 2D grid of MPI nodes to be constructed. \param col_dim number of column in the 2D grid of MPI nodes to be constructed. \param grid_major the type of numbering of the MPI ranks within the constructed 2D grid.grid_major==”C”Row major numbering if
.grid_major==”R”Column major numbering if
. \param irsrc Process row over which the first row of the global matrixAis distributed. \param icsrc Process column over which the first column of the global matrixA` is distributed.comm – the working MPI communicator for ChASE.
-
inline ChaseMpiProperties(std::size_t N, std::size_t nev, std::size_t nex, MPI_Comm comm = MPI_COMM_WORLD)¶
A constructor of the class ChaseMpiProperties which distributes matrix
AinBlock Distribution.It constructs a 2D grid of MPI ranks within the MPI communicator
comm_.The dimensions of this 2D grid is determined by
MPI_Cart_createusing all the available MPI nodes withincomm_.It distributes the Hermitian matrix
Ain a Block-Dsitribution scheme.
This constructor requires the explicit values for the initalization of the size
Nof the matrix A, the number of sought after extremal eigenvaluesnev, and the number of extra eigenvaluenexwhich defines, together withnev, the search space, and the working MPI communicatorcomm_.All the private members are either initialized directly by these parameters, or setup within the construction of this constructor.
- Parameters:
N – Size of the square matrix defining the eigenproblem.
nev – Number of desired extremal eigenvalues.
nex – Number of eigenvalues augmenting the search space. Usually a relatively small fraction of
nev.comm – the working MPI communicator for ChASE.
-
inline std::size_t get_N()¶
Returns the rank of matrix
Awhich is distributed within 2D MPI grid.- Returns:
N_: the rank of matrixA.
-
inline std::size_t get_n()¶
Returns column number of the local matrix on each MPI node.
- Returns:
n_: the column number of the local matrix on each MPI node.
-
inline std::size_t get_m()¶
Returns row number of the local matrix.
- Returns:
m_: Row number of the local matrix on each MPI node.
-
inline std::size_t get_max_block()¶
Returns the maximum column number of rectangular matrix
V.- Returns:
max_block_: Maximum column number of matrixV.
-
inline std::size_t GetNev()¶
Returns number of desired extremal eigenpairs, which was set by users.
- Returns:
nev_: Number of desired extremal eigenpairs.
-
inline std::size_t GetNex()¶
Returns the Increment of the search subspace so that its total size, which was set by users within chase::ChaseConfig.
- Returns:
nex_: Increment of the search subspace.
-
inline std::size_t get_nb()¶
Returns the column blocking factor, this function is useful for ChASE with Block-Cyclic Distribution.
- Returns:
nb_: Column blocking factor.
-
inline std::size_t get_mb()¶
Returns the row blocking factor, this function is useful for ChASE with Block-Cyclic Distribution.
- Returns:
mb_: Row blocking factor.
-
inline MPI_Comm get_row_comm()¶
- Returns:
row_comm_: the row communicator within 2D MPI grid.
-
inline MPI_Comm get_col_comm()¶
- Returns:
col_comm_: the column communicator within 2D MPI grid.
-
inline int *get_dims()¶
Returns the dimension of cartesian communicator grid.
- Returns:
dims_: an array of size 2 which store the dimensions of the constructed 2D MPI grid.
-
inline std::size_t *get_off()¶
Returns offset of row and column of the local matrix on each MPI node regarding the index of row and column of global matrix
A.For example, for a global matrix
A,A_subis a submatrix ofAof sizem * n, which is extracted out ofAstarting from the row indexingiand column indexingj. This member function returnsiandjas an array of size 2 for the submatrix on each MPI rank. This member function is mostly used for ChASE with Block-Distribution.- Returns:
off_: an array of size 2 which stores the offset of row and column of the local matrix on each MPI node regarding the index of row and column of global matrixA.
-
inline void get_off(std::size_t *xoff, std::size_t *yoff, std::size_t *xlen, std::size_t *ylen)¶
Return the offset and length along the two dimensions of the local matrix on each MPI node regarding the global index of matrix
A.For example, for a global matrix
A,A_subis a submatrix ofAof sizem * n, which is extracted out ofAstarting from the row indexingiand column indexingj. This member function outputsxoff=i,yoff=j,xlen=m, andylen=nfor the submatrix on each MPI rank. This member function is mostly used for ChASE with Block-Distribution.- Parameters:
[in/out] – `xoff` -> the offset of row of the local matrix on each MPI node regarding the row index of matrix
A.[in/out] – `yoff` -> the offset of column of the local matrix on each MPI node regarding the column index of matrix
A.[in/out] – `xlen` -> the number of row of the local matrix on each MPI node.
[in/out] – `ylen` -> the number of column of the local matrix on each MPI node.
-
inline std::size_t get_mblocks()¶
This member function is mostly used for ChASE with Block-Cyclic Distribution. The number of submatrix on each MPI node is
mblocks_ * nblocks_.- Returns:
mblocks_: the number of submatrices in the local matrix on each MPI node along the row direction.
-
inline std::size_t get_nblocks()¶
This member function is mostly used for ChASE with Block-Cyclic Distribution. The number of submatrix on each MPI node is
mblocks_ * nblocks_.- Returns:
nblocks_: the number of submatrices in the local matrix on each MPI node along the column direction.
-
inline int get_irsrc()¶
This member function only matters for the Block-Cyclic Distribution.
- Returns:
irsrc_: the process row within 2D MPI grid over which the first row of the global matrixAis distributed.
-
inline int get_icsrc()¶
This member function only matters for the Block-Cyclic Distribution.
- Returns:
icsrc_: the process column within 2D MPI grid over which the first column of the global matrixAis distributed.
-
inline std::size_t *get_row_offs()¶
This member function only matters for the Block-Cyclic Distribution.
- Returns:
r_offs_.get(): the pointer to store offset of each subblock in local matrix along the row direction regarding the row direction of global matrixA.
-
inline std::size_t *get_row_lens()¶
This member function only matters for the Block-Cyclic Distribution.
- Returns:
r_lens_.get(): the pointer to store number of row of each subblock in local matrix along the row direction regarding the row direction of global matrixA.
-
inline std::size_t *get_row_offs_loc()¶
This member function only matters for the Block-Cyclic Distribution.
- Returns:
r_offs_l_.get(): the pointer to store offset of each subblock in local matrix along the row direction regarding the row direction of local matrix.
-
inline std::size_t *get_col_offs()¶
This member function only matters for the Block-Cyclic Distribution.
- Returns:
c_offs_.get(): the pointer to store offset of each subblock of local matrix along the column direction regarding the column direction of global matrixA.
-
inline std::size_t *get_col_lens()¶
This member function only matters for the Block-Cyclic Distribution.
- Returns:
c_lens_.get(): the pointer to store length of each subblock of local matrix along the column direction regarding the column direction of global matrixA.
-
inline std::size_t *get_col_offs_loc()¶
This member function only matters for the Block-Cyclic Distribution.
- Returns:
c_offs_l_.get(): the pointer to store offset of each subblock in local matrix along the column direction regarding the column direction of local matrix.
-
inline void get_offs_lens(std::size_t *&r_offs, std::size_t *&r_lens, std::size_t *&r_offs_l, std::size_t *&c_offs, std::size_t *&c_lens, std::size_t *&c_offs_l)¶
This member function only matters for the Block-Cyclic Distribution.
Return the pointers to
r_offs_,r_lens_,r_offs_l_,c_offs_,c_lens_andc_offs_l_in single member function.- Parameters:
[in/out] – `r_offs` -> the pointer to store offset of each subblock of local matrix along the row direction regarding the global indexing of matrix A. Its size is
mblocks_, which can be obtained by get_mblocks().[in/out] – `r_lens` -> the pointer to store length of each subblock of local matrix along the row direction regarding the global indexing of matrix A. Its size is
mblocks_, which can be obtained by get_mblocks().[in/out] – `r_offs_l` -> the pointer to store offset of each subblock of local matrix along the row direction regarding the indexing of local matrix. Its size is
mblocks_, which can be obtained by get_mblocks().[in/out] – `c_offs` -> the pointer to store offset of each subblock of local matrix along the column direction regarding the global indexing of matrix A. Its size is
nblocks_, which can be obtained by get_nblocks().[in/out] – `c_lens` -> the pointer to store length of each subblock of local matrix along the column direction regarding the global indexing of matrix A. Its size is
nblocks_, which can be obtained by get_nblocks().[in/out] – `c_offs_l` -> the pointer to store offset of each subblock of local matrix along the column direction regarding the indexing of local matrix. Its size is
nblocks_, which can be obtained by get_nblocks().
-
inline std::string get_dataLayout()¶
-
inline int *get_coord()¶
- Returns:
coord_: the coordinates of each MPI rank in the cartesian communicator grid.
-
inline std::size_t get_ldb()¶
- Returns:
n_: the leading dimension of the local matrix ofAin the row dimension.
-
inline std::size_t get_ldc()¶
- Returns:
m_: the leading dimension of the local matrix ofAin the column dimension.
-
inline T *get_IMT()¶
- Returns:
IMT_: a poniter to the memory which is used for the MPI collective communications for the MPI-based implementation of HEMM.
-
inline const std::vector<std::vector<int>> &get_blockcounts()¶
- Returns:
block_counts_: 2D array which stores the block number of local matrix on each MPI node in each dimension.
-
inline const std::vector<std::vector<std::vector<int>>> &get_blocklens()¶
- Returns:
block_lens_: 3D array which stores the size of each sublock on each MPI node in each dimension.
-
inline const std::vector<std::vector<std::vector<int>>> &get_blockdispls()¶
- Returns:
block_displs_: 3D array which stores the offset of each sublock on each MPI node in each dimension.
-
inline const std::vector<std::vector<int>> &get_sendlens()¶
- Returns:
send_lens_: 2D array which stores the size of local matrix on each MPI node in each dimension.
-
inline const std::vector<std::vector<int>> &get_g_offsets()¶
- Returns:
g_offsets_: 2D array which stores the offset of the first block (the most up and left one) on each MPI node in each dimension regarding the global indexing of matrix A.
-
inline int get_nprocs()¶
Returns the total number of MPI nodes within MPI communicator where ChASE is working on.
- Returns:
nprocs_: the total number of MPI nodes within the root MPI communicator.
-
inline int get_my_rank()¶
Returns the rank of MPI node within 2D grid.
- Returns:
rank_: the rank of MPI node within 2D grid.
-
inline ChaseMpiMatrices<T> create_matrices(T *V1 = nullptr, Base<T> *ritzv = nullptr, T *V2 = nullptr, Base<T> *resid = nullptr) const¶
Create a ChaseMpiMatrices object which stores the operating matrices and vectors for ChASE-MPI.
- Parameters:
V1 – a
N * max_block_rectangular matrix for the operationA*V1.ritzv – a
max_block_vector which stores the computed Ritz values.V2 – a
N * max_block_rectangular matrix for the operationV2^T*A.resid – a
max_block_vector which stores the residual of each computed Ritz value.
Private Members
-
std::size_t N_¶
Global size of the matrix A defining the eigenproblem.
This variable is initialized by the constructor using the value of the first of its input parameter
N. This variable is private, it can be access by the member function get_N().
-
std::size_t nev_¶
Number of desired extremal eigenpairs.
This variable is initialized by the constructor using the value of its input parameter
nev. This variable is private, it can be access by the member function GetNev().
-
std::size_t nex_¶
Increment of the search subspace so that its total size is
nev + nex.This variable is initialized by the constructor using the value of its input parameter
nex. This variable is private, it can be access by the member function GetNex().
-
std::size_t max_block_¶
Maximum column number of matrix
VThis variable is initialized by the constructor using the sum of its input parameter
nexandnev. Thus we havemax_block_=nev_+nex_. This variable is private, it can be access by the member function get_max_block().
-
std::size_t n_¶
Column number of the local matrix on each MPI node.
For Block Distribution, this variable is initialized based on the global size of matrix
Aand dimension of the column of 2D MPI grid.For Block-Cyclic Distribution, it is determined also by block size of submatrices
nb_, etc. This variable is private, it can be access by the member function get_n().
-
std::size_t m_¶
Row number of the local matrix on each MPI node.
For Block Distribution, this variable is initialized based on the global size of matrix
Aand dimension of the column of 2D MPI grid.For Block-Cyclic Distribution, it is determined also by block size of submatrices
mb_, etc. This variable is private, it can be access by the member function get_m().
-
std::size_t nb_¶
Column blocking factor.
For Block Distribution, this variable equals to the variable
n_.For Block-Cyclic Distribution, it is initialized by the parameter of the constructor
nb, This variable is private, it can be access by the member function get_nb().
-
std::size_t mb_¶
Row blocking factor.
For Block Distribution, this variable equals to the variable
m_.For Block-Cyclic Distribution, it is initialized by the parameter of the constructor
mb, This variable is private, it can be access by the member function get_mb().
-
std::size_t nblocks_¶
Number of submatrices along the column direction in the local matrix. Thus each local matrix is constructed by
mblocks_ * nblocks_blocks.For Block Distribution, this variable equals to 1.
For Block-Cyclic Distribution, it is initialized during the construction of Block-Cyclic scheme, This variable is private, it can be access by the member function get_nblocks().
-
std::size_t mblocks_¶
Number of submatrices along the row direction in the local matrix. Thus each local matrix is constructed by
mblocks_ * nblocks_blocks.For Block Distribution, this variable equals to 1.
For Block-Cyclic Distribution, it is initialized during the construction of Block-Cyclic scheme, This variable is private, it can be access by the member function get_mblocks().
-
int irsrc_¶
Process row over which the first row of the global matrix A is distributed.
This variable matters only for the Block-Cyclic Distribution, it is initialized by the parameter irsrc of the constructor. This variable is private, it can be access by the member function get_irsrc().
-
int icsrc_¶
Process column over which the first column of the global matrix A is distributed.
This variable matters only for the Block-Cyclic Distribution, it is initialized by the parameter irsrc of the constructor. This variable is private, it can be access by the member function get_icsrc().
-
std::unique_ptr<std::size_t[]> r_offs_¶
Offset of each subblock (especially for Block-Cyclic Distribution) along the row direction regarding the global indexing of matrix
A.This variable matters only for the Block-Cyclic Distribution, it is initialized during the setup of the Block-Cyclic Distribution scheme. This variable is private, it can be access by the member function get_row_offs() and get_offs_lens(). The size of this array is
mblocks_.
-
std::unique_ptr<std::size_t[]> r_lens_¶
Length of each subblock (especially for Block-Cyclic Distribution) along the row direction regarding the global indexing of matrix
A.This variable matters only for the Block-Cyclic Distribution, it is initialized during the setup of the Block-Cyclic Distribution scheme. This variable is private, it can be access by the member function get_row_lens() and get_offs_lens(). The size of this array is
mblocks_.
-
std::unique_ptr<std::size_t[]> r_offs_l_¶
Offset of each subblock (especially for Block-Cyclic Distribution) along the row direction regarding the indexing of local matrix on each MPI node.
This variable matters only for the Block-Cyclic Distribution, it is initialized during the setup of the Block-Cyclic Distribution scheme. This variable is private, it can be access by the member function get_row_offs_loc() and get_offs_lens(). The size of this array is
mblocks_.
-
std::unique_ptr<std::size_t[]> c_offs_¶
Offset of each subblock (especially for Block-Cyclic Distribution) along the column direction regarding the global indexing of matrix
A.This variable matters only for the Block-Cyclic Distribution, it is initialized during the setup of the Block-Cyclic Distribution scheme. This variable is private, it can be access by the member function get_col_offs() and get_offs_lens(). The size of this array is
nblocks_.
-
std::unique_ptr<std::size_t[]> c_lens_¶
Length of each subblock (especially for Block-Cyclic Distribution) along the column direction regarding the global indexing of matrix
A.This variable matters only for the Block-Cyclic Distribution, it is initialized during the setup of the Block-Cyclic Distribution scheme. This variable is private, it can be access by the member function get_col_lens() and get_offs_lens(). The size of this array is
nblocks_.
-
std::unique_ptr<std::size_t[]> c_offs_l_¶
Offset of each subblock (especially for Block-Cyclic Distribution) along the column direction regarding the indexing of local matrix on each MPI node.
This variable matters only for the Block-Cyclic Distribution, it is initialized during the setup of the Block-Cyclic Distribution scheme. This variable is private, it can be access by the member function get_col_offs_loc() and get_offs_lens(). The size of this array is
nblocks_.
-
std::vector<std::vector<int>> block_counts_¶
2D array which stores the block number of local matrix on each MPI node in each dimension.
This variable is equally shared by all the MPI nodes, which make the Block-Cyclic scheme within each MPI node be visible to all other MPI nodes.
The variable is especically useful for the MPI communication in the case that global matrix cannot be equally distributed to each MPI node.
For example, the block number within rank
i(this rank is within row_comm_) along the row dimension isblock_counts_[0][i], and the block number within rankj(this rank is within col_comm_) along the column dimension isblock_counts_[1][j]. For Block-Distribution, all the values in this 2D array equal to 1.
This variable is private, it can be access by the member function get_blockcounts().
-
std::vector<std::vector<std::vector<int>>> block_lens_¶
3D array which stores the length of each sublock on each MPI node in each dimension.
This variable is equally shared by all the MPI nodes, which make the Block-Cyclic scheme within each MPI node be visible to all other MPI nodes.
The variable is especically useful for the MPI communication in the case that global matrix cannot be equally distributed to each MPI node.
For example, the length of the block numbering
kth within ranki(this rank is within row_comm_) along the row dimension isblock_lens_[0][i][k], and the length of the block numberingkth the block number within rankj(this rank is within col_comm_) along the column dimension isblock_lens_[1][j][k].
This variable is private, it can be access by the member function get_blocklens().
-
std::vector<std::vector<std::vector<int>>> block_displs_¶
3D array which stores the offset of each sublock on each MPI node in each dimension.
This variable is equally shared by all the MPI nodes, which make the Block-Cyclic scheme within each MPI node be visible to all other MPI nodes.
The variable is especically useful for the MPI communication in the case that global matrix cannot be equally distributed to each MPI node.
For example, the offset of the block numbering
kth within ranki(this rank is within row_comm_) along the row dimension isblock_displs_[0][i][k], and the offset of the block numberingkth the block number within rankj(this rank is within col_comm_) along the column dimension isblock_displs_[1][j][k].
This variable is private, it can be access by the member function get_blocklens().
-
std::vector<std::vector<int>> send_lens_¶
2D array which stores the length of local matrix on each MPI node in each dimension.
This variable is equally shared by all the MPI nodes, which make the Block-Cyclic scheme within each MPI node be visible to all other MPI nodes.
The variable is especically useful for the MPI communication in the case that global matrix cannot be equally distributed to each MPI node.
For example, the length of local matrix within rank
i(this rank is within row_comm_) along the row dimension issend_lens_[0][i], and the block number within rankj(this rank is within col_comm_) along the column dimension issend_lens_[1][j].
This variable is private, it can be access by the member function get_sendlens().
-
std::vector<std::vector<int>> g_offsets_¶
2D array which stores the offset of the first block (the most up and left one) on each MPI node in each dimension regarding the global indexing of matrix
A.This variable is equally shared by all the MPI nodes, which make the Block-Cyclic scheme within each MPI node be visible to all other MPI nodes.
The variable is especically useful for the MPI communication in the case that global matrix cannot be equally distributed to each MPI node.
For example, the offset of first block of local matrix within rank
i(this rank is within row_comm_) along the row dimension isg_offsets_[0][i], and the block number within rankj(this rank is within col_comm_) along the column dimension isg_offsets_[1][j].
This variable is private, it can be access by the member function get_g_offsets().
-
MPI_Comm comm_¶
The MPI communicator which ChASE is working on.
This variable is initialized by the constructor using the value of its input parameters
comm.
-
int nprocs_¶
Total number of MPI nodes in the MPI communicator which ChASE is working on.
-
int rank_¶
The rank of each MPI node within the MPI communicator which ChASE is working on.
-
std::unique_ptr<T[]> H_¶
The memory allocated to store the local matrix of
Aon each MPI node.This variable is initialized during the construction of ChaseMpiProperties of size
n_ * m_.
-
std::unique_ptr<T[]> B_¶
A temporary memory allocated to store local part of V for the MPI collective communications for the MPI-based implementation of
HEMM.This variable is initialized during the construction of ChaseMpiProperties of size
n_ * max_block_.
-
std::unique_ptr<T[]> C_¶
A temporary memory allocated to store local part of W for the MPI collective communications for the MPI-based implementation of
HEMM.This variable is initialized during the construction of ChaseMpiProperties of size
m_ * max_block_.
-
std::unique_ptr<T[]> IMT_¶
A temporary memory the MPI collective communications for the MPI-based implementation of
HEMM.This variable is initialized during the construction of ChaseMpiProperties of size
std::max(n_, m_) * max_block_.
-
MPI_Comm row_comm_¶
The row communicator of the constructed 2D grid of MPI codes.
This variable is initialized in the constructor, after the construction of MPI 2D grid. This variable is private, it can be access by the member function get_row_comm().
-
MPI_Comm col_comm_¶
The column communicator of the constructed 2D grid of MPI codes.
This variable is initialized in the constructor, after the construction of MPI 2D grid. This variable is private, it can be access by the member function get_col_comm().
-
int dims_[2]¶
The array with two elements determines the dimension of 2D grid of MPI nodes.
For Block Distribution, it is initialized by
MPI_Dims_createwhich creates a division of MPI ranks in a cartesian grid.For Block-Cyclic Distribution, it is initialized by the input paramters
row_dimandcol_dim. More precise, we havedims_[0] = row_dimanddims_[1] = col_dim.
-
int coord_[2]¶
The array with two elements indicates the coordinates of each MPI node within the 2D grid of MPI nodes.
This variable is determined by the properties of 2D grid of MPI node.
-
std::size_t off_[2]¶
The array with two elements indicates the offset of the local matrix on each MPI node regarding the global index of matrix
A.This variable is determined by the properties of 2D grid of MPI node, the size of matrix and the scheme of distribution across the 2D grid.
-
std::string data_layout¶