Skip to content

Commit 7f4224d

Browse files
authored
Merge pull request #94 from pplab/develop
change elpa set handle so it will only call once not in every ion step
2 parents c237afc + 5a4513f commit 7f4224d

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

source/src_io/write_wfc_realspace.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,4 +157,4 @@ namespace Write_Wfc_Realspace
157157
}
158158
#endif
159159
}
160-
};
160+
};

source/src_pdiag/pdiag_double.cpp

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -664,22 +664,29 @@ void Pdiag_Double::diago_double_begin(
664664
MPI_Bcast(&maxnloc, 1, MPI_LONG, 0, comm_2D);
665665
wfc_2d.create(this->ncol,this->nrow); // Fortran order
666666

667-
int is_already_decomposed, elpa_error;
668667
static elpa_t handle;
668+
static bool has_set_elpa_handle = false;
669+
if(! has_set_elpa_handle)
670+
{
671+
set_elpahandle(handle, desc, nrow, ncol);
672+
has_set_elpa_handle = true;
673+
}
669674

675+
int is_already_decomposed;
670676
if(ifElpaHandle(GlobalC::CHR.get_new_e_iteration(), (GlobalV::CALCULATION=="nscf")))
671677
{
672-
ModuleBase::timer::tick("Diago_LCAO_Matrix","elpa_set");
678+
ModuleBase::timer::tick("Diago_LCAO_Matrix","decompose_S");
673679
LapackConnector::copy(nloc, s_mat, inc, Stmp, inc);
674-
set_elpahandle(handle, desc, nrow, ncol);
675680
is_already_decomposed=0;
676-
ModuleBase::timer::tick("Diago_LCAO_Matrix","elpa_set");
681+
ModuleBase::timer::tick("Diago_LCAO_Matrix","decompose_S");
677682
}
678683
else
679684
{
680685
is_already_decomposed=1;
681686
}
687+
682688
ModuleBase::timer::tick("Diago_LCAO_Matrix","elpa_solve");
689+
int elpa_error;
683690
elpa_generalized_eigenvectors_d(handle, h_mat, Stmp, eigen, wfc_2d.c, is_already_decomposed, &elpa_error);
684691
ModuleBase::timer::tick("Diago_LCAO_Matrix","elpa_solve");
685692

@@ -1019,15 +1026,16 @@ void Pdiag_Double::diago_complex_begin(
10191026
MPI_Bcast(&maxnloc, 1, MPI_LONG, 0, comm_2D);
10201027
wfc_2d.create(this->ncol,this->nrow); // Fortran order
10211028

1022-
LapackConnector::copy(nloc, cs_mat, inc, Stmp, inc);
1023-
ModuleBase::timer::tick("Diago_LCAO_Matrix","elpa_set");
10241029
static elpa_t handle;
1025-
1026-
if(ifElpaHandle(GlobalC::CHR.get_new_e_iteration(), (GlobalV::CALCULATION=="nscf")))
1030+
static bool has_set_elpa_handle = false;
1031+
if(! has_set_elpa_handle)
10271032
{
10281033
set_elpahandle(handle, desc, nrow, ncol);
1034+
has_set_elpa_handle = true;
10291035
}
1030-
ModuleBase::timer::tick("Diago_LCAO_Matrix","elpa_set");
1036+
1037+
LapackConnector::copy(nloc, cs_mat, inc, Stmp, inc);
1038+
10311039
ModuleBase::timer::tick("Diago_LCAO_Matrix","elpa_solve");
10321040
int elpa_derror;
10331041
elpa_generalized_eigenvectors_dc(handle, reinterpret_cast<double _Complex*>(ch_mat),

0 commit comments

Comments
 (0)