[petsc-users] PETSc crashes when different rank sets row, col and A values using MatCreateSeqAIJWithArrays

Junchao Zhang junchao.zhang at gmail.com
Thu Feb 8 08:52:09 CST 2024


On Thu, Feb 8, 2024 at 3:15 AM Maruthi NH <maruthinh at gmail.com> wrote:

> Hi Barry,
> Thanks. Yes, the global column index was wrong. I have one more question
> regarding MatCreateMPIAIJWithArrays. If I have 100 elements in rank 0 and
> 50 in rank 1, does PETSc redistribute equally among procs before solving?
>

No, the m  you provided in MatCreateMPIAIJWithArrays(comm, m, n, ..., i, j,
..) determines the number of local rows and petsc won't change that.
If you want petsc to redistribute it, first create a balanced matrix and
then call MatSetValues() to insert values.  Petsc will ship these values
around to match the matrix layout you prescribed.


>
>
> Regards,
> Maruthi
>
> On Mon, Feb 5, 2024 at 2:18 AM Barry Smith <bsmith at petsc.dev> wrote:
>
>>
>>    Is each rank trying to create its own sequential matrix with
>> MatCreateSeqAIJWithArrays() or did you mean MatCreateMPIAIJWithArrays()?
>>
>>    If the latter, then possibly one of your size arguments is wrong or
>> the indices are incorrect for the given sizes.
>>
>>    Barry
>>
>>
>> > On Feb 4, 2024, at 3:15 PM, Maruthi NH <maruthinh at gmail.com> wrote:
>> >
>> > Hi all,
>> >
>> > I have a row, col, and A values in CSR format; let's say rank 0 has 200
>> unknowns and rank 1 has 100 unknowns. If I use MatCreateSeqAIJWithArrays to
>> create a Matrix, it crashes. However, if each rank has an equal number of
>> unknowns, it works fine. Please let me know how to proceed
>> >
>> >
>> > Regards,
>> > Maruthi
>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20240208/20a1d9cc/attachment-0001.html>


More information about the petsc-users mailing list