Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion source/module_base/global_function.h
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ T ddot_real(
//==========================================================
static inline bool IS_COLUMN_MAJOR_KS_SOLVER()
{
return GlobalV::KS_SOLVER=="genelpa" || GlobalV::KS_SOLVER=="scalapack_gvx" || GlobalV::KS_SOLVER=="cusolver";
return GlobalV::KS_SOLVER=="genelpa" || GlobalV::KS_SOLVER=="scalapack_gvx" || GlobalV::KS_SOLVER=="cusolver" || GlobalV::KS_SOLVER=="cg_in_lcao";
}

}//namespace GlobalFunc
Expand Down
6 changes: 3 additions & 3 deletions source/module_basis/module_ao/ORB_control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ void ORB_control::setup_2d_division(std::ofstream& ofs_running,
ofs_running << "\n SETUP THE DIVISION OF H/S MATRIX" << std::endl;

// (1) calculate nrow, ncol, nloc.
if (ks_solver == "genelpa" || ks_solver == "scalapack_gvx" || ks_solver == "cusolver")
if (ks_solver == "genelpa" || ks_solver == "scalapack_gvx" || ks_solver == "cusolver" || ks_solver == "cg_in_lcao")
{
ofs_running << " divide the H&S matrix using 2D block algorithms." << std::endl;
#ifdef __MPI
Expand All @@ -205,7 +205,7 @@ void ORB_control::setup_2d_division(std::ofstream& ofs_running,
bool div_2d;
if (ks_solver == "lapack" || ks_solver == "cg" || ks_solver == "dav") div_2d = false;
#ifdef __MPI
else if (ks_solver == "genelpa" || ks_solver == "scalapack_gvx" || ks_solver == "cusolver") div_2d = true;
else if (ks_solver == "genelpa" || ks_solver == "scalapack_gvx" || ks_solver == "cusolver" || ks_solver == "cg_in_lcao") div_2d = true;
#endif
else
{
Expand Down Expand Up @@ -382,7 +382,7 @@ assert(nb2d > 0);
}

// init blacs context for genelpa
if (ks_solver == "genelpa" || ks_solver == "scalapack_gvx" || ks_solver == "cusolver")
if (ks_solver == "genelpa" || ks_solver == "scalapack_gvx" || ks_solver == "cusolver" || ks_solver == "cg_in_lcao")
{
pv->set_desc(nlocal, nlocal, pv->nrow);
pv->set_desc_wfc_Eij(nlocal, nbands, pv->nrow);
Expand Down
8 changes: 4 additions & 4 deletions source/module_elecstate/elecstate_lcao.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ void ElecStateLCAO<std::complex<double>>::psiToRho(const psi::Psi<std::complex<d
// psi::Psi<std::complex<double>> dm_k_2d();

if (GlobalV::KS_SOLVER == "genelpa" || GlobalV::KS_SOLVER == "scalapack_gvx" || GlobalV::KS_SOLVER == "lapack"
|| GlobalV::KS_SOLVER == "cusolver") // Peize Lin test 2019-05-15
|| GlobalV::KS_SOLVER == "cusolver" || GlobalV::KS_SOLVER == "cg_in_lcao") // Peize Lin test 2019-05-15
{
//cal_dm(this->loc->ParaV, this->wg, psi, this->loc->dm_k);
elecstate::cal_dm_psi(this->DM->get_paraV_pointer(), this->wg, psi, *(this->DM));
Expand All @@ -124,7 +124,7 @@ void ElecStateLCAO<std::complex<double>>::psiToRho(const psi::Psi<std::complex<d

}
if (GlobalV::KS_SOLVER == "genelpa" || GlobalV::KS_SOLVER == "scalapack_gvx" || GlobalV::KS_SOLVER == "lapack"
|| GlobalV::KS_SOLVER == "cusolver")
|| GlobalV::KS_SOLVER == "cusolver" || GlobalV::KS_SOLVER == "cg_in_lcao")
{
for (int ik = 0; ik < psi.get_nk(); ik++)
{
Expand Down Expand Up @@ -175,7 +175,7 @@ void ElecStateLCAO<double>::psiToRho(const psi::Psi<double>& psi)
this->calEBand();

if (GlobalV::KS_SOLVER == "genelpa" || GlobalV::KS_SOLVER == "scalapack_gvx" || GlobalV::KS_SOLVER == "lapack"
|| GlobalV::KS_SOLVER == "cusolver")
|| GlobalV::KS_SOLVER == "cusolver" || GlobalV::KS_SOLVER == "cg_in_lcao")
{
ModuleBase::timer::tick("ElecStateLCAO", "cal_dm_2d");
// get DMK in 2d-block format
Expand All @@ -196,7 +196,7 @@ void ElecStateLCAO<double>::psiToRho(const psi::Psi<double>& psi)
{
// for gamma_only case, no convertion occured, just for print.
if (GlobalV::KS_SOLVER == "genelpa" || GlobalV::KS_SOLVER == "scalapack_gvx"
|| GlobalV::KS_SOLVER == "cusolver")
|| GlobalV::KS_SOLVER == "cusolver" || GlobalV::KS_SOLVER == "cg_in_lcao")
{
psi.fix_k(ik);
this->print_psi(psi);
Expand Down
4 changes: 4 additions & 0 deletions source/module_elecstate/elecstate_print.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,10 @@ void ElecState::print_etot(const bool converged,
{
label = "CG";
}
else if (ks_solver_type == "cg_in_lcao")
{
label = "CGAO";
}
else if (ks_solver_type == "lapack")
{
label = "LA";
Expand Down
15 changes: 11 additions & 4 deletions source/module_elecstate/module_dm/cal_dm_psi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,14 @@ void cal_dm_psi(const Parallel_Orbitals* ParaV,

// C++: dm(iw1,iw2) = wfc(ib,iw1).T * wg_wfc(ib,iw2)
#ifdef __MPI
psiMulPsiMpi(wg_wfc, wfc, dmk_pointer, ParaV->desc_wfc, ParaV->desc);

if (GlobalV::KS_SOLVER == "cg_in_lcao")
{
psiMulPsi(wg_wfc, wfc, dmk_pointer);
} else
{
psiMulPsiMpi(wg_wfc, wfc, dmk_pointer, ParaV->desc_wfc, ParaV->desc);
}
#else
psiMulPsi(wg_wfc, wfc, dmk_pointer);
#endif
Expand All @@ -126,7 +133,7 @@ void cal_dm_psi(const Parallel_Orbitals* ParaV,
return;
}

#ifdef __MPI
// #ifdef __MPI
void psiMulPsiMpi(const psi::Psi<double>& psi1,
const psi::Psi<double>& psi2,
double* dm_out,
Expand Down Expand Up @@ -195,7 +202,7 @@ void psiMulPsiMpi(const psi::Psi<std::complex<double>>& psi1,
ModuleBase::timer::tick("psiMulPsiMpi", "pdgemm");
}

#else
// #else
void psiMulPsi(const psi::Psi<double>& psi1, const psi::Psi<double>& psi2, double* dm_out)
{
const double one_float = 1.0, zero_float = 0.0;
Expand Down Expand Up @@ -241,6 +248,6 @@ void psiMulPsi(const psi::Psi<std::complex<double>>& psi1,
dm_out,
&nlocal);
}
#endif
// #endif

} // namespace elecstate
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ void Local_Orbital_wfc::gamma_file(psi::Psi<double>* psid, elecstate::ElecState*

//allocate psi
int ncol = this->ParaV->ncol_bands;
if (GlobalV::KS_SOLVER == "genelpa" || GlobalV::KS_SOLVER == "lapack_gvx" || GlobalV::KS_SOLVER == "scalapack_gvx"
if (GlobalV::KS_SOLVER == "genelpa" || GlobalV::KS_SOLVER == "lapack_gvx" || GlobalV::KS_SOLVER == "scalapack_gvx" || GlobalV::KS_SOLVER == "cg_in_lcao"
#ifdef __CUSOLVER_LCAO
|| GlobalV::KS_SOLVER == "cusolver"
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ void SpinConstrain<std::complex<double>, psi::DEVICE_CPU>::cal_mw_from_lambda(in
= dynamic_cast<elecstate::ElecStateLCAO<std::complex<double>>*>(this->pelec);
this->pelec->calculate_weights();
this->pelec->calEBand();
if (this->KS_SOLVER == "genelpa" || this->KS_SOLVER == "scalapack_gvx" || this->KS_SOLVER == "lapack")
if (this->KS_SOLVER == "genelpa" || this->KS_SOLVER == "scalapack_gvx" || this->KS_SOLVER == "lapack" || this->KS_SOLVER == "cg_in_lcao")
{
elecstate::cal_dm_psi(this->ParaV, pelec_lcao->wg, *(this->psi), *(pelec_lcao->get_DM()));
}
Expand Down
1 change: 1 addition & 0 deletions source/module_hsolver/diago_cg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,7 @@ void DiagoCG<T, Device>::diag(
namespace hsolver {
template class DiagoCG<std::complex<float>, psi::DEVICE_CPU>;
template class DiagoCG<std::complex<double>, psi::DEVICE_CPU>;
// template class DiagoCG<double, psi::DEVICE_CPU>;
#if ((defined __CUDA) || (defined __ROCM))
template class DiagoCG<std::complex<float>, psi::DEVICE_GPU>;
template class DiagoCG<std::complex<double>, psi::DEVICE_GPU>;
Expand Down
10 changes: 10 additions & 0 deletions source/module_hsolver/diago_iter_assist.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ class DiagoIterAssist
static Real PW_DIAG_THR;
static int PW_DIAG_NMAX;

static Real LCAO_DIAG_THR;
static int LCAO_DIAG_NMAX;


/// average steps of last cg diagonalization for each band.
static Real avg_iter;
static bool need_subspace;
Expand Down Expand Up @@ -90,6 +94,12 @@ int DiagoIterAssist<T, Device>::PW_DIAG_NMAX = 30;
template<typename T, typename Device>
typename DiagoIterAssist<T, Device>::Real DiagoIterAssist<T, Device>::PW_DIAG_THR = 1.0e-2;

template<typename T, typename Device>
int DiagoIterAssist<T, Device>::LCAO_DIAG_NMAX = 50;

template<typename T, typename Device>
typename DiagoIterAssist<T, Device>::Real DiagoIterAssist<T, Device>::LCAO_DIAG_THR = 1.0e-12;

template<typename T, typename Device>
bool DiagoIterAssist<T, Device>::need_subspace = false;

Expand Down
Loading