[petsc-users] MatGetSubMatrix and memory usage

francois pacull fpacull at fluorem.com
Wed Jun 23 04:45:56 CDT 2010


Dear PETSc team,

I have a question regarding the MatGetSubMatrix routine (release 
3.0.0-p7). I am using it to change the partitioning of a MATMPIAIJ matrix:

ierr = 
MatGetSubMatrix(Aold,ISrow,IScol,PETSC_DECIDE,MAT_INITIAL_MATRIX,&Anew);

Using the PetscMemoryGetCurrentUsage routine, I noticed that the memory 
size is increased by about 100% when calling MatGetSubMatrix:

- memory usage : 267 MB
ierr = 
MatGetSubMatrix(Aold,ISrow,IScol,PETSC_DECIDE,MAT_INITIAL_MATRIX,&Anew);
- memory usage : 780 MB
ierr = MatDestroy(Aold);
- memory usage : 528 MB

In order to reduce the memory, I have to duplicate Anew in the following 
way:

- memory usage : 267 MB
ierr = 
MatGetSubMatrix(Aold,ISrow,IScol,PETSC_DECIDE,MAT_INITIAL_MATRIX,&Anew);CHKERRQ(ierr);
- memory usage : 780 MB
ierr = MatDestroy(Aold);
- memory usage : 528 MB
ierr = MatDuplicate(Anew,MAT_COPY_VALUES,&Atemp);CHKERRQ(ierr);
- memory usage : 780 MB
ierr = MatDestroy(Anew);CHKERRQ(ierr);
- memory usage : 278 MB
Anew = Atemp;

However, the peak memory is still about three times the size of Aold. Am 
I doing something wrong? Why is it using so much memory? Is there a way 
to avoid this memory peak?
I noticed the same thing when using the release 3.1-p1

Thanks for your help,
francois pacull.



More information about the petsc-users mailing list