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

Matthew Knepley knepley at gmail.com
Thu Apr 22 08:13:29 CDT 2010


On Thu, Apr 22, 2010 at 8:06 AM, Parker, Andrew (UK Filton) <
Andrew.Parker2 at baesystems.com> wrote:

>  Ok,
>
> Cheers guys.  I did find that strange, that it was using AIJ, can I set
> that in the code rather from an options file, what is the code equivalent to
> -mat_type seqbaij, is it MatSetType or something like that?  I'm going to
> try Jed's suggestion about error on on first non-preallocated access.  Could
> my error actually be that the sparsity is correct, but as you note below,
> the matrix type allocated with MatSeqBAIJSetPreallocation is of type AIJ,
> and in which case, for that matrix it has not be preallocated with the
> correct sparsity, or at all, and hence the speed?  Or something like that??
> Could the solution possibly just be setting -mat_type seqbaij?  In which
> case I need to find out how to do that.
>

1) -mat_type seqbaij is equivalent to MatSetType(A, MATSEQBAIJ), but why
hardcode it?

2) Yes, preallocation only takes place for the given type. You can call more
than one
     preallocation function.

3) You have two errors: Wrong matrix type, and then for the second call the
matrix type is
    correct but the sparsity is wrong.

    Matt


>
> Cheers again,
> Andy
>
>  ------------------------------
> *From:* petsc-users-bounces at mcs.anl.gov [mailto:
> petsc-users-bounces at mcs.anl.gov] *On Behalf Of *Barry Smith
> *Sent:* 22 April 2010 13:59
> *To:* PETSc users list
> *Subject:* Re: [petsc-users] Newbie Question - Really slow - PetscMemCpy
>
>                     *** WARNING ***
>
>   This message has originated outside your organisation,
>   either from an external partner or the Global Internet.
>       Keep this in mind if you answer this message.
>
>
>
>  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
>
>    MatCreateSeqBAIJ(PETSC_COMM_SELF,
>       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 space.
>
>    Barry
>
>
> 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.
> ********************************************************************
>
>
>


-- 
What most experimenters take for granted before they begin their experiments
is infinitely more interesting than any results to which their experiments
lead.
-- Norbert Wiener
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20100422/b43d46ea/attachment.htm>


More information about the petsc-users mailing list