[petsc-dev] Potential memory leak in PETSc - hypre interface when using Euclid

Jed Brown jed at jedbrown.org
Thu Oct 27 16:20:25 CDT 2022


I did this for one step and ten steps, then compared the output using meld.

$ PPROF_PATH=/usr/bin/pprof HEAPCHECK=normal LD_PRELOAD=/usr/lib/libtcmalloc.so mpich-clang/tests/ts/tutorials/ex15 -da_grid_x 20 -da_grid_y 20 -boundary 0 -ts_max_steps 20 -Jtype 1 -ts_monitor -pc_type hypre -pc_hypre_boomeramg_smooth_type Euclid -ts_max_steps 10 >& ten.log


There are several stack traces that leak memory per step, but they look similar to this.

Leak of 99560 bytes in 95 objects allocated from:
	@ 7f3b8a4f8311 hypre_HostMalloc
	@ 7f3b8a4f7843 hypre_Free_core
	@ 7f3b8a4f7bdc hypre_Memcpy_core
	@ 7f3b8a1180bb Mem_dhMalloc
	@ 7f3b8a0f5f95 Euclid_dhSetup
	@ 7f3b8a1697b7 HYPRE_EuclidSetup
	@ 7f3b8a3d8b59 hypre_BoomerAMGSetup
	@ 7f3b8a165a9d HYPRE_BoomerAMGSolveT
	@ 7f3b8d9f1b40 PCSetUp_HYPRE
	@ 7f3b8d3a2622 PCSetUp
	@ 7f3b8cfe0f05 KSPSetUp
	@ 7f3b8cfe9f55 KSPSolve_Private
	@ 7f3b8cfe91b3 KSPSolve
	@ 7f3b8ddd5700 SNESSolve_NEWTONLS
	@ 7f3b8dbe4bd4 SNESSolve
	@ 7f3b8e11d363 TSTheta_SNESSolve
	@ 7f3b8e1018bf TSAdjointStep_Theta
	@ 7f3b8dfaa

Barry Smith <bsmith at petsc.dev> writes:

>   My quick examination of hypre.c shows the only relevant code in PETSc is 
>
>  PetscCall(PetscOptionsEList("-pc_hypre_boomeramg_smooth_type", "Enable more complex smoothers", "None", HYPREBoomerAMGSmoothType, PETSC_STATIC_ARRAY_LENGTH(HYPREBoomerAMGSmoothType), HYPREBoomerAMGSmoothType[0], &indx, &flg));
>   if (flg) {
>     jac->smoothtype = indx;
>     PetscCallExternal(HYPRE_BoomerAMGSetSmoothType, jac->hsolver, indx + 6);
>
> In other words PETSc just sends this option off to hypre and does not create any objects or allocate any memory based on this option.
>
> Thus my conclusion is the memory leak is within hypre. Likely valgrind would locate the exact position easily.
>
>> On Oct 27, 2022, at 4:27 PM, Emil Constantinescu via petsc-dev <petsc-dev at mcs.anl.gov> wrote:
>> 
>> Hi there,
>> 
>> Tang Qi (LANL) reported a potential memory leak when using hypre/Euclid. Upon rudimentary testing, I could reproduce it for many examples in PETSc TS. The symptom is memory usage (measured with top)  with the number of time steps. Without Euclid, memory use does not increase.
>> 
>> For instance, one can try ex15 under TS:
>> 
>> ex15  -da_grid_x 50 -da_grid_y 50 -boundary 0 -ts_max_steps 20 -Jtype 1 -ts_monitor -pc_type hypre -pc_hypre_boomeramg_smooth_type Euclid
>> 
>> I am not sure if it's PETSc - hypre that causes the memory use or hypre itself.
>> 
>> Can someone with more sophisticated tools take a look at it?
>> 
>> Emil


More information about the petsc-dev mailing list