<div dir="ltr"><div dir="ltr">On Tue, Feb 12, 2019 at 6:43 PM Maahi Talukder via petsc-users <<a href="mailto:petsc-users@mcs.anl.gov">petsc-users@mcs.anl.gov</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"><div dir="ltr"><div dir="ltr"><br></div><div dir="ltr">Dear All,<br><div><br></div><div><br></div><div>I am tying to solve a linear system using ksp solvers. I have managed to solve the system with a sequential code. The part of my sequential code that deals with creating Matrix and setting values is as the following - </div><div><br></div><div><div>call MatCreate(PETSC_COMM_WORLD,Mp,ierr)</div><div>call MatSetSizes(Mp,PETSC_DECIDE,PETSC_DECIDE,u*v,u*v,ierr)</div><div>call MatSetFromOptions(Mp,ierr)</div><div>call MatSetUp(Mp,ierr)</div><div><br></div><div>Do p = 1,29008</div><div>Do r = 1,29008</div><div>if(Q(p,r)/=0.0) then</div><div>val(1) = Q(p,r)</div><div>col(1) = r-1</div><div>call MatSetValues(Mp,ione,p-1,ione,col,val,INSERT_VALUES,ierr)</div><div>endif</div><div>end Do</div><div>end Do</div><div><br></div><div>call MatAssemblyBegin(Mp,MAT_FINAL_ASSEMBLY,ierr)</div><div>call MatAssemblyEnd(Mp,MAT_FINAL_ASSEMBLY,ierr)</div></div><div><br></div><div>And the part of my sequential code that creates the vector is -</div><div><br></div><div><div>call VecCreateMPI(PETSC_COMM_WORLD,PETSC_DECIDE,u*v,Bx,ierr)</div><div>call VecSetFromOptions(Bx,ierr)</div><div>call VecDuplicate(Bx,Xp,ierr)</div><div>call VecSet(Bx,zero,ierr) </div><div><br></div><div>Do p = 1,29008</div><div>if(Fx(p,1)/=0.0) then</div><div>val(1) = Fx(p,1)</div><div>call VecSetValues(Bx,ione,p-1,val,INSERT_VALUES,ierr)</div><div>endif</div><div>end Do</div><div><br></div><div>call VecAssemblyBegin(Bx,ierr)</div><div>call VecAssemblyEnd(Bx,ierr)</div></div><div><br></div><div>So when I run the code on single processor, it runs fine. But when I tried to run it on more than one processor, it failed. </div></div></div></div></blockquote><div><br></div><div>How? We cannot guess how it fails. You have to send the ENTIRE error message.</div><div><br></div><div>Looking about it should not fail, but it will be really inefficient because every process sets every value in the matrix and vector.</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 dir="ltr"><div dir="ltr"><div> Now from what I understood from going through the manual is that if I use MatCreate to create my Matrix, then depending on the no of processor that I put in after 'mpiexec -n ...' , it either acts either as a sequential code or a parallel code. And I don't need to anything extra to make it work in parallel, as PETSc does that internally. </div><div><br></div><div>So would you please let me know what modifications I need to do to my existing sequential code to make it work in parallel like using MatGetOwnershipRange ? </div><div><br></div><div>Regards,</div><div>Maahi Talukder</div><div>MSc Student</div><div>Clarkson University</div><div><br></div><div><br></div><div><br></div></div></div></div>
</blockquote></div><br clear="all"><div><br></div>-- <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>