[petsc-dev] MatGetFactor calling MatSetUp
Jed Brown
jedbrown at mcs.anl.gov
Mon Apr 1 21:51:26 CDT 2013
Paul just had some code here that calls MatSetUp() in
MatGetFactor_seqaij_aijcusparse().
https://bitbucket.org/pmullowney/petsc-aijcusparse-icc/commits/565b4a4a9c73300d4d7010d4fbc5d561c0644b6e#Lsrc/mat/impls/aij/seq/seqcusparse/aijcusparse.cuT90
Of course this is not allowed (it doesn't make sense to set up the
matrix this early), and we can detect it because -malloc_test gives:
[ 0]736 bytes MatSeqAIJSetPreallocation_SeqAIJ() line 3551 in /home/jed/petsc/src/mat/impls/aij/seq/aij.c
[0] MatSeqAIJSetPreallocation_SeqAIJ() line 3551 in /home/jed/petsc/src/mat/impls/aij/seq/aij.c
[0] MatSetUp_SeqAIJ() line 2483 in /home/jed/petsc/src/mat/impls/aij/seq/aij.c
[0] MatSetUp() line 707 in /home/jed/petsc/src/mat/interface/matrix.c
[0] MatGetFactor_seqaij_cusparse() line 79 in /home/jed/petsc/src/mat/impls/aij/seq/seqcusparse/aijcusparse.cu
[0] MatGetFactor() line 3997 in /home/jed/petsc/src/mat/interface/matrix.c
[0] PCSetUp_ILU() line 161 in /home/jed/petsc/src/ksp/pc/impls/factor/ilu/ilu.c
[0] PCSetUp() line 868 in /home/jed/petsc/src/ksp/pc/interface/precon.c
[0] KSPSetUp() line 192 in /home/jed/petsc/src/ksp/ksp/interface/itfunc.c
... and a few more
The leak is caused because the factorization routines don't check
whether the matrix was already preallocated.
#1 0x00007ffff6762668 in MatILUFactorSymbolic_SeqAIJ_ilu0 (fact=0x9511ae0, A=0x94214d0, isrow=0x951d3d0, iscol=0x9521d10, info=0x94d23f8) at /home/jed/petsc/src/mat/impls/aij/seq/aijfact.c:1659
1659 ierr = PetscMalloc3(ai[n]+1,PetscScalar,&b->a,ai[n]+1,PetscInt,&b->j,n+1,PetscInt,&b->i);CHKERRQ(ierr);
This is not the best misuse behavior, but I certainly don't want to
silently deallocate because then the misuse would more easily go
undetected.
Is there a good place to raise an error for this sort of misuse?
More information about the petsc-dev
mailing list