[petsc-users] Valgrind Errors with KSPSolve

Phil Tooley phil.tooley at sheffield.ac.uk
Fri Oct 26 08:53:30 CDT 2018


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. 

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



More information about the petsc-users mailing list