[petsc-users] Valgrind Errors with KSPSolve

Matthew Knepley knepley at gmail.com
Fri Oct 26 09:01:17 CDT 2018


On Fri, Oct 26, 2018 at 9:54 AM Phil Tooley <phil.tooley at sheffield.ac.uk>
wrote:

> Hi All,
>
> Running valgrind over my code reveals a huge number (it stops collecting
> after 1e6) of uninitialised value errors occuring the KSPSolve routine.
> These don't occur with the ksp example scripts but I can't figure out
> what I am doing wrong in my code.  My code works as expected.  The same
> errors occur with both version 3.9.4 and 3.10.0.
>
> I am developing in c++ and using smart pointers to allow autodestruction
> of Petsc objects, but I don't think this should have any side effects.
>

>From casual inspection, it sure seems like the matrix you are passing KSP
has unitialized
values.

<Editorial comment>I used smart pointers for years, and work on packages
that had smart
pointers. In almost every case, we ended up ripping out the smart pointers
and going with
explicit destruction, the amount of work they save never outweighed the
problems with
detecting errors</Editorial comment>

  Thanks,

     Matt

  Thanks,

    Matt


> I do the ksp setup as:
>
> KSP_unique m_ksp = create_unique_ksp();
>
> perr = KSPCreate(m_comm, m_ksp.get());CHKERRABORT(m_comm, perr);
>
> perr = KSPSetOperators(*m_ksp, *normmat, *normmat);CHKERRABORT(m_comm,
> perr);
> perr = KSPSetUp(*m_ksp);CHKERRABORT(m_comm, perr);
>
> perr = KSPSetFromOptions(*m_ksp);CHKERRABORT(m_comm, perr);
> perr = KSPSetUp(*m_ksp);CHKERRABORT(m_comm, perr);
>
> perr = KSPSolve(*m_ksp, *m_rhs, *m_delta);CHKERRABORT(m_comm, perr);
>
> Where normmat is a smart pointer to a previously created Mat object and
> m_rhs and m_delta are smart pointers to Vec objects which are
> initialised using MatCreateVecs on normmat.
>
> I am using MPICH to provide a (hopefully) valgrind clean MPI
> implementation.
>
> Any insights are appreciated.
>
> Many Thanks
>
> Phil Tooley
>
> Typical errors are as follows:
>
> ==7368== Conditional jump or move depends on uninitialised value(s)
> ==7368==    at 0x58894EE: PetscAbsScalar(double) (petscmath.h:389)
> ==7368==    by 0x5891702: MatLUFactorNumeric_SeqAIJ (aijfact.c:553)
> ==7368==    by 0x5406B83: MatLUFactorNumeric (matrix.c:3031)
> ==7368==    by 0x609F317: PCSetUp_ILU(_p_PC*) (ilu.c:176)
> ==7368==    by 0x6192D4F: PCSetUp (precon.c:923)
> ==7368==    by 0x62EAE56: KSPSetUp (itfunc.c:381)
> ==7368==    by 0x60190BB: PCSetUpOnBlocks_BJacobi_Singleblock(_p_PC*)
> (bjacobi.c:621)
> ==7368==    by 0x619352C: PCSetUpOnBlocks (precon.c:954)
> ==7368==    by 0x62E8F0A: KSPSetUpOnBlocks (itfunc.c:213)
> ==7368==    by 0x62ECCB1: KSPSolve (itfunc.c:613)
> ==7368==    by 0x10FCDD: Elastic::innerstep(double) (in
> /home/telemin/repos/pfire_petsc/bin/pfire)
> ==7368==    by 0x110600: Elastic::innerloop(int) (in
> /home/telemin/repos/pfire_petsc/bin/pfire)
> ==7368==
> ==7368== Conditional jump or move depends on uninitialised value(s)
> ==7368==    at 0x58894EE: PetscAbsScalar(double) (petscmath.h:389)
> ==7368==    by 0x588A75F: MatPivotCheck_none(_p_Mat*, _p_Mat*,
> MatFactorInfo const*, FactorShiftCtx*, int) (matimpl.h:704)
> ==7368==    by 0x588AD6E: MatPivotCheck(_p_Mat*, _p_Mat*, MatFactorInfo
> const*, FactorShiftCtx*, int) (matimpl.h:727)
> ==7368==    by 0x589177D: MatLUFactorNumeric_SeqAIJ (aijfact.c:558)
> ==7368==    by 0x5406B83: MatLUFactorNumeric (matrix.c:3031)
> ==7368==    by 0x609F317: PCSetUp_ILU(_p_PC*) (ilu.c:176)
> ==7368==    by 0x6192D4F: PCSetUp (precon.c:923)
> ==7368==    by 0x62EAE56: KSPSetUp (itfunc.c:381)
> ==7368==    by 0x60190BB: PCSetUpOnBlocks_BJacobi_Singleblock(_p_PC*)
> (bjacobi.c:621)
> ==7368==    by 0x619352C: PCSetUpOnBlocks (precon.c:954)
> ==7368==    by 0x62E8F0A: KSPSetUpOnBlocks (itfunc.c:213)
> ==7368==    by 0x62ECCB1: KSPSolve (itfunc.c:613)
> ==7368==
> ==7368== Conditional jump or move depends on uninitialised value(s)
> ==7368==    at 0x588A76D: MatPivotCheck_none(_p_Mat*, _p_Mat*,
> MatFactorInfo const*, FactorShiftCtx*, int) (matimpl.h:704)
> ==7368==    by 0x588AD6E: MatPivotCheck(_p_Mat*, _p_Mat*, MatFactorInfo
> const*, FactorShiftCtx*, int) (matimpl.h:727)
> ==7368==    by 0x589177D: MatLUFactorNumeric_SeqAIJ (aijfact.c:558)
> ==7368==    by 0x5406B83: MatLUFactorNumeric (matrix.c:3031)
> ==7368==    by 0x609F317: PCSetUp_ILU(_p_PC*) (ilu.c:176)
> ==7368==    by 0x6192D4F: PCSetUp (precon.c:923)
> ==7368==    by 0x62EAE56: KSPSetUp (itfunc.c:381)
> ==7368==    by 0x60190BB: PCSetUpOnBlocks_BJacobi_Singleblock(_p_PC*)
> (bjacobi.c:621)
> ==7368==    by 0x619352C: PCSetUpOnBlocks (precon.c:954)
> ==7368==    by 0x62E8F0A: KSPSetUpOnBlocks (itfunc.c:213)
> ==7368==    by 0x62ECCB1: KSPSolve (itfunc.c:613)
> ==7368==    by 0x10FCDD: Elastic::innerstep(double) (in
> /home/telemin/repos/pfire_petsc/bin/pfire)
> ==7368==
> ==7368== Conditional jump or move depends on uninitialised value(s)
> ==7368==    at 0x58894EE: PetscAbsScalar(double) (petscmath.h:389)
> ==7368==    by 0x5889528: PetscIsNanScalar(double) (petscmath.h:674)
> ==7368==    by 0x588A784: MatPivotCheck_none(_p_Mat*, _p_Mat*,
> MatFactorInfo const*, FactorShiftCtx*, int) (matimpl.h:704)
> ==7368==    by 0x588AD6E: MatPivotCheck(_p_Mat*, _p_Mat*, MatFactorInfo
> const*, FactorShiftCtx*, int) (matimpl.h:727)
> ==7368==    by 0x589177D: MatLUFactorNumeric_SeqAIJ (aijfact.c:558)
> ==7368==    by 0x5406B83: MatLUFactorNumeric (matrix.c:3031)
> ==7368==    by 0x609F317: PCSetUp_ILU(_p_PC*) (ilu.c:176)
> ==7368==    by 0x6192D4F: PCSetUp (precon.c:923)
> ==7368==    by 0x62EAE56: KSPSetUp (itfunc.c:381)
> ==7368==    by 0x60190BB: PCSetUpOnBlocks_BJacobi_Singleblock(_p_PC*)
> (bjacobi.c:621)
> ==7368==    by 0x619352C: PCSetUpOnBlocks (precon.c:954)
> ==7368==    by 0x62E8F0A: KSPSetUpOnBlocks (itfunc.c:213)
> ==7368==
> ==7368== Conditional jump or move depends on uninitialised value(s)
> ==7368==    at 0x4FDACE3: std::isnan(double) (cmath:627)
> ==7368==    by 0x4FDAC8D: PetscIsNanReal (mathinf.c:92)
> ==7368==    by 0x588952D: PetscIsNanScalar(double) (petscmath.h:674)
> ==7368==    by 0x588A784: MatPivotCheck_none(_p_Mat*, _p_Mat*,
> MatFactorInfo const*, FactorShiftCtx*, int) (matimpl.h:704)
> ==7368==    by 0x588AD6E: MatPivotCheck(_p_Mat*, _p_Mat*, MatFactorInfo
> const*, FactorShiftCtx*, int) (matimpl.h:727)
> ==7368==    by 0x589177D: MatLUFactorNumeric_SeqAIJ (aijfact.c:558)
> ==7368==    by 0x5406B83: MatLUFactorNumeric (matrix.c:3031)
> ==7368==    by 0x609F317: PCSetUp_ILU(_p_PC*) (ilu.c:176)
> ==7368==    by 0x6192D4F: PCSetUp (precon.c:923)
> ==7368==    by 0x62EAE56: KSPSetUp (itfunc.c:381)
> ==7368==    by 0x60190BB: PCSetUpOnBlocks_BJacobi_Singleblock(_p_PC*)
> (bjacobi.c:621)
> ==7368==    by 0x619352C: PCSetUpOnBlocks (precon.c:954)
>
> --
> Phil Tooley
> Research Software Engineering
> University of Sheffield
>
>

-- 
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener

https://www.cse.buffalo.edu/~knepley/ <http://www.cse.buffalo.edu/~knepley/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20181026/9392a4e4/attachment.html>


More information about the petsc-users mailing list