Skip to content

Commit 9791f7e

Browse files
authored
Merge pull request #873 from pxlxingliang/develop
fix(hsolver): correct the dimension of input eigenvalue array in scalapack interface
2 parents a3afde1 + e217dbe commit 9791f7e

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

source/module_hsolver/diago_blas.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,21 @@ void DiagoBlas::diag(hamilt::Hamilt *phm_in, psi::Psi<double> &psi, double *eige
2626
matd h_mat, s_mat;
2727
phm_in->matrix(h_mat, s_mat);
2828
assert(h_mat.col == s_mat.col && h_mat.row == s_mat.row && h_mat.desc == s_mat.desc);
29-
this->pdsygvx_diag(h_mat.desc, h_mat.col, h_mat.row, h_mat.p, s_mat.p, eigenvalue_in, psi);
29+
std::vector<double> eigen(GlobalV::NLOCAL, 0.0);
30+
this->pdsygvx_diag(h_mat.desc, h_mat.col, h_mat.row, h_mat.p, s_mat.p, eigen.data(), psi);
31+
const int inc = 1;
32+
BlasConnector::copy(GlobalV::NBANDS, eigen.data(), inc, eigenvalue_in, inc);
3033
}
3134

3235
void DiagoBlas::diag(hamilt::Hamilt *phm_in, psi::Psi<std::complex<double>> &psi, double *eigenvalue_in)
3336
{
3437
matcd h_mat, s_mat;
3538
phm_in->matrix(h_mat, s_mat);
3639
assert(h_mat.col == s_mat.col && h_mat.row == s_mat.row && h_mat.desc == s_mat.desc);
37-
this->pzhegvx_diag(h_mat.desc, h_mat.col, h_mat.row, h_mat.p, s_mat.p, eigenvalue_in, psi);
40+
std::vector<double> eigen(GlobalV::NLOCAL, 0.0);
41+
this->pzhegvx_diag(h_mat.desc, h_mat.col, h_mat.row, h_mat.p, s_mat.p, eigen.data(), psi);
42+
const int inc = 1;
43+
BlasConnector::copy(GlobalV::NBANDS, eigen.data(), inc, eigenvalue_in, inc);
3844
}
3945

4046
std::pair<int, std::vector<int>> DiagoBlas::pdsygvx_once(const int *const desc,

source/src_pdiag/pdiag_double.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,11 @@ void Pdiag_Double::diago_double_begin(
307307
}
308308
else if(GlobalV::KS_SOLVER=="scalapack_gvx")
309309
{
310-
diag_scalapack_gvx.pdsygvx_diag(pv->desc, pv->ncol, pv->nrow, h_mat, s_mat, ekb, lowf.wfc_gamma[ik]); // Peize Lin add 2021.11.02
310+
double *eigen = new double[GlobalV::NLOCAL];
311+
ModuleBase::GlobalFunc::ZEROS(eigen, GlobalV::NLOCAL);
312+
diag_scalapack_gvx.pdsygvx_diag(pv->desc, pv->ncol, pv->nrow, h_mat, s_mat, eigen, lowf.wfc_gamma[ik]); // Peize Lin add 2021.11.02
313+
BlasConnector::copy(GlobalV::NBANDS, eigen, inc, ekb, inc);
314+
delete[] eigen;
311315
}
312316
//delete[] Stmp; //LiuXh 20171109
313317
#endif
@@ -482,8 +486,11 @@ void Pdiag_Double::diago_complex_begin(
482486
} // GenELPA method
483487
else if(GlobalV::KS_SOLVER=="scalapack_gvx")
484488
{
485-
diag_scalapack_gvx.pzhegvx_diag(pv->desc, pv->ncol, pv->nrow, ch_mat, cs_mat, ekb, lowf.wfc_k[ik]); // Peize Lin add 2021.11.02
486-
489+
double *eigen = new double[GlobalV::NLOCAL];
490+
ModuleBase::GlobalFunc::ZEROS(eigen, GlobalV::NLOCAL);
491+
diag_scalapack_gvx.pzhegvx_diag(pv->desc, pv->ncol, pv->nrow, ch_mat, cs_mat, eigen, lowf.wfc_k[ik]); // Peize Lin add 2021.11.02
492+
BlasConnector::copy(GlobalV::NBANDS, eigen, inc, ekb, inc);
493+
delete[] eigen;
487494
lowf.wfc_2d_to_grid(this->out_wfc_lcao, lowf.wfc_k[ik].c, lowf.wfc_k_grid[ik], ik);
488495

489496
}

0 commit comments

Comments
 (0)