Skip to content

Commit

Permalink
Fix: memory leak in tddft (#4012)
Browse files Browse the repository at this point in the history
* Fix: memory leak in tddft

* fix mpi type

* fix missed data access
  • Loading branch information
caic99 authored Apr 18, 2024
1 parent 6c366b1 commit 277e92d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
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

0 comments on commit 277e92d

Please sign in to comment.