Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: memory leak in tddft #4012

Merged
merged 3 commits into from
Apr 18, 2024
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
15 changes: 6 additions & 9 deletions source/module_hamilt_lcao/module_tddft/propagator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ namespace module_tddft
Propagator::~Propagator()
{
}

#ifdef __MPI

inline int globalIndex(int localindex, int nblk, int nprocs, int myproc)
Expand Down Expand Up @@ -584,24 +583,22 @@ void Propagator::compute_propagator_etrs(const int nlocal,
std::complex<double>* U_operator,
const int print_matrix) const
{
std::complex<double>* U1 = new std::complex<double>[this->ParaV->nloc];
std::complex<double>* U2 = new std::complex<double>[this->ParaV->nloc];
ModuleBase::GlobalFunc::ZEROS(U1, this->ParaV->nloc);
ModuleBase::GlobalFunc::ZEROS(U2, this->ParaV->nloc);
std::vector<std::complex<double>> U1(this->ParaV->nloc);
std::vector<std::complex<double>> U2(this->ParaV->nloc);
int tag = 2;
compute_propagator_taylor(nlocal, Stmp, Htmp, U1, print_matrix, tag);
compute_propagator_taylor(nlocal, Stmp, H_laststep, U2, print_matrix, tag);
compute_propagator_taylor(nlocal, Stmp, Htmp, U1.data(), print_matrix, tag);
compute_propagator_taylor(nlocal, Stmp, H_laststep, U2.data(), print_matrix, tag);
ScalapackConnector::gemm('N',
'N',
nlocal,
nlocal,
nlocal,
1.0,
U1,
U1.data(),
1,
1,
this->ParaV->desc,
U2,
U2.data(),
1,
1,
this->ParaV->desc,
Expand Down
6 changes: 3 additions & 3 deletions source/module_md/nhchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -441,9 +441,9 @@ void Nose_Hoover::restart(const std::string& global_readin_dir)
}

#ifdef __MPI
MPI_Bcast(&ok, 1, MPI_INT, 0, MPI_COMM_WORLD);
MPI_Bcast(&ok2, 1, MPI_INT, 0, MPI_COMM_WORLD);
MPI_Bcast(&ok3, 1, MPI_INT, 0, MPI_COMM_WORLD);
MPI_Bcast(&ok, 1, MPI_C_BOOL, 0, MPI_COMM_WORLD);
MPI_Bcast(&ok2, 1, MPI_C_BOOL, 0, MPI_COMM_WORLD);
MPI_Bcast(&ok3, 1, MPI_C_BOOL, 0, MPI_COMM_WORLD);
#endif

if (!ok)
Expand Down