[petsc-users] error in petsc-dev

Matthew Knepley knepley at gmail.com
Mon Apr 30 18:57:20 CDT 2012


On Mon, Apr 30, 2012 at 7:01 PM, Mohammad Mirzadeh <mirzadeh at gmail.com>wrote:

> Hi,
>
> Just a quick question. Following
> petsc-dev/src/ksp/ksp/examples/tutorials/ex2.c, it seems that I need to
> call both MatMPIAIJSetPreallocation and MatSeqAIJSetPreallocation to be
> able to preallocate for both MPI and Seq matrices. Does petsc automatically
> chose the relevant function when the code is run in serial and parallel? In
> other words, what is the effect
> of MatMPIAIJSetPreallocation(MatSeqAIJSetPreallocation) when the code is
> run in serial(parallel)?
>
> I like how several functions are abstract and can be used both in serial
> and parallel (like MatCreate). Is there a similar way to just call a single
> "MatSetPreallocation" function?
>

http://www.mcs.anl.gov/petsc/petsc-dev/docs/manualpages/Mat/MatXAIJSetPreallocation.html

   Matt


> Thanks,
> Mohammad
>
> On Wed, Apr 25, 2012 at 4:04 PM, Mohammad Mirzadeh <mirzadeh at gmail.com>wrote:
>
>> Thanks Hong; that fixed the problem.
>>
>>
>> On Wed, Apr 25, 2012 at 11:31 AM, Hong Zhang <hzhang at mcs.anl.gov> wrote:
>>
>>> Mohammad:
>>>
>>>>
>>>> MatCreate(comm, &A);
>>>> MatSetSizes(A, localRowSize, localColumnSize, globalRowSize,
>>>> globalColumnSize);
>>>> MatSetType(A, MATMPIAIJ);
>>>> MatMPIAIJSetPreallocation(A, 0, d_nnz, 0, o_nnz);
>>>> MatSetFromOptions(A);
>>>> MatGetOwnershipRange(A, &rStart, &rEnd);
>>>>
>>>>
>>>> This (even without MatSetType(A, MATMPIAIJ);) works with 3.2-p6 but not
>>>> dev. The only difference I can see is 1) the order of MatSetFromOptions and
>>>> 2) I do not call MatSeqAIJSetPreallocation which I think I do not need
>>>> anyway. Is there something I'm doing wrong?
>>>>
>>>
>>> MatSetFromOptions() must be called before MatMPIAIJSetPreallocation().
>>> If user set mattype at runtime, MatSetFromOptions() picks it and set the
>>> type accordingly. SetPreallocation()
>>> will be called after the type is set.
>>>
>>> Hong
>>>
>>>>
>>>> Mohammd
>>>>
>>>
>>>
>>
>


-- 
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/20120430/954c2b12/attachment.htm>


More information about the petsc-users mailing list