[petsc-users] Can not understand why convert matrix type from MPIAIJ to MATIS failed.

Junchao Zhang junchao.zhang at gmail.com
Sun Apr 17 22:29:33 CDT 2022


Hi, Xiu Hui,
 I can reproduce the error. I need to read the code to understand why. I'll
report back once I have a fix.
 Thanks.
--Junchao Zhang


On Sat, Apr 16, 2022 at 12:02 AM 459543524 <459543524 at qq.com> wrote:

> Sir, I rewrite the code.
> The code do not include any domain concept.
> The code is simple allocate space, insert value, compress, set attribute,
> then convert the matrix type.
> It can help to reproduce the problem.
> Please take a look.
> As you suggested, I found that the problem comes from the line
> ```
> MatSetBlockSize(....);
> ```
> If this line is not used, every thing will be ok.
> Thanks for your time sir.
>
> ------------------------------
> 徐辉,Xu Hui
> 清华大学航天航空学院博士研究生
> PhD Candidate, School of Aerospace Engineering
> Tsinghua University
> Tel: 188-1152-7137
> Mail:459543524 at qq.com
>
>
>
>
> ------------------ 原始邮件 ------------------
> *发件人:* "Junchao Zhang" <junchao.zhang at gmail.com>;
> *发送时间:* 2022年4月15日(星期五) 晚上11:25
> *收件人:* "459543524"<459543524 at qq.com>;
> *抄送:* "petsc-users"<petsc-users at mcs.anl.gov>;
> *主题:* Re: [petsc-users] Can not understand why convert matrix type from
> MPIAIJ to MATIS failed.
>
> Hi, Xu Hui,
>   I ran a test with your matrix but met
> $  mpirun -n 4  ./ex0 -f test.mat
> [0]PETSC ERROR: --------------------- Error Message
> --------------------------------------------------------------
> [0]PETSC ERROR: Unexpected data in file
> [0]PETSC ERROR: Not a matrix object in file
> ...
> [0]PETSC ERROR: #4 main() at ex0.c:18
> [0]PETSC ERROR: PETSc Option Table entries:
> [0]PETSC ERROR: -f test.mat
> [0]PETSC ERROR: -matload_block_size 2
>
> I attach my test ex0.c.  You can run at your side to make sure the matrix
> is OK.  Then, could just put the test and matrix files in a tarball and
> send it back?
> I feel the problem might be related to -matload_block_size 2. But let's
> see.
>
> Thanks.
> --Junchao Zhang
>
>
> On Fri, Apr 15, 2022 at 2:43 AM 459543524 <459543524 at qq.com> wrote:
>
>> Sir, I already dump the matrix into binary file and attached in the mail,
>> and please have a look.
>> Thanks for your time.
>>
>> The follow code can be used to reproduce problem.
>> ---------------------------------------------------------------
>> std::string path = "......";
>> PetscViewer viewer;
>> PetscViewerBinaryOpen(comm, path.c_str(), FILE_MODE_READ, &viewer);
>> Mat A;
>> MatCreate(comm,&A);
>> MatSetType(A,MATMPIAIJ);
>> MatLoad(A,viewer);
>> PetscViewerDestroy(&viewer);
>> MatView(A, PETSC_VIEWER_STDOUT_(MPI_COMM_WORLD));
>> Mat J;
>> MatConvert(A, MATIS, MAT_INITIAL_MATRIX, &J);
>> ---------------------------------------------------------------
>> The result shown as follows:
>> ---------------------------------------------------------------
>> Mat Object: 4 MPI processes
>>   type: mpiaij
>> row 0: (0, 168.75)  (1, 0.)  (2, 0.)  (3, 0.)  (4, 0.)  (5, 0.)  (6, 0.)
>> (7, 0.)
>> row 1: (0, 0.)  (1, 168.75)  (2, 0.)  (3, 0.)  (4, 0.)  (5, 0.)  (6, 0.)
>> (7, 0.)
>> row 2: (0, 0.)  (1, 0.)  (2, 168.75)  (3, 0.)  (6, 0.)  (7, 0.)  (8, 0.)
>> (9, 0.)  (12, 0.)  (13, 0.)
>> row 3: (0, 0.)  (1, 0.)  (2, 0.)  (3, 168.75)  (6, 0.)  (7, 0.)  (8, 0.)
>> (9, 0.)  (12, 0.)  (13, 0.)
>> row 4: (0, 0.)  (1, 0.)  (4, 150.)  (5, -25.)  (6, -100.)  (7, 25.)  (16,
>> -25.)  (17, 25.)  (18, 0.)  (19, -25.)
>> row 5: (0, 0.)  (1, 0.)  (4, -25.)  (5, 150.)  (6, 25.)  (7, -50.)  (16,
>> 0.)  (17, -50.)  (18, -25.)  (19, 0.)
>> row 6: (0, 0.)  (1, 0.)  (2, 0.)  (3, 0.)  (4, -100.)  (5, 25.)  (6,
>> 300.)  (7, -50.)  (12, -100.)  (13, 25.)  (18, -50.)  (19, 25.)  (24, 0.)
>> (25, -25.)
>> row 7: (0, 0.)  (1, 0.)  (2, 0.)  (3, 0.)  (4, 25.)  (5, -50.)  (6,
>> -50.)  (7, 300.)  (12, 25.)  (13, -50.)  (18, 25.)  (19, -100.)  (24,
>> -25.)  (25, 0.)
>> row 8: (2, 0.)  (3, 0.)  (8, 150.)  (9, 0.)  (10, 0.)  (11, 0.)  (12,
>> 0.)  (13, 0.)  (14, 0.)  (15, 0.)
>> row 9: (2, 0.)  (3, 0.)  (8, 0.)  (9, 150.)  (10, 0.)  (11, 0.)  (12,
>> 0.)  (13, 0.)  (14, 0.)  (15, 0.)
>> row 10: (8, 0.)  (9, 0.)  (10, 150.)  (11, 0.)  (14, 0.)  (15, 0.)
>> row 11: (8, 0.)  (9, 0.)  (10, 0.)  (11, 150.)  (14, 0.)  (15, 0.)
>> row 12: (2, 0.)  (3, 0.)  (6, -100.)  (7, 25.)  (8, 0.)  (9, 0.)  (12,
>> 300.)  (13, -50.)  (14, -100.)  (15, 25.)  (24, -50.)  (25, 25.)  (26, 0.)
>> (27, -25.)
>> row 13: (2, 0.)  (3, 0.)  (6, 25.)  (7, -50.)  (8, 0.)  (9, 0.)  (12,
>> -50.)  (13, 300.)  (14, 25.)  (15, -50.)  (24, 25.)  (25, -100.)  (26,
>> -25.)  (27, 0.)
>> row 14: (8, 0.)  (9, 0.)  (10, 0.)  (11, 0.)  (12, -100.)  (13, 25.)
>> (14, 150.)  (15, -25.)  (26, -25.)  (27, 0.)
>> row 15: (8, 0.)  (9, 0.)  (10, 0.)  (11, 0.)  (12, 25.)  (13, -50.)  (14,
>> -25.)  (15, 150.)  (26, 25.)  (27, -50.)
>> row 16: (4, -25.)  (5, 0.)  (16, 150.)  (17, -25.)  (18, -100.)  (19,
>> 25.)  (20, -25.)  (21, 25.)  (22, 0.)  (23, -25.)
>> row 17: (4, 25.)  (5, -50.)  (16, -25.)  (17, 150.)  (18, 25.)  (19,
>> -50.)  (20, 0.)  (21, -50.)  (22, -25.)  (23, 0.)
>> row 18: (4, 0.)  (5, -25.)  (6, -50.)  (7, 25.)  (16, -100.)  (17, 25.)
>> (18, 300.)  (19, -50.)  (22, -50.)  (23, 25.)  (24, -100.)  (25, 25.)  (28,
>> 0.)  (29, -25.)
>> row 19: (4, -25.)  (5, 0.)  (6, 25.)  (7, -100.)  (16, 25.)  (17, -50.)
>> (18, -50.)  (19, 300.)  (22, 25.)  (23, -100.)  (24, 25.)  (25, -50.)  (28,
>> -25.)  (29, 0.)
>> row 20: (16, -25.)  (17, 0.)  (20, 75.)  (21, -25.)  (22, -50.)  (23,
>> 25.)
>> row 21: (16, 25.)  (17, -50.)  (20, -25.)  (21, 75.)  (22, 0.)  (23,
>> -25.)
>> row 22: (16, 0.)  (17, -25.)  (18, -50.)  (19, 25.)  (20, -50.)  (21,
>> 0.)  (22, 150.)  (23, -25.)  (28, -50.)  (29, 25.)
>> row 23: (16, -25.)  (17, 0.)  (18, 25.)  (19, -100.)  (20, 25.)  (21,
>> -25.)  (22, -25.)  (23, 150.)  (28, 0.)  (29, -25.)
>> row 24: (6, 0.)  (7, -25.)  (12, -50.)  (13, 25.)  (18, -100.)  (19,
>> 25.)  (24, 300.)  (25, -50.)  (26, -100.)  (27, 25.)  (28, -50.)  (29,
>> 25.)  (30, 0.)  (31, -25.)
>> row 25: (6, -25.)  (7, 0.)  (12, 25.)  (13, -100.)  (18, 25.)  (19,
>> -50.)  (24, -50.)  (25, 300.)  (26, 25.)  (27, -50.)  (28, 25.)  (29,
>> -100.)  (30, -25.)  (31, 0.)
>> row 26: (12, 0.)  (13, -25.)  (14, -25.)  (15, 25.)  (24, -100.)  (25,
>> 25.)  (26, 150.)  (27, -25.)  (30, -25.)  (31, 0.)
>> row 27: (12, -25.)  (13, 0.)  (14, 0.)  (15, -50.)  (24, 25.)  (25,
>> -50.)  (26, -25.)  (27, 150.)  (30, 25.)  (31, -50.)
>> row 28: (18, 0.)  (19, -25.)  (22, -50.)  (23, 0.)  (24, -50.)  (25,
>> 25.)  (28, 150.)  (29, -25.)  (30, -50.)  (31, 25.)
>> row 29: (18, -25.)  (19, 0.)  (22, 25.)  (23, -25.)  (24, 25.)  (25,
>> -100.)  (28, -25.)  (29, 150.)  (30, 0.)  (31, -25.)
>> row 30: (24, 0.)  (25, -25.)  (26, -25.)  (27, 25.)  (28, -50.)  (29,
>> 0.)  (30, 75.)  (31, 0.)
>> row 31: (24, -25.)  (25, 0.)  (26, 0.)  (27, -50.)  (28, 25.)  (29,
>> -25.)  (30, 0.)  (31, 75.)
>> [0]PETSC ERROR: --------------------- Error Message
>> --------------------------------------------------------------
>> [0]PETSC ERROR: Argument out of range
>> [0]PETSC ERROR: Scatter indices in ix are out of range
>> [0]PETSC ERROR: See https://petsc.org/release/faq/ for trouble shooting.
>> [0]PETSC ERROR: Petsc Release Version 3.15.4, Sep 01, 2021
>> [0]PETSC ERROR: Unknown Name on a  named xuhui-Office by xuhui Fri Apr 15
>> 15:40:00 2022
>> [0]PETSC ERROR: Configure options --prefix=/opt/petsc/debug_int64
>> --download-mumps --download-scalapack --download-superlu_dist
>> --download-parmetis --download-metis --with-64-bit-indices=1
>> [0]PETSC ERROR: #1 VecScatterCreate() at
>> /home/xuhui/Temp/petsc-3.15.4/src/vec/is/sf/interface/vscat.c:767
>> [0]PETSC ERROR: #2 MatISSetUpScatters_Private() at
>> /home/xuhui/Temp/petsc-3.15.4/src/mat/impls/is/matis.c:2403
>> [0]PETSC ERROR: #3 MatSetLocalToGlobalMapping_IS() at
>> /home/xuhui/Temp/petsc-3.15.4/src/mat/impls/is/matis.c:2501
>> [0]PETSC ERROR: #4 MatSetLocalToGlobalMapping() at
>> /home/xuhui/Temp/petsc-3.15.4/src/mat/interface/matrix.c:2093
>> [0]PETSC ERROR: #5 MatConvert_XAIJ_IS() at
>> /home/xuhui/Temp/petsc-3.15.4/src/mat/impls/is/matis.c:651
>> [0]PETSC ERROR: #6 MatConvert() at
>> /home/xuhui/Temp/petsc-3.15.4/src/mat/interface/matrix.c:4439
>> ^C[mpiexec at xuhui-Office] Sending Ctrl-C to processes as requested
>>
>> ---------------------------------------------------------------
>> ------------------------------
>> 徐辉,Xu Hui
>> 清华大学航天航空学院博士研究生
>> PhD Candidate, School of Aerospace Engineering
>> Tsinghua University
>> Tel: 188-1152-7137
>> Mail:459543524 at qq.com
>>
>>
>>
>>
>> ------------------ 原始邮件 ------------------
>> *发件人:* "Junchao Zhang" <junchao.zhang at gmail.com>;
>> *发送时间:* 2022年4月15日(星期五) 上午6:31
>> *收件人:* "459543524"<459543524 at qq.com>;
>> *抄送:* "petsc-users"<petsc-users at mcs.anl.gov>;
>> *主题:* Re: [petsc-users] Can not understand why convert matrix type from
>> MPIAIJ to MATIS failed.
>>
>> Since you already have the test matrix, could you add "-mat_view binary"
>> to dump the matrix and send us the binaryoutput.* files for reproduce?
>>
>> --Junchao Zhang
>>
>>
>> On Thu, Apr 14, 2022 at 10:09 AM 459543524 via petsc-users <
>> petsc-users at mcs.anl.gov> wrote:
>>
>>> Sir, I can not understand why my convert from MPIAIJ to MATIS failed.
>>>
>>> I already have a matrix A, create by follow commands
>>> ---------------------------------------------------------------------
>>> Mat A;
>>> MatCreateAIJ(...)
>>> MatSetValues(...)
>>> MatAssemblyBegin(A, MAT_FINAL_ASSEMBLY);
>>> MatAssemblyEnd(A, MAT_FINAL_ASSEMBLY);
>>> ---------------------------------------------------------------------
>>> I want convert the matrix A to MATIS type for future BDDC operation, as
>>> advised by ex 72.
>>> ---------------------------------------------------------------------
>>> Mat J;
>>> MatConvert(A, MATIS, MAT_INITIAL_MATRIX, &J);
>>> ---------------------------------------------------------------------
>>>
>>> The command failed with the stacktrace
>>> [0]PETSC ERROR: --------------------- Error Message
>>> --------------------------------------------------------------
>>> [0]PETSC ERROR: Argument out of range
>>> [0]PETSC ERROR: Scatter indices in ix are out of range
>>> [0]PETSC ERROR: See https://petsc.org/release/faq/ for trouble shooting.
>>> [0]PETSC ERROR: Petsc Release Version 3.15.4, Sep 01, 2021
>>> [0]PETSC ERROR: Unknown Name on a  named xuhui-Office by xuhui Thu Apr
>>> 14 23:06:08 2022
>>> [0]PETSC ERROR: Configure options --prefix=/opt/petsc/debug_int64
>>> --download-mumps --download-scalapack --download-superlu_dist
>>> --download-parmetis --download-metis --with-64-bit-indices=1
>>> [0]PETSC ERROR: #1 VecScatterCreate() at
>>> /home/xuhui/Temp/petsc-3.15.4/src/vec/is/sf/interface/vscat.c:767
>>> [0]PETSC ERROR: #2 MatISSetUpScatters_Private() at
>>> /home/xuhui/Temp/petsc-3.15.4/src/mat/impls/is/matis.c:2403
>>> [0]PETSC ERROR: #3 MatSetLocalToGlobalMapping_IS() at
>>> /home/xuhui/Temp/petsc-3.15.4/src/mat/impls/is/matis.c:2501
>>> [0]PETSC ERROR: #4 MatSetLocalToGlobalMapping() at
>>> /home/xuhui/Temp/petsc-3.15.4/src/mat/interface/matrix.c:2093
>>> [0]PETSC ERROR: #5 MatConvert_XAIJ_IS() at
>>> /home/xuhui/Temp/petsc-3.15.4/src/mat/impls/is/matis.c:651
>>> [0]PETSC ERROR: #6 MatConvert() at
>>> /home/xuhui/Temp/petsc-3.15.4/src/mat/interface/matrix.c:4439
>>> ^C[mpiexec at xuhui-Office] Sending Ctrl-C to processes as requested
>>>
>>>
>>> I have no idea why this happen. Thanks for your time.
>>>
>>>
>>> Further information:
>>> The matrix A is distributed on 4 processes.
>>> We can view the matrix as follows:
>>>
>>> Mat Object: 4 MPI processes
>>>   type: mpiaij
>>> row 0: (0, 168.75)  (1, 0.)  (2, 0.)  (3, 0.)  (4, 0.)  (5, 0.)  (6,
>>> 0.)  (7, 0.)
>>> row 1: (0, 0.)  (1, 168.75)  (2, 0.)  (3, 0.)  (4, 0.)  (5, 0.)  (6,
>>> 0.)  (7, 0.)
>>> row 2: (0, 0.)  (1, 0.)  (2, 168.75)  (3, 0.)  (6, 0.)  (7, 0.)  (8,
>>> 0.)  (9, 0.)  (12, 0.)  (13, 0.)
>>> row 3: (0, 0.)  (1, 0.)  (2, 0.)  (3, 168.75)  (6, 0.)  (7, 0.)  (8,
>>> 0.)  (9, 0.)  (12, 0.)  (13, 0.)
>>> row 4: (0, 0.)  (1, 0.)  (4, 150.)  (5, -25.)  (6, -100.)  (7, 25.)
>>> (16, -25.)  (17, 25.)  (18, 0.)  (19, -25.)
>>> row 5: (0, 0.)  (1, 0.)  (4, -25.)  (5, 150.)  (6, 25.)  (7, -50.)  (16,
>>> 0.)  (17, -50.)  (18, -25.)  (19, 0.)
>>> row 6: (0, 0.)  (1, 0.)  (2, 0.)  (3, 0.)  (4, -100.)  (5, 25.)  (6,
>>> 300.)  (7, -50.)  (12, -100.)  (13, 25.)  (18, -50.)  (19, 25.)  (24, 0.)
>>> (25, -25.)
>>> row 7: (0, 0.)  (1, 0.)  (2, 0.)  (3, 0.)  (4, 25.)  (5, -50.)  (6,
>>> -50.)  (7, 300.)  (12, 25.)  (13, -50.)  (18, 25.)  (19, -100.)  (24,
>>> -25.)  (25, 0.)
>>> row 8: (2, 0.)  (3, 0.)  (8, 150.)  (9, 0.)  (10, 0.)  (11, 0.)  (12,
>>> 0.)  (13, 0.)  (14, 0.)  (15, 0.)
>>> row 9: (2, 0.)  (3, 0.)  (8, 0.)  (9, 150.)  (10, 0.)  (11, 0.)  (12,
>>> 0.)  (13, 0.)  (14, 0.)  (15, 0.)
>>> row 10: (8, 0.)  (9, 0.)  (10, 150.)  (11, 0.)  (14, 0.)  (15, 0.)
>>> row 11: (8, 0.)  (9, 0.)  (10, 0.)  (11, 150.)  (14, 0.)  (15, 0.)
>>> row 12: (2, 0.)  (3, 0.)  (6, -100.)  (7, 25.)  (8, 0.)  (9, 0.)  (12,
>>> 300.)  (13, -50.)  (14, -100.)  (15, 25.)  (24, -50.)  (25, 25.)  (26, 0.)
>>> (27, -25.)
>>> row 13: (2, 0.)  (3, 0.)  (6, 25.)  (7, -50.)  (8, 0.)  (9, 0.)  (12,
>>> -50.)  (13, 300.)  (14, 25.)  (15, -50.)  (24, 25.)  (25, -100.)  (26,
>>> -25.)  (27, 0.)
>>> row 14: (8, 0.)  (9, 0.)  (10, 0.)  (11, 0.)  (12, -100.)  (13, 25.)
>>> (14, 150.)  (15, -25.)  (26, -25.)  (27, 0.)
>>> row 15: (8, 0.)  (9, 0.)  (10, 0.)  (11, 0.)  (12, 25.)  (13, -50.)
>>> (14, -25.)  (15, 150.)  (26, 25.)  (27, -50.)
>>> row 16: (4, -25.)  (5, 0.)  (16, 150.)  (17, -25.)  (18, -100.)  (19,
>>> 25.)  (20, -25.)  (21, 25.)  (22, 0.)  (23, -25.)
>>> row 17: (4, 25.)  (5, -50.)  (16, -25.)  (17, 150.)  (18, 25.)  (19,
>>> -50.)  (20, 0.)  (21, -50.)  (22, -25.)  (23, 0.)
>>> row 18: (4, 0.)  (5, -25.)  (6, -50.)  (7, 25.)  (16, -100.)  (17, 25.)
>>> (18, 300.)  (19, -50.)  (22, -50.)  (23, 25.)  (24, -100.)  (25, 25.)  (28,
>>> 0.)  (29, -25.)
>>> row 19: (4, -25.)  (5, 0.)  (6, 25.)  (7, -100.)  (16, 25.)  (17, -50.)
>>> (18, -50.)  (19, 300.)  (22, 25.)  (23, -100.)  (24, 25.)  (25, -50.)  (28,
>>> -25.)  (29, 0.)
>>> row 20: (16, -25.)  (17, 0.)  (20, 75.)  (21, -25.)  (22, -50.)  (23,
>>> 25.)
>>> row 21: (16, 25.)  (17, -50.)  (20, -25.)  (21, 75.)  (22, 0.)  (23,
>>> -25.)
>>> row 22: (16, 0.)  (17, -25.)  (18, -50.)  (19, 25.)  (20, -50.)  (21,
>>> 0.)  (22, 150.)  (23, -25.)  (28, -50.)  (29, 25.)
>>> row 23: (16, -25.)  (17, 0.)  (18, 25.)  (19, -100.)  (20, 25.)  (21,
>>> -25.)  (22, -25.)  (23, 150.)  (28, 0.)  (29, -25.)
>>> row 24: (6, 0.)  (7, -25.)  (12, -50.)  (13, 25.)  (18, -100.)  (19,
>>> 25.)  (24, 300.)  (25, -50.)  (26, -100.)  (27, 25.)  (28, -50.)  (29,
>>> 25.)  (30, 0.)  (31, -25.)
>>> row 25: (6, -25.)  (7, 0.)  (12, 25.)  (13, -100.)  (18, 25.)  (19,
>>> -50.)  (24, -50.)  (25, 300.)  (26, 25.)  (27, -50.)  (28, 25.)  (29,
>>> -100.)  (30, -25.)  (31, 0.)
>>> row 26: (12, 0.)  (13, -25.)  (14, -25.)  (15, 25.)  (24, -100.)  (25,
>>> 25.)  (26, 150.)  (27, -25.)  (30, -25.)  (31, 0.)
>>> row 27: (12, -25.)  (13, 0.)  (14, 0.)  (15, -50.)  (24, 25.)  (25,
>>> -50.)  (26, -25.)  (27, 150.)  (30, 25.)  (31, -50.)
>>> row 28: (18, 0.)  (19, -25.)  (22, -50.)  (23, 0.)  (24, -50.)  (25,
>>> 25.)  (28, 150.)  (29, -25.)  (30, -50.)  (31, 25.)
>>> row 29: (18, -25.)  (19, 0.)  (22, 25.)  (23, -25.)  (24, 25.)  (25,
>>> -100.)  (28, -25.)  (29, 150.)  (30, 0.)  (31, -25.)
>>> row 30: (24, 0.)  (25, -25.)  (26, -25.)  (27, 25.)  (28, -50.)  (29,
>>> 0.)  (30, 75.)  (31, 0.)
>>> row 31: (24, -25.)  (25, 0.)  (26, 0.)  (27, -50.)  (28, 25.)  (29,
>>> -25.)  (30, 0.)  (31, 75.)
>>>
>>>
>>> ------------------------------
>>> 徐辉,Xu Hui
>>> 清华大学航天航空学院博士研究生
>>> PhD Candidate, School of Aerospace Engineering
>>> Tsinghua University
>>> Tel: 188-1152-7137
>>> Mail:459543524 at qq.com
>>>
>>>
>>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20220417/f019f29b/attachment-0001.html>


More information about the petsc-users mailing list