hypre icon indicating copy to clipboard operation
hypre copied to clipboard

Valgrind error

Open fdkong opened this issue 2 years ago • 3 comments

It seems that HYPRE is not valgrind clean

A petsc example:

[rocky-8][~/workhome/rod/moose/petsc/src/ksp/ksp/tutorials]> valgrind --leak-check=full --tool=memcheck --dsymutil=yes --track-origins=yes --demangle=yes ./ex29 -ksp_view -pc_type hypre
==3240472== Memcheck, a memory error detector
==3240472== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==3240472== Using Valgrind-3.15.0 and LibVEX; rerun with -h for copyright info
==3240472== Command: ./ex29 -ksp_view -pc_type hypre
==3240472== 
hwloc x86 backend cannot work under Valgrind, disabling.
May be reenabled by dumping CPUIDs with hwloc-gather-cpuid
and reloading them under Valgrind with HWLOC_CPUID_PATH.

KSP Object: 1 MPI processes
 type: gmres
  restart=30, using Classical (unmodified) Gram-Schmidt Orthogonalization with no iterative refinement
  happy breakdown tolerance 1e-30
 maximum iterations=10000, initial guess is zero
 tolerances: relative=1e-05, absolute=1e-50, divergence=10000.
 left preconditioning
 using PRECONDITIONED norm type for convergence test
PC Object: 1 MPI processes
 type: hypre
  HYPRE BoomerAMG preconditioning
   Cycle type V
   Maximum number of levels 25
   Maximum number of iterations PER hypre call 1
   Convergence tolerance PER hypre call 0.
   Threshold for strong coupling 0.25
   Interpolation truncation factor 0.
   Interpolation: max elements per row 0
   Number of levels of aggressive coarsening 0
   Number of paths for aggressive coarsening 1
   Maximum row sums 0.9
   Sweeps down     1
   Sweeps up      1
   Sweeps on coarse  1
   Relax down     symmetric-SOR/Jacobi
   Relax up      symmetric-SOR/Jacobi
   Relax on coarse   Gaussian-elimination
   Relax weight (all)   1.
   Outer relax weight (all) 1.
   Using CF-relaxation
   Not using more complex smoothers.
   Measure type    local
   Coarsen type    Falgout
   Interpolation type classical
 linear system matrix = precond matrix:
 Mat Object: 1 MPI processes
  type: seqaij
  rows=9, cols=9
  total: nonzeros=33, allocated nonzeros=33
  total number of mallocs used during MatSetValues calls=0
   not using I-node routines
==3240472== 
==3240472== HEAP SUMMARY:
==3240472==   in use at exit: 916,481 bytes in 10,786 blocks
==3240472==  total heap usage: 49,019 allocs, 38,233 frees, 1,353,537,861 bytes allocated
==3240472== 
==3240472== 89,760 bytes in 255 blocks are possibly lost in loss record 15 of 18
==3240472==  at 0x4C38CE4: calloc (vg_replace_malloc.c:762)
==3240472==  by 0x40129EB: _dl_allocate_tls (in /usr/lib64/ld-2.28.so)
==3240472==  by 0x7BF4DD2: pthread_create@@GLIBC_2.2.5 (in /usr/lib64/libpthread-2.28.so)
==3240472==  by 0xAA1AC35: gomp_team_start (team.c:836)
==3240472==  by 0xAA1170C: GOMP_parallel (parallel.c:169)
==3240472==  by 0x6850A95: hypre_IJMatrixInitializeParCSR_v2 (IJMatrix_parcsr.c:308)
==3240472==  by 0x684BAAF: HYPRE_IJMatrixInitialize_v2 (HYPRE_IJMatrix.c:200)
==3240472==  by 0x52B5083: MatHYPRE_IJMatrixCopy (mhypre.c:141)
==3240472==  by 0x52B5083: MatConvert_AIJ_HYPRE (mhypre.c:411)
==3240472==  by 0x54D2469: MatConvert (matrix.c:4435)
==3240472==  by 0x586A73D: PCSetUp_HYPRE (hypre.c:243)
==3240472==  by 0x5A009F9: PCSetUp (precon.c:1017)
==3240472==  by 0x5AF42C7: KSPSetUp (itfunc.c:408)
==3240472== 
==3240472== LEAK SUMMARY:
==3240472==  definitely lost: 0 bytes in 0 blocks
==3240472==  indirectly lost: 0 bytes in 0 blocks
==3240472==   possibly lost: 89,760 bytes in 255 blocks
==3240472==  still reachable: 826,721 bytes in 10,531 blocks
==3240472==     suppressed: 0 bytes in 0 blocks
==3240472== Reachable blocks (those to which a pointer was found) are not shown.
==3240472== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==3240472== 
==3240472== For lists of detected and suppressed errors, rerun with: -s
==3240472== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)

A MOOSE example:

