ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
dist_matrix_transformer.h
Go to the documentation of this file.
1#ifndef DISTMATRIXTRANSFORMER_H
2#define DISTMATRIXTRANSFORMER_H
3
4#include <mpi.h>
5#include <map>
6#include <vector>
7// transform a sparse matrix from block cyclic distribution (BCD) to Compressed Column Storage (CCS) distribution
8// they should have same MPI communicator
9// The local matrix of BCD is column-major order
10// int transformBCDtoCCS(DistBCDMatrix &SRC_Matrix, double* H_2d, const double ZERO_Limit,
11// DistCCSMatrix &DST_Matrix, double*& H_ccs);
12
13// transform two sparse matrices from block cyclic distribution (BCD) to Compressed Column Storage (CCS) distribution
14// two destination matrices share the same non-zero elements positions
15// if either of two elements in source matrices is non-zeros, the elements in the destination matrices are non-zero,
16// even if one of them is acturely zero All matrices must have same MPI communicator
17namespace pexsi
18{
19class DistBCDMatrix;
20class DistCCSMatrix;
21
22namespace DistMatrixTransformer
23{
24int MinimumIndexPosition(const bool isFirst,
25 const int nprocs,
26 int* size_process,
27 int* displacement_process,
28 const int* index);
29
30void buildCCSParameter(const int size,
31 const int nprocs,
32 std::vector<int> size_process,
33 std::vector<int> displacement_process,
34 const int* position_index,
35 DistCCSMatrix& DST_Matrix,
36 int* buffer2ccsIndex);
37
38void buffer2CCSvalue(int nnzLocal, int* buffer2ccsIndex, double* buffer, double* nzvalLocal);
39
40void countMatrixDistribution(int N, double* A, std::map<int, int>& P);
41
42int getNonZeroIndex(char layout,
43 const int nrow,
44 const int ncol,
45 double* H_2d,
46 double* S_2d,
47 const double ZERO_Limit,
48 int& nnz,
49 std::vector<int>& rowidx,
50 std::vector<int>& colidx);
51
53 DistCCSMatrix& DST_Matrix,
54 const int NPROC_TRANS,
55 MPI_Group& GROUP_TRANS,
56 MPI_Comm& COMM_TRANS,
57 const int nnz,
58 std::vector<int>& rowidx,
59 std::vector<int>& colidx,
60 int& sender_size,
61 std::vector<int>& sender_size_process,
62 std::vector<int>& sender_displacement_process,
63 int& receiver_size,
64 std::vector<int>& receiver_size_process,
65 std::vector<int>& receiver_displacement_process,
66 std::vector<int>& buffer2ccsIndex);
67
69 DistCCSMatrix& DST_Matrix,
70 MPI_Group& GROUP_TRANS,
71 MPI_Comm& COMM_TRANS);
72
73int deleteGroupCommTrans(MPI_Group& GROUP_TRANS, MPI_Comm& COMM_TRANS);
74
76 double* H_2d,
77 double* S_2d,
78 const double ZERO_Limit,
79 DistCCSMatrix& DST_Matrix,
80 double*& H_ccs,
81 double*& S_ccs);
82
84 double* DMnzvalLocal,
85 double* ENDnzvalLocal,
86 DistBCDMatrix& DST_Matrix,
87 double* DM_2d,
88 double* ED_2d);
89}; // namespace DistMatrixTransformer
90} // namespace pexsi
91#endif // DISTMATRIXTRANSFORMER_H
Definition dist_bcd_matrix.h:14
Definition dist_ccs_matrix.h:10
#define N
Definition exp.cpp:24
void countMatrixDistribution(int N, double *A, std::map< int, int > &P)
int transformBCDtoCCS(DistBCDMatrix &SRC_Matrix, double *H_2d, double *S_2d, const double ZERO_Limit, DistCCSMatrix &DST_Matrix, double *&H_ccs, double *&S_ccs)
int buildTransformParameter(DistBCDMatrix &SRC_Matrix, DistCCSMatrix &DST_Matrix, const int NPROC_TRANS, MPI_Group &GROUP_TRANS, MPI_Comm &COMM_TRANS, const int nnz, std::vector< int > &rowidx, std::vector< int > &colidx, int &sender_size, std::vector< int > &sender_size_process, std::vector< int > &sender_displacement_process, int &receiver_size, std::vector< int > &receiver_size_process, std::vector< int > &receiver_displacement_process, std::vector< int > &buffer2ccsIndex)
int getNonZeroIndex(char layout, const int nrow, const int ncol, double *H_2d, double *S_2d, const double ZERO_Limit, int &nnz, std::vector< int > &rowidx, std::vector< int > &colidx)
int MinimumIndexPosition(const bool isFirst, const int nprocs, int *size_process, int *displacement_process, const int *index)
int deleteGroupCommTrans(MPI_Group &GROUP_TRANS, MPI_Comm &COMM_TRANS)
int transformCCStoBCD(DistCCSMatrix &SRC_Matrix, double *DMnzvalLocal, double *ENDnzvalLocal, DistBCDMatrix &DST_Matrix, double *DM_2d, double *ED_2d)
void buildCCSParameter(const int size, const int nprocs, std::vector< int > size_process, std::vector< int > displacement_process, const int *position_index, DistCCSMatrix &DST_Matrix, int *buffer2ccsIndex)
void buffer2CCSvalue(int nnzLocal, int *buffer2ccsIndex, double *buffer, double *nzvalLocal)
int newGroupCommTrans(DistBCDMatrix &SRC_Matrix, DistCCSMatrix &DST_Matrix, MPI_Group &GROUP_TRANS, MPI_Comm &COMM_TRANS)
Definition dist_bcd_matrix.h:12