Skip to content

Commit 048346c

Browse files
committed
Fix: add __MPI for diago_elpa
1 parent c43c3e4 commit 048346c

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

source/module_hsolver/diago_elpa.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include "module_base/global_variable.h"
44
#include "module_base/lapack_connector.h"
55
#include "module_base/timer.h"
6+
#include "module_base/tool_quit.h"
67
extern "C"
78
{
89
#include "module_base/blacs_connector.h"
@@ -54,6 +55,7 @@ inline int set_elpahandle(elpa_t &handle,
5455

5556
void DiagoElpa::diag(hamilt::Hamilt *phm_in, psi::Psi<std::complex<double>> &psi, double *eigenvalue_in)
5657
{
58+
#ifdef __MPI
5759
matcd h_mat, s_mat;
5860
phm_in->matrix(h_mat, s_mat);
5961

@@ -86,10 +88,14 @@ void DiagoElpa::diag(hamilt::Hamilt *phm_in, psi::Psi<std::complex<double>> &psi
8688
// the eigenvalues.
8789
const int inc = 1;
8890
BlasConnector::copy(GlobalV::NBANDS, eigen.data(), inc, eigenvalue_in, inc);
91+
#elif
92+
ModuleBase::WARNING_QUIT("DiagoElpa", "DiagoElpa only can be used with macro __MPI");
93+
#endif
8994
}
9095

9196
void DiagoElpa::diag(hamilt::Hamilt *phm_in, psi::Psi<double> &psi, double *eigenvalue_in)
9297
{
98+
#ifdef __MPI
9399
matd h_mat, s_mat;
94100
phm_in->matrix(h_mat, s_mat);
95101

@@ -134,8 +140,12 @@ void DiagoElpa::diag(hamilt::Hamilt *phm_in, psi::Psi<double> &psi, double *eige
134140
ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running, "K-S equation was solved by genelpa2");
135141
BlasConnector::copy(GlobalV::NBANDS, eigen.data(), inc, eigenvalue_in, inc);
136142
ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running, "eigenvalues were copied to ekb");
143+
#elif
144+
ModuleBase::WARNING_QUIT("DiagoElpa", "DiagoElpa only can be used with macro __MPI");
145+
#endif
137146
}
138147

148+
#ifdef __MPI
139149
bool DiagoElpa::ifElpaHandle(const bool &newIteration, const bool &ifNSCF)
140150
{
141151
int doHandle = false;
@@ -145,5 +155,6 @@ bool DiagoElpa::ifElpaHandle(const bool &newIteration, const bool &ifNSCF)
145155
doHandle = true;
146156
return doHandle;
147157
}
158+
#endif
148159

149160
} // namespace hsolver

source/module_hsolver/diago_elpa.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ class DiagoElpa : public DiagH
1616
void diag(hamilt::Hamilt* phm_in, psi::Psi<std::complex<double>>& psi, double* eigenvalue_in) override;
1717

1818
private:
19+
#ifdef __MPI
1920
bool ifElpaHandle(const bool& newIteration, const bool& ifNSCF);
21+
#endif
2022

2123
static bool is_already_decomposed;
2224
};

0 commit comments

Comments
 (0)