- [ ] test:GBAnisotropy.test1: ==1365016== 
- [ ] test:GBAnisotropy.test1: ==1365016== 24 bytes in 1 blocks are definitely lost in loss record 5 of 25
- [ ] test:GBAnisotropy.test1: ==1365016==    at 0x4C38CE4: calloc (vg_replace_malloc.c:762)
- [ ] test:GBAnisotropy.test1: ==1365016==    by 0xD5C7366: hypre_HostMalloc (memory.c:174)
- [ ] test:GBAnisotropy.test1: ==1365016==    by 0xD5C7366: hypre_MAlloc_core (memory.c:320)
- [ ] test:GBAnisotropy.test1: ==1365016==    by 0xD5C7366: hypre_CAlloc (memory.c:806)
- [ ] test:GBAnisotropy.test1: ==1365016==    by 0xD5C6F91: hypre_IntArrayCreate (int_array.c:26)
- [ ] test:GBAnisotropy.test1: ==1365016==    by 0xD363CB6: hypre_BoomerAMGCoarseParmsHost (par_coarse_parms.c:89)
- [ ] test:GBAnisotropy.test1: ==1365016==    by 0xD363D6C: hypre_BoomerAMGCoarseParms (par_coarse_parms.c:155)
- [ ] test:GBAnisotropy.test1: ==1365016==    by 0xD35345F: hypre_BoomerAMGSetup (par_amg_setup.c:1455)
- [ ] test:GBAnisotropy.test1: ==1365016==    by 0xD33104B: HYPRE_BoomerAMGSetup (HYPRE_parcsr_amg.c:47)
- [ ] test:GBAnisotropy.test1: ==1365016==    by 0xC3276B5: PCSetUp_HYPRE (hypre.c:418)
- [ ] test:GBAnisotropy.test1: ==1365016==    by 0xC48DF0A: PCSetUp (precon.c:1017)
- [ ] test:GBAnisotropy.test1: ==1365016==    by 0xC55F4A8: KSPSetUp (itfunc.c:408)
- [ ] test:GBAnisotropy.test1: ==1365016==    by 0xC561516: KSPSolve_Private (itfunc.c:852)
- [ ] test:GBAnisotropy.test1: ==1365016==    by 0xC564724: KSPSolve (itfunc.c:1086)

fdkong avatar Mar 11 '22 03:03 fdkong

Not sure if this is a real hypre issue or an OpenMP issue.

liruipeng avatar Mar 11 '22 05:03 liruipeng

For the 2nd leak, a fix has been done https://github.com/hypre-space/hypre/pull/491. Which version of hypre is being used?

liruipeng avatar Mar 11 '22 05:03 liruipeng

Hmmm. that did not fix the issue. I did not have time to come up a patch yet. I will work on a patch from my side

If possible, we should not close this issue

fdkong avatar Apr 07 '22 16:04 fdkong

@fdkong, can you still reproduce this issue? It's clean on my end.

$ valgrind --leak-check=full --tool=memcheck --dsymutil=yes --track-origins=yes --demangle=yes ./ex29 -ksp_view -pc_type hypre
==1111== Memcheck, a memory error detector
==1111== Copyright (C) 2002-2022, and GNU GPL'd, by Julian Seward et al.
==1111== Using Valgrind-3.19.0 and LibVEX; rerun with -h for copyright info
==1111== Command: ./ex29 -ksp_view -pc_type hypre
==1111== 
==1111== WARNING: valgrind ignores shmget(shmflg) SHM_HUGETLB
KSP Object: 1 MPI process
  type: gmres
    restart=30, using Classical (unmodified) Gram-Schmidt Orthogonalization with no iterative refinement
    happy breakdown tolerance 1e-30
  maximum iterations=10000, initial guess is zero
  tolerances:  relative=1e-05, absolute=1e-50, divergence=10000.
  left preconditioning
  using PRECONDITIONED norm type for convergence test
PC Object: 1 MPI process
  type: hypre
    HYPRE BoomerAMG preconditioning
      Cycle type V
      Maximum number of levels 25
      Maximum number of iterations PER hypre call 1
      Convergence tolerance PER hypre call 0.
      Threshold for strong coupling 0.25
      Interpolation truncation factor 0.
      Interpolation: max elements per row 0
      Number of levels of aggressive coarsening 0
      Number of paths for aggressive coarsening 1
      Maximum row sums 0.9
      Sweeps down         1
      Sweeps up           1
      Sweeps on coarse    1
      Relax down          symmetric-SOR/Jacobi
      Relax up            symmetric-SOR/Jacobi
      Relax on coarse     Gaussian-elimination
      Relax weight  (all)      1.
      Outer relax weight (all) 1.
      Using CF-relaxation
      Not using more complex smoothers.
      Measure type        local
      Coarsen type        Falgout
      Interpolation type  classical
      SpGEMM type         cusparse
  linear system matrix = precond matrix:
  Mat Object: 1 MPI process
    type: seqaij
    rows=9, cols=9
    total: nonzeros=33, allocated nonzeros=33
    total number of mallocs used during MatSetValues calls=0
      not using I-node routines
==1111== 
==1111== HEAP SUMMARY:
==1111==     in use at exit: 6,049 bytes in 23 blocks
==1111==   total heap usage: 9,747 allocs, 9,634 frees, 8,358,119 bytes allocated
==1111== 
==1111== LEAK SUMMARY:
==1111==    definitely lost: 0 bytes in 0 blocks
==1111==    indirectly lost: 0 bytes in 0 blocks
==1111==      possibly lost: 0 bytes in 0 blocks
==1111==    still reachable: 2,473 bytes in 17 blocks
==1111==         suppressed: 3,576 bytes in 6 blocks
==1111== Reachable blocks (those to which a pointer was found) are not shown.
==1111== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==1111== 
==1111== For lists of detected and suppressed errors, rerun with: -s
==1111== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 1 from 1)

prj- avatar Oct 30 '22 06:10 prj-

@liruipeng, I think you can close this issue, this is now clean in PETSc.

prj- avatar Nov 03 '22 20:11 prj-