<div dir="ltr"><div>Dear PETSc Developers,</div><div><br></div><div>I am having trouble interfacing SuperLU_Dist as a direct solver for certain problems in PETSc. The problem is that when interfacing with SuperLU_Dist, you need your matrix to be of Type MPISEQAIJ when running MPI with one processor. PETSc has long allowed the use of Matrix type MPIAIJ for all MPI runs, including MPI with a single processor and that is still the case for all of PETSc's native solvers. This however has been broken for the SuperLU_Dist option. The following code snippet (in PETSc and not SuperLU_Dist) is responsible for this restriction and I do not know if it is by design or accident :</div><div><br></div><div>In file petsc-3.12.4/src/mat/impls/aij/mpi/superlu_dist/superlu_dist.c line 257 onwards :</div><div><br></div><div>ierr = MPI_Comm_size(PetscObjectComm((PetscObject)A),&size);CHKERRQ(ierr);<br><br>  if (size == 1) {<br>    aa = (Mat_SeqAIJ*)A->data;<br>    rstart = 0;<br>    nz     = aa->nz;<br>  } else {<br>    Mat_MPIAIJ *mat = (Mat_MPIAIJ*)A->data;<br>    aa = (Mat_SeqAIJ*)(mat->A)->data;<br>    bb = (Mat_SeqAIJ*)(mat->B)->data;<br>    ai = aa->i; aj = aa->j;<br>    bi = bb->i; bj = bb->j;</div><div><br></div><div>The code seems to check for number of processors and if it is = 1 conclude that the matrix is a Mat_SeqAIJ and perform some operations. Only if number-of-procs > 1 then it assumes that matrix is of type Mat_MPIAIJ. I think this is unwieldy and lacks generality. One would like the same piece of code to run in MPI mode for all processors with type Mat_MPIAIJ. Also this restriction has suddenly appeared in a recent version. The issue was not there until at least 3.9.4. So my question is from now (e.g. v12.4) on, should we always use matrix type Mat_SeqAIJ when running on 1 processor even with MPI enabled and use Mat_MPIAIJ for more than 1 processor. That is use the number of processors in use as a criterion to set the matrix type ?</div><div><br></div><div>A an illustration, I have attached a minor modification of KSP example 12, that used to work with all PETSc versions until at least 3.9.4 but now throws a segmentation fault. It was compiled with MPI and run with mpiexec -n 1 ./ex12</div><div>If I remove the "ierr = MatSetType(A,MATMPIAIJ);CHKERRQ(ierr);" it is okay.</div><div><br></div><div>I hope you can clarify my confusion.</div><div><br></div><div>Regards,</div><div>Rochan<br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div></div>