<div dir="ltr"><div dir="ltr">On Sun, Aug 27, 2023 at 8:30 AM maitri ksh <<a href="mailto:maitri.ksh@gmail.com">maitri.ksh@gmail.com</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi, <div>I am using MatSetSizes() followed by MatLoad() to distribute the rows of a <b>sparse</b> matrix (<b>480000x480000</b>) across the processors. But it seems like the entire matrix is getting loaded in each of the processors instead of distributing it. What am I missing here?</div><div><div><b><br></b></div><div><b>code snippet:</b></div><div> Mat Js;<br> MatType type = MATMPIAIJ;<br> PetscViewer viewerJ;<br> PetscCall(PetscViewerBinaryOpen(PETSC_COMM_WORLD, "Js.dat", FILE_MODE_READ, &viewerJ)); <br> PetscCall(MatCreate(PETSC_COMM_WORLD, &Js));<br> PetscCall(MatSetSizes(Js, PETSC_DECIDE, PETSC_DECIDE, N, N));<br> PetscCall(MatSetType(Js, type));<br> PetscCall(MatLoad(Js, viewerJ));<br> PetscCall(PetscViewerDestroy(&viewerJ));<br> PetscCall(MatGetLocalSize(Js, &m, &n));<br> PetscCall(MatGetSize(Js, &M, &N)); <br> PetscPrintf(PETSC_COMM_WORLD, "Js,Local rows: %d, Local columns: %d\n", m, n);<br></div></div></div></blockquote><div><br></div><div>If this was really PETSC_COMM_WORLD, then this print statement would only output once, but you have 4 lines. Therefore, MPI is messed up. I am guessing you used an 'mpirun' or 'mpiexec' that is from a different MPI, and therefore the launch did not work correctly. If you had PETSc install MPI, then the correct one is in</div><div><br></div><div> ${PETSC_DIR}/${PETSC_ARCH}/bin/mpiexec</div><div><br></div><div> Thanks,</div><div><br></div><div> Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><div><div><br></div><div><b>Output </b>of 'mpiexec -n 4 ./check':</div></div></div><div>Js,Local rows: 480000, Local columns: 480000<br>Js,Local rows: 480000, Local columns: 480000<br>Js,Local rows: 480000, Local columns: 480000<br>Js,Local rows: 480000, Local columns: 480000<br></div><div><br></div><div><br></div></div>
</blockquote></div><br clear="all"><div><br></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>-- Norbert Wiener</div><div><br></div><div><a href="http://www.cse.buffalo.edu/~knepley/" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br></div></div></div></div></div></div></div></div>