[petsc-users] Sparse Matrix preallocation and performance

Bartłomiej W bartlomiej.wach at yahoo.pl
Thu Apr 7 08:04:43 CDT 2011


Hello,

Wheather I use

  ierr = MatCreate(PETSC_COMM_WORLD,&L);CHKERRQ(ierr);
  ierr = MatSetSizes(L,PETSC_DECIDE,PETSC_DECIDE,n,n);CHKERRQ(ierr);
             MatSeqAIJSetPreallocation(L,PETSC_NULL,nnz);
  ierr = MatSetFromOptions(L);CHKERRQ(ierr);

or

  
  ierr = MatCreateSeqAIJ(PETSC_COMM_WORLD,n,n,PETSC_DEFAULT,nnz,&L);CHKERRQ(ierr);
  ierr = MatSetFromOptions(L);CHKERRQ(ierr);
 
Gives me 

   Number of mallocs during MatSetValues() is  X 

On matrix assembly, where X is positive
Is this indicating the preallocation or should it be zero and I'm missing something?

Moreover, using MatCreateSeqAIJ lowers the performance of MatSetValues

Is my code improper?

Regards 
Bartłomiej Wach
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20110407/3885cece/attachment.htm>


More information about the petsc-users mailing list