[petsc-users] error in petsc-dev

Mohammad Mirzadeh mirzadeh at gmail.com
Mon Apr 30 18:01:31 CDT 2012


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?

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
>>>
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20120430/f09c61f5/attachment-0001.htm>


More information about the petsc-users mailing list