ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
utils.h
Go to the documentation of this file.
1#ifndef ABACUS_SOURCE_HSOLVER_MODULE_GENELPA_UTILS_H
2#define ABACUS_SOURCE_HSOLVER_MODULE_GENELPA_UTILS_H
3
4#include <complex>
5#include <mpi.h>
6
7static inline int globalIndex(int localIndex, int nblk, int nprocs, int myproc)
8{
9 int iblock, gIndex;
10 iblock = localIndex / nblk;
11 gIndex = (iblock * nprocs + myproc) * nblk + localIndex % nblk;
12 return gIndex;
13}
14
15static inline int localIndex(int globalIndex, int nblk, int nprocs, int& lcoalProc)
16{
17 lcoalProc = int((globalIndex % (nblk * nprocs)) / nblk);
18 return int(globalIndex / (nblk * nprocs)) * nblk + globalIndex % nblk;
19}
20
21// load matrix from the file
22void loadMatrix(const char FileName[], int nFull, double* a, int* desca, int blacs_ctxt);
23
24void saveLocalMatrix(const char filePrefix[], int narows, int nacols, double* a);
25
26// use pdgemr2d to collect matrix from all processes to root process
27// and save to one completed matrix file
28void saveMatrix(const char FileName[], int nFull, double* a, int* desca, int blacs_ctxt);
29
30void loadMatrix(const char FileName[], int nFull, std::complex<double>* a, int* desca, int blacs_ctxt);
31
32void saveLocalMatrix(const char filePrefix[], int narows, int nacols, std::complex<double>* a);
33
34// use pzgemr2d to collect matrix from all processes to root process
35// and save to one completed matrix file
36void saveMatrix(const char FileName[], int nFull, std::complex<double>* a, int* desca, int blacs_ctxt);
37
38#endif // ABACUS_SOURCE_HSOLVER_MODULE_GENELPA_UTILS_H
void saveMatrix(const char FileName[], int nFull, double *a, int *desca, int blacs_ctxt)
Definition utils.cpp:107
void loadMatrix(const char FileName[], int nFull, double *a, int *desca, int blacs_ctxt)
Definition utils.cpp:15
void saveLocalMatrix(const char filePrefix[], int narows, int nacols, double *a)
Definition utils.cpp:73