[petsc-users] MatMPIAIJSetPreallocation question

Gideon Simpson gideon.simpson at gmail.com
Sun Feb 15 21:17:04 CST 2015


Got it, one follow up question:

When calling MatMPIAIJSetPreallocation, is there a reason why the number of nonzero entries in the off-diagonal sub matrix cannot be zero?

-gideon

> On Feb 15, 2015, at 9:31 PM, Barry Smith <bsmith at mcs.anl.gov> wrote:
> 
> 
>> On Feb 15, 2015, at 8:22 PM, Gideon Simpson <gideon.simpson at gmail.com> wrote:
>> 
>> I’m trying to get a handle on the different ways of constructing matrices.  Currently, I have:
>> 
>> MatCreate(...)
>> MatSetSizes(...)
>> MatSetFromOptions(...)
>> MatSetUp(…)
>> 
>> but I gather from reading the manual that, by not preallocating, I’m losing out in performance.  If I assume that my matrix will either by SeqAIJ or MPIAIJ, depending on the number of processors available, how would I go about doing this.  I see some of the example codes with:
>> 
>> MatSeqAIJSetPreallocation(…)
>> MatMPIAIJSetPreallocation(…)
>> 
>> as successive commands.  Should I interpret this as saying that PETSc will just ignore the one that is not the active one in the current instance? 
> 
>  Exactly*.
> 
>  You can also use MatXAIJSetPreallocation() which sets the possible preallocation forms for all the matrix types without requiring you to set one each individuallly.
> 
>  Barry
> 
> * We support this in many places because we hate requiring users to put a bunch of if (type == xxx) kind of code in their applications. For example KSPGMRESSetRestart() is ignored if the KSP type is not GMRES.
> 
> 
>> 
>> -gideon
>> 
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20150215/cfeb1e6a/attachment.html>


More information about the petsc-users mailing list