From 471243f6e29ac03a87936675e6c4bb04e6b43daa Mon Sep 17 00:00:00 2001 From: Chun Cai Date: Thu, 11 Jan 2024 20:26:52 +0800 Subject: [PATCH] Fix: elpa memory leak (#3472) * Fix: elpa memory leak * Fix assertion condition in `to_numerical_orbital_lm` * Remove outdated assertion --- source/module_basis/module_nao/numerical_radial.cpp | 8 ++++---- source/module_hamilt_pw/hamilt_pwdft/hamilt_pw.cpp | 3 --- source/module_hsolver/genelpa/elpa_new.cpp | 1 + 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/source/module_basis/module_nao/numerical_radial.cpp b/source/module_basis/module_nao/numerical_radial.cpp index 238e443fb9..df3fa9258f 100644 --- a/source/module_basis/module_nao/numerical_radial.cpp +++ b/source/module_basis/module_nao/numerical_radial.cpp @@ -158,9 +158,9 @@ void NumericalRadial::build(const int l, void NumericalRadial::to_numerical_orbital_lm(Numerical_Orbital_Lm& orbital_lm, const int nk_legacy, const double lcao_dk) const { #ifdef __DEBUG - assert(rgrid_ && kgrid_); - assert(rgrid_[0] == 0.0 && kgrid_[0] == 0.0); - assert(is_uniform(nr_, rgrid_, 1e-14) && is_uniform(nk_, kgrid_, 1e-14)); + assert(rgrid_); + assert(rgrid_[0] == 0.0); + assert(is_uniform(nr_, rgrid_, 1e-14)); // Numerical_Orbital_Lm does not support extra exponent in the real space value assert(pr_ == 0); @@ -329,7 +329,7 @@ void NumericalRadial::wipe(const bool r_space, const bool k_space) pr_ = 0; ircut_ = 0; } - + if (k_space) { delete[] kgrid_; diff --git a/source/module_hamilt_pw/hamilt_pwdft/hamilt_pw.cpp b/source/module_hamilt_pw/hamilt_pwdft/hamilt_pw.cpp index 1bd03f2cd5..b9aedf3175 100644 --- a/source/module_hamilt_pw/hamilt_pwdft/hamilt_pw.cpp +++ b/source/module_hamilt_pw/hamilt_pwdft/hamilt_pw.cpp @@ -214,9 +214,6 @@ void HamiltPW::sPsi(const T* psi_in, // psi if(GlobalV::use_paw) { #ifdef USE_PAW -#ifdef __DEBUG - assert(psi.get_k_first()); -#endif for(int m = 0; m < nbands; m ++) { GlobalC::paw_cell.paw_nl_psi(1, reinterpret_cast*> (&psi_in[m * npw]), diff --git a/source/module_hsolver/genelpa/elpa_new.cpp b/source/module_hsolver/genelpa/elpa_new.cpp index d3ef6b79f1..e72fb0490d 100644 --- a/source/module_hsolver/genelpa/elpa_new.cpp +++ b/source/module_hsolver/genelpa/elpa_new.cpp @@ -206,6 +206,7 @@ void ELPA_Solver::exit() logfile.close(); int error; elpa_deallocate(NEW_ELPA_HANDLE_POOL[handle_id], &error); + elpa_uninit(&error); } int ELPA_Solver::read_cpuflag()