[petsc-users] loosing preallocation information

Alexander Grayver agrayver at gfz-potsdam.de
Sun Mar 6 09:39:49 CST 2011


Hello,

I'm newbie in PETSc.

I use PETSc from FORTRAN under Windows, my build configuration is:
Configure options: --with-cc="win32fe cl" --with-fc="win32fe ifort" 
--with-cxx="win32fe cl" --with-windows-graphics=0 
--download-f-blas-lapack=1 --with-precision=double 
--with-scalar-type=complex --with-clanguage=cxx 
--with-mpi-include=/cygdrive/d/Dev/HPC_2008_SDK/Include 
--with-mpi-lib="[/cygdrive/d/Dev/HPC_2008_SDK/Lib/amd64/msmpi.lib,/cygdrive/d/Dev/HPC_2008_SDK/Lib/amd64/msmpifec.lib]" 
--with-shared=0 --with-debugging=0 --with-fortran-kernels=1 --useThreads=0

I wrote this code:

                   call MatCreateSeqAIJ(PETSC_COMM_SELF, n, m, 2, 
PETSC_NULL, Gmat, ierr)
                   CHKERRQ(ierr)

                   call cpu_time(timetest(1))

                   do irow=1,UBOUND(G, dim=1)
                     call MatSetValue(Gmat, ir(i)-1, ic(i)-1, G(irow), 
INSERT_VALUES, ierr)
                   enddo

                   call cpu_time(timetest(2))
                   write(*,*) 'Time of setting matrix G was ', 
timetest(2) - timetest(1), ' seconds'

                   call MatAssemblyBegin(Gmat,MAT_FINAL_ASSEMBLY,ierr)
                   call MatAssemblyEnd(Gmat,MAT_FINAL_ASSEMBLY,ierr)

It gives me that for UBOUND(G, dim=1) = 195551:
  Time of setting matrix G was    620.525177700000       seconds

I read user manual and FAQ and I know that I use inefficient way of 
setting matrix values, but still it seems very suspicios. I run code 
with -info options and it gave:

[0] MatAssemblyEnd_SeqAIJ(): Matrix size: 98304 X 32768; storage space: 
1279009 unneeded,195551 used
[0] MatAssemblyEnd_SeqAIJ(): Number of mallocs during MatSetValues() is 
98304
[0] MatAssemblyEnd_SeqAIJ(): Maximum nonzeros in any row is 2
[0] Mat_CheckInode(): Found 98304 nodes out of 98304 rows. Not using 
Inode routines
[0] PetscCommDuplicate(): Using internal PETSc communicator 1140850689 
-2080374781
[0] PetscCommDuplicate():   returning tag 2147483646

Why there is so much mallocs? I thought I provided information for 
preallocation by setting 2 nonzeros for each row in MatCreateSeqAIJ. 
Isn't that enough? And why there is so much "unneeded" elements?

Thanks in advance.
Regards,
Alexander


More information about the petsc-users mailing list