[petsc-users] MatCreateSubMatricesMPI strange behavior

Alexis SALZMAN alexis.salzman at ec-nantes.fr
Fri Jul 25 04:15:48 CDT 2025


Hi,

As I am relatively new to Petsc, I may have misunderstood how to use the 
MatCreateSubMatricesMPI function. The attached code is tuned for three 
processes and extracts one matrix for each colour of a subcommunicator 
that has been created using the MPI_Comm_split function from an  MPIAij 
matrix. The following error message appears when the code is set to its 
default configuration (i.e. when a rectangular matrix is extracted with 
more rows than columns for colour 0):

[0]PETSC ERROR: --------------------- Error Message 
--------------------------------------------------------------
[0]PETSC ERROR: Argument out of range
[0]PETSC ERROR: Column too large: col 4 max 3
[0]PETSC ERROR: See https://urldefense.us/v3/__https://petsc.org/release/faq/__;!!G_uCfscf7eWS!ZqH097BZ0G0O3WI7RWrwIKFNpyk0czSWEqfusAeTlgEygAffwpgBUzsLw1TIoGkjZ3mYG-NRQxxFoxU4y8EyY0ofiz9I43Qwe0w$  for trouble shooting.
[0]PETSC ERROR: Petsc Release Version 3.22.2, unknown

... petsc git hash 2a89477b25f compiled on a dell i9 computer with Gcc 
14.3, mkl 2025.2, .....
[0]PETSC ERROR: #1 MatSetValues_SeqAIJ() at 
...petsc/src/mat/impls/aij/seq/aij.c:426
[0]PETSC ERROR: #2 MatSetValues() at 
...petsc/src/mat/interface/matrix.c:1543
[0]PETSC ERROR: #3 MatSetSeqMats_MPIAIJ() at 
.../petsc/src/mat/impls/aij/mpi/mpiov.c:2965
[0]PETSC ERROR: #4 MatCreateSubMatricesMPI_MPIXAIJ() at 
.../petsc/src/mat/impls/aij/mpi/mpiov.c:3163
[0]PETSC ERROR: #5 MatCreateSubMatricesMPI_MPIAIJ() at 
.../petsc/src/mat/impls/aij/mpi/mpiov.c:3196
[0]PETSC ERROR: #6 MatCreateSubMatricesMPI() at 
.../petsc/src/mat/interface/matrix.c:7293
[0]PETSC ERROR: #7 main() at sub.c:169

When the '-ok' option is selected, the code extracts a square matrix for 
colour 0, which runs smoothly in this case. Selecting the '-trans' 
option swaps the row and column selection indices, providing a 
transposed submatrix smoothly. For colour 1, which uses only one process 
and is therefore sequential, rectangular extraction is OK regardless of 
the shape.

Is this dependency on the shape expected? Have I missed an important 
tuning step somewhere?

Thank you in advance for any clarification.

Regards

A.S.

P.S.: I'm sorry, but as I'm leaving my office for the following weeks 
this evening, I won't be very responsive during this period.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: sub.c
Type: text/x-csrc
Size: 6037 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20250725/a2ef5f2b/attachment.bin>


More information about the petsc-users mailing list