[petsc-users] MatMPIAIJSetPreallocation question
Barry Smith
bsmith at mcs.anl.gov
Sun Feb 15 21:34:39 CST 2015
> On Feb 15, 2015, at 9:17 PM, Gideon Simpson <gideon.simpson at gmail.com> wrote:
>
> 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?
It could be zero; that means there is not coupling between processes however so essentially each process has its own independent problem; thus normally it is most definitely not zero.
Barry
>
> -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
>>>
>>
>
More information about the petsc-users
mailing list