[petsc-users] Newbie Question - Really slow - PetscMemCpy

Barry Smith bsmith at mcs.anl.gov
Thu Apr 22 07:59:17 CDT 2010

On Apr 22, 2010, at 7:33 AM, Parker, Andrew (UK Filton) wrote:

> Hi,
> I'm new to these postings.  On very large cases, regardless of where  
> I stop the debugger it is always copying data.  I've put it into a  
> debugger because on smaller cases it runs fine, on larger it takes a  
> while (very long time) to get going.  The stack trace always gives  
> something like:
> memcpy
> PetscMemCpy
> MatSetValues_SeqAIJ

     It is using SeqAIJ matrices

> MatSetValues
> my own wrapper to add values to a location within the matrix.
> I'm using Seq_BAIJ.  My bets are that I've got the sparsity wrong,  
> or the preallocation wrong, but I'm not sure why.  I know this could  
> be anything, but has anybody got any thoughts, remember stopping the  
> debugger at random, regardless of the frequency always gives the  
> above....
> I set up the matrix like this
>   MatCreate(PETSC_COMM_SELF,&_storage);
> MatSetSizes 
> (_storage,PETSC_DECIDE,PETSC_DECIDE,numVars*numLocs,numVars*numLocs);
>   MatSetFromOptions(_storage);
> MatSeqBAIJSetPreallocation(_storage,numVars,PETSC_NULL,sparsityStart);

     Unless you use the argument -mat_type seqbaij this will use  
SeqAIJ while you preallocate SeqBAIJ.

> However, using this makes zero difference to the speed
>       numVars,
>       numVars*numLocs,
>       numVars*numLocs,
>       0,
>        sparsityStart,
>       &_storage);
> It is so slow that it has not even completed one cycle of the  
> solver....

     Your sparseityStart is wrong. Run with -info and grep the results  
for malloc and you'll see it is mallocing many times to get enough  


> Cheers again,
> Andy
> ********************************************************************
> This email and any attachments are confidential to the intended
> recipient and may also be privileged. If you are not the intended
> recipient please delete it from your system and notify the sender.
> You should not copy it or use it for any purpose nor disclose or
> distribute its contents to any other person.
> ********************************************************************

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20100422/bcdd5115/attachment.htm>

More information about the petsc-users mailing list