Skip to content

Commit

Permalink
SIRIUS: Fix memory leaks
Browse files Browse the repository at this point in the history
  • Loading branch information
oschuett committed Jan 27, 2020
1 parent 8681da3 commit 611f900
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 30 deletions.
35 changes: 23 additions & 12 deletions src/pwdft_environment_types.F
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,22 @@
!> \author JHU
! **************************************************************************************************
MODULE pwdft_environment_types
USE ISO_C_BINDING, ONLY: C_NULL_PTR,&
C_PTR
USE cp_para_types, ONLY: cp_para_env_type
USE cp_subsys_types, ONLY: cp_subsys_type
USE input_section_types, ONLY: section_vals_type
USE kinds, ONLY: dp
USE qs_subsys_types, ONLY: qs_subsys_get,&
qs_subsys_release,&
qs_subsys_retain,&
qs_subsys_set,&
qs_subsys_type
USE ISO_C_BINDING, ONLY: C_NULL_PTR, &
C_PTR
USE cp_para_types, ONLY: cp_para_env_type
USE cp_subsys_types, ONLY: cp_subsys_type
USE input_section_types, ONLY: section_vals_type
USE kinds, ONLY: dp
USE qs_subsys_types, ONLY: qs_subsys_get, &
qs_subsys_release, &
qs_subsys_retain, &
qs_subsys_set, &
qs_subsys_type

#if defined(__SIRIUS)
USE sirius, ONLY: sirius_free_handler
#endif

#include "./base/base_uses.f90"

IMPLICIT NONE
Expand Down Expand Up @@ -129,7 +134,13 @@ SUBROUTINE pwdft_env_release(pwdft_env)
CPASSERT(pwdft_env%ref_count > 0)
pwdft_env%ref_count = pwdft_env%ref_count - 1
IF (pwdft_env%ref_count < 1) THEN
!

#if defined(__SIRIUS)
CALL sirius_free_handler(pwdft_env%gs_handler)
CALL sirius_free_handler(pwdft_env%ks_handler)
CALL sirius_free_handler(pwdft_env%sctx)
#endif

IF (ASSOCIATED(pwdft_env%qs_subsys)) THEN
CALL qs_subsys_release(pwdft_env%qs_subsys)
END IF
Expand Down
10 changes: 0 additions & 10 deletions tools/toolchain/scripts/install_sirius.sh
Original file line number Diff line number Diff line change
Expand Up @@ -246,16 +246,6 @@ export CP_LIBS="IF_MPI(IF_OMP("\${SIRIUS_LIBS}"|)|) \${CP_LIBS}"
EOF
fi

# ----------------------------------------------------------------------
# Suppress reporting of known leaks
# ----------------------------------------------------------------------
cat <<EOF >> ${INSTALLDIR}/lsan.supp
# Leaks in SIRIUS
leak:sddk::Communicator::cart_sub
leak:sddk::Communicator::split
leak:sddk::Communicator::cart_create
EOF

# update toolchain environment
load "${BUILDDIR}/setup_sirius"
export -p > "${INSTALLDIR}/toolchain.env"
Expand Down
8 changes: 0 additions & 8 deletions tools/toolchain/scripts/install_spfft.sh
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,6 @@ EOF
cat "${BUILDDIR}/setup_spfft" >> $SETUPFILE
fi

# ----------------------------------------------------------------------
# Suppress reporting of known leaks
# ----------------------------------------------------------------------
cat <<EOF >> ${INSTALLDIR}/lsan.supp
# Leaks in SpFFT
leak:spfft::MPICommunicatorHandle::MPICommunicatorHandle
EOF

# update toolchain environment
load "${BUILDDIR}/setup_spfft"
export -p > "${INSTALLDIR}/toolchain.env"
Expand Down

0 comments on commit 611f900

Please sign in to comment